Documentation ¶
Index ¶
- Variables
- func WithChildrenOption(opts ...resource.Option) resource.Option
- func WithInitialChildren(children ...*traits.Child) resource.Option
- func WithParentApiClientFactory(f func(name string) (traits.ParentApiClient, error)) router.Option
- func WithParentInfoClientFactory(f func(name string) (traits.ParentInfoClient, error)) router.Option
- type ApiRouter
- func (r *ApiRouter) Add(name string, client any) any
- func (r *ApiRouter) AddParentApiClient(name string, client traits.ParentApiClient) traits.ParentApiClient
- func (r *ApiRouter) GetParentApiClient(name string) (traits.ParentApiClient, error)
- func (r *ApiRouter) HoldsType(client any) bool
- func (r *ApiRouter) ListChildren(ctx context.Context, request *traits.ListChildrenRequest) (*traits.ListChildrenResponse, error)
- func (r *ApiRouter) PullChildren(request *traits.PullChildrenRequest, ...) error
- func (r *ApiRouter) Register(server grpc.ServiceRegistrar)
- func (r *ApiRouter) RemoveParentApiClient(name string) traits.ParentApiClient
- type ApiWrapper
- type InfoRouter
- func (r *InfoRouter) Add(name string, client any) any
- func (r *InfoRouter) AddParentInfoClient(name string, client traits.ParentInfoClient) traits.ParentInfoClient
- func (r *InfoRouter) GetParentInfoClient(name string) (traits.ParentInfoClient, error)
- func (r *InfoRouter) HoldsType(client any) bool
- func (r *InfoRouter) Register(server grpc.ServiceRegistrar)
- func (r *InfoRouter) RemoveParentInfoClient(name string) traits.ParentInfoClient
- type InfoWrapper
- type Model
- func (m *Model) AddChild(child *traits.Child)
- func (m *Model) AddChildTrait(name string, traitName ...trait.Name) (child *traits.Child, created bool)
- func (m *Model) ListChildren() []*traits.Child
- func (m *Model) PullChildren(ctx context.Context, opts ...resource.ReadOption) <-chan *traits.PullChildrenResponse_Change
- func (m *Model) RemoveChildByName(name string, opts ...resource.WriteOption) (*traits.Child, error)
- func (m *Model) RemoveChildTrait(name string, traitName ...trait.Name) *traits.Child
- type ModelOption
- type ModelServer
Constants ¶
This section is empty.
Variables ¶
DefaultModelOptions holds the default options for the model.
Functions ¶
func WithChildrenOption ¶
WithChildrenOption configures the children resource of the model.
func WithInitialChildren ¶
WithInitialChildren returns an option that configures the model to initialise with the given children. Can be called multiple times to add more children. Panics if any child has no name. Panics if any child's traits are not sorted.
func WithParentApiClientFactory ¶
WithParentApiClientFactory instructs the router to create a new client the first time Get is called for that name.
func WithParentInfoClientFactory ¶
func WithParentInfoClientFactory(f func(name string) (traits.ParentInfoClient, error)) router.Option
WithParentInfoClientFactory instructs the router to create a new client the first time Get is called for that name.
Types ¶
type ApiRouter ¶
type ApiRouter struct { traits.UnimplementedParentApiServer router.Router }
ApiRouter is a traits.ParentApiServer that allows routing named requests to specific traits.ParentApiClient
func NewApiRouter ¶
func (*ApiRouter) Add ¶
Add extends Router.Add to panic if client is not of type traits.ParentApiClient.
func (*ApiRouter) AddParentApiClient ¶
func (r *ApiRouter) AddParentApiClient(name string, client traits.ParentApiClient) traits.ParentApiClient
func (*ApiRouter) GetParentApiClient ¶
func (r *ApiRouter) GetParentApiClient(name string) (traits.ParentApiClient, error)
func (*ApiRouter) ListChildren ¶
func (r *ApiRouter) ListChildren(ctx context.Context, request *traits.ListChildrenRequest) (*traits.ListChildrenResponse, error)
func (*ApiRouter) PullChildren ¶
func (r *ApiRouter) PullChildren(request *traits.PullChildrenRequest, server traits.ParentApi_PullChildrenServer) error
func (*ApiRouter) Register ¶
func (r *ApiRouter) Register(server grpc.ServiceRegistrar)
func (*ApiRouter) RemoveParentApiClient ¶
func (r *ApiRouter) RemoveParentApiClient(name string) traits.ParentApiClient
type ApiWrapper ¶
type ApiWrapper struct { traits.ParentApiClient // contains filtered or unexported fields }
func WrapApi ¶
func WrapApi(server traits.ParentApiServer) *ApiWrapper
WrapApi adapts a traits.ParentApiServer and presents it as a traits.ParentApiClient
func (*ApiWrapper) Unwrap ¶
func (w *ApiWrapper) Unwrap() any
Unwrap implements wrap.Unwrapper and returns the underlying server instance as an unknown type.
func (*ApiWrapper) UnwrapServer ¶
func (w *ApiWrapper) UnwrapServer() traits.ParentApiServer
UnwrapServer returns the underlying server instance.
func (*ApiWrapper) UnwrapService ¶
func (w *ApiWrapper) UnwrapService() (grpc.ClientConnInterface, grpc.ServiceDesc)
type InfoRouter ¶
type InfoRouter struct { traits.UnimplementedParentInfoServer router.Router }
InfoRouter is a traits.ParentInfoServer that allows routing named requests to specific traits.ParentInfoClient
func NewInfoRouter ¶
func NewInfoRouter(opts ...router.Option) *InfoRouter
func (*InfoRouter) Add ¶
func (r *InfoRouter) Add(name string, client any) any
Add extends Router.Add to panic if client is not of type traits.ParentInfoClient.
func (*InfoRouter) AddParentInfoClient ¶
func (r *InfoRouter) AddParentInfoClient(name string, client traits.ParentInfoClient) traits.ParentInfoClient
func (*InfoRouter) GetParentInfoClient ¶
func (r *InfoRouter) GetParentInfoClient(name string) (traits.ParentInfoClient, error)
func (*InfoRouter) HoldsType ¶
func (r *InfoRouter) HoldsType(client any) bool
func (*InfoRouter) Register ¶
func (r *InfoRouter) Register(server grpc.ServiceRegistrar)
func (*InfoRouter) RemoveParentInfoClient ¶
func (r *InfoRouter) RemoveParentInfoClient(name string) traits.ParentInfoClient
type InfoWrapper ¶
type InfoWrapper struct { traits.ParentInfoClient // contains filtered or unexported fields }
func WrapInfo ¶
func WrapInfo(server traits.ParentInfoServer) *InfoWrapper
WrapInfo adapts a traits.ParentInfoServer and presents it as a traits.ParentInfoClient
func (*InfoWrapper) Unwrap ¶
func (w *InfoWrapper) Unwrap() any
Unwrap implements wrap.Unwrapper and returns the underlying server instance as an unknown type.
func (*InfoWrapper) UnwrapServer ¶
func (w *InfoWrapper) UnwrapServer() traits.ParentInfoServer
UnwrapServer returns the underlying server instance.
func (*InfoWrapper) UnwrapService ¶
func (w *InfoWrapper) UnwrapService() (grpc.ClientConnInterface, grpc.ServiceDesc)
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model models a collection of children.
func (*Model) AddChild ¶
AddChild inserts a child into this model. If a child with the given Child.Name already exists, no changes will be made. Panics if child.Traits are not sorted in ascending order, required by AddChildTrait.
func (*Model) AddChildTrait ¶
func (m *Model) AddChildTrait(name string, traitName ...trait.Name) (child *traits.Child, created bool)
AddChildTrait ensures that a child with the given name and list of trait names exists in this model. If no child with the given name is already know, one will be created. If a child is already known with the given name, its traits will be unioned with the given trait names.
func (*Model) ListChildren ¶
ListChildren returns a slice of all known Child instances.
func (*Model) PullChildren ¶
func (m *Model) PullChildren(ctx context.Context, opts ...resource.ReadOption) <-chan *traits.PullChildrenResponse_Change
PullChildren returns a chan that will emit when changes are made to the known children of this model.
func (*Model) RemoveChildByName ¶
RemoveChildByName removes a child from this model matching the given name.
type ModelOption ¶
ModelOption defined the base type for all options that apply to this traits model.
type ModelServer ¶
type ModelServer struct { traits.UnimplementedParentApiServer // contains filtered or unexported fields }
ModelServer exposes Model as a traits.ParentApiServer.
func NewModelServer ¶
func NewModelServer(model *Model) *ModelServer
func (*ModelServer) ListChildren ¶
func (s *ModelServer) ListChildren(_ context.Context, request *traits.ListChildrenRequest) (*traits.ListChildrenResponse, error)
func (*ModelServer) PullChildren ¶
func (s *ModelServer) PullChildren(request *traits.PullChildrenRequest, server traits.ParentApi_PullChildrenServer) error
func (*ModelServer) Unwrap ¶
func (s *ModelServer) Unwrap() any