The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/kindsys/bind.go

96 lines
1.9 KiB

package kindsys
import (
"github.com/grafana/thema"
)
// genericComposable is a general representation of a parsed and validated
// Composable kind.
type genericComposable struct {
def Def[ComposableProperties]
lin thema.Lineage
}
var _ Composable = genericComposable{}
func (k genericComposable) Props() SomeKindProperties {
return k.def.Properties
}
func (k genericComposable) Name() string {
return k.def.Properties.Name
}
func (k genericComposable) MachineName() string {
return k.def.Properties.MachineName
}
func (k genericComposable) Maturity() Maturity {
return k.def.Properties.Maturity
}
func (k genericComposable) Def() Def[ComposableProperties] {
return k.def
}
func (k genericComposable) Lineage() thema.Lineage {
return k.lin
}
// TODO docs
func BindComposable(rt *thema.Runtime, def Def[ComposableProperties], opts ...thema.BindOption) (Composable, error) {
lin, err := def.Some().BindKindLineage(rt, opts...)
if err != nil {
return nil, err
}
return genericComposable{
def: def,
lin: lin,
}, nil
}
// genericCore is a general representation of a parsed and validated Core kind.
type genericCore struct {
def Def[CoreProperties]
lin thema.Lineage
}
var _ Core = genericCore{}
func (k genericCore) Props() SomeKindProperties {
return k.def.Properties
}
func (k genericCore) Name() string {
return k.def.Properties.Name
}
func (k genericCore) MachineName() string {
return k.def.Properties.MachineName
}
func (k genericCore) Maturity() Maturity {
return k.def.Properties.Maturity
}
func (k genericCore) Def() Def[CoreProperties] {
return k.def
}
func (k genericCore) Lineage() thema.Lineage {
return k.lin
}
// TODO docs
func BindCore(rt *thema.Runtime, def Def[CoreProperties], opts ...thema.BindOption) (Core, error) {
lin, err := def.Some().BindKindLineage(rt, opts...)
if err != nil {
return nil, err
}
return genericCore{
def: def,
lin: lin,
}, nil
}