Documentation ¶
Index ¶
- Variables
- func WithHailApiClientFactory(f func(name string) (traits.HailApiClient, error)) router.Option
- func WithHailInfoClientFactory(f func(name string) (traits.HailInfoClient, error)) router.Option
- type ApiRouter
- func (r *ApiRouter) Add(name string, client any) any
- func (r *ApiRouter) AddHailApiClient(name string, client traits.HailApiClient) traits.HailApiClient
- func (r *ApiRouter) CreateHail(ctx context.Context, request *traits.CreateHailRequest) (*traits.Hail, error)
- func (r *ApiRouter) DeleteHail(ctx context.Context, request *traits.DeleteHailRequest) (*traits.DeleteHailResponse, error)
- func (r *ApiRouter) GetHail(ctx context.Context, request *traits.GetHailRequest) (*traits.Hail, error)
- func (r *ApiRouter) GetHailApiClient(name string) (traits.HailApiClient, error)
- func (r *ApiRouter) HoldsType(client any) bool
- func (r *ApiRouter) ListHails(ctx context.Context, request *traits.ListHailsRequest) (*traits.ListHailsResponse, error)
- func (r *ApiRouter) PullHail(request *traits.PullHailRequest, server traits.HailApi_PullHailServer) error
- func (r *ApiRouter) PullHails(request *traits.PullHailsRequest, server traits.HailApi_PullHailsServer) error
- func (r *ApiRouter) Register(server grpc.ServiceRegistrar)
- func (r *ApiRouter) RemoveHailApiClient(name string) traits.HailApiClient
- func (r *ApiRouter) UpdateHail(ctx context.Context, request *traits.UpdateHailRequest) (*traits.Hail, error)
- type ApiWrapper
- type HailChange
- type HailsChange
- type InfoRouter
- func (r *InfoRouter) Add(name string, client any) any
- func (r *InfoRouter) AddHailInfoClient(name string, client traits.HailInfoClient) traits.HailInfoClient
- func (r *InfoRouter) GetHailInfoClient(name string) (traits.HailInfoClient, error)
- func (r *InfoRouter) HoldsType(client any) bool
- func (r *InfoRouter) Register(server grpc.ServiceRegistrar)
- func (r *InfoRouter) RemoveHailInfoClient(name string) traits.HailInfoClient
- type InfoWrapper
- type Model
- func (m *Model) CreateHail(hail *traits.Hail) (*traits.Hail, error)
- func (m *Model) DeleteHail(id string, opts ...resource.WriteOption) (*traits.Hail, error)
- func (m *Model) GetHail(id string, opts ...resource.ReadOption) (*traits.Hail, bool)
- func (m *Model) ListHails(opts ...resource.ReadOption) []*traits.Hail
- func (m *Model) PullHail(ctx context.Context, id string, opts ...resource.ReadOption) <-chan HailChange
- func (m *Model) PullHails(ctx context.Context, opts ...resource.ReadOption) <-chan HailsChange
- func (m *Model) UpdateHail(hail *traits.Hail, opts ...resource.WriteOption) (*traits.Hail, error)
- type ModelOption
- type ModelServer
- func (m *ModelServer) CreateHail(_ context.Context, request *traits.CreateHailRequest) (*traits.Hail, error)
- func (m *ModelServer) DeleteHail(_ context.Context, request *traits.DeleteHailRequest) (*traits.DeleteHailResponse, error)
- func (m *ModelServer) GetHail(_ context.Context, request *traits.GetHailRequest) (*traits.Hail, error)
- func (m *ModelServer) ListHails(_ context.Context, request *traits.ListHailsRequest) (*traits.ListHailsResponse, error)
- func (m *ModelServer) PullHail(request *traits.PullHailRequest, server traits.HailApi_PullHailServer) error
- func (m *ModelServer) PullHails(request *traits.PullHailsRequest, server traits.HailApi_PullHailsServer) error
- func (m *ModelServer) Register(server grpc.ServiceRegistrar)
- func (m *ModelServer) Unwrap() any
- func (m *ModelServer) UpdateHail(_ context.Context, request *traits.UpdateHailRequest) (*traits.Hail, error)
Constants ¶
This section is empty.
Variables ¶
var DefaultModelOptions = []resource.Option{ WithKeepAlive(30 * time.Second), }
DefaultModelOptions holds the default options for the model.
Functions ¶
func WithHailApiClientFactory ¶
WithHailApiClientFactory instructs the router to create a new client the first time Get is called for that name.
func WithHailInfoClientFactory ¶
WithHailInfoClientFactory instructs the router to create a new client the first time Get is called for that name.
Types ¶
type ApiRouter ¶
type ApiRouter struct { traits.UnimplementedHailApiServer router.Router }
ApiRouter is a traits.HailApiServer that allows routing named requests to specific traits.HailApiClient
func NewApiRouter ¶
func (*ApiRouter) Add ¶
Add extends Router.Add to panic if client is not of type traits.HailApiClient.
func (*ApiRouter) AddHailApiClient ¶
func (r *ApiRouter) AddHailApiClient(name string, client traits.HailApiClient) traits.HailApiClient
func (*ApiRouter) CreateHail ¶
func (*ApiRouter) DeleteHail ¶
func (r *ApiRouter) DeleteHail(ctx context.Context, request *traits.DeleteHailRequest) (*traits.DeleteHailResponse, error)
func (*ApiRouter) GetHailApiClient ¶
func (r *ApiRouter) GetHailApiClient(name string) (traits.HailApiClient, error)
func (*ApiRouter) ListHails ¶
func (r *ApiRouter) ListHails(ctx context.Context, request *traits.ListHailsRequest) (*traits.ListHailsResponse, error)
func (*ApiRouter) PullHail ¶
func (r *ApiRouter) PullHail(request *traits.PullHailRequest, server traits.HailApi_PullHailServer) error
func (*ApiRouter) PullHails ¶
func (r *ApiRouter) PullHails(request *traits.PullHailsRequest, server traits.HailApi_PullHailsServer) error
func (*ApiRouter) Register ¶
func (r *ApiRouter) Register(server grpc.ServiceRegistrar)
func (*ApiRouter) RemoveHailApiClient ¶
func (r *ApiRouter) RemoveHailApiClient(name string) traits.HailApiClient
func (*ApiRouter) UpdateHail ¶
type ApiWrapper ¶
type ApiWrapper struct { traits.HailApiClient // contains filtered or unexported fields }
func WrapApi ¶
func WrapApi(server traits.HailApiServer) *ApiWrapper
WrapApi adapts a traits.HailApiServer and presents it as a traits.HailApiClient
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.HailApiServer
UnwrapServer returns the underlying server instance.
func (*ApiWrapper) UnwrapService ¶
func (w *ApiWrapper) UnwrapService() (grpc.ClientConnInterface, grpc.ServiceDesc)
type HailsChange ¶
type InfoRouter ¶
type InfoRouter struct { traits.UnimplementedHailInfoServer router.Router }
InfoRouter is a traits.HailInfoServer that allows routing named requests to specific traits.HailInfoClient
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.HailInfoClient.
func (*InfoRouter) AddHailInfoClient ¶
func (r *InfoRouter) AddHailInfoClient(name string, client traits.HailInfoClient) traits.HailInfoClient
func (*InfoRouter) GetHailInfoClient ¶
func (r *InfoRouter) GetHailInfoClient(name string) (traits.HailInfoClient, error)
func (*InfoRouter) HoldsType ¶
func (r *InfoRouter) HoldsType(client any) bool
func (*InfoRouter) Register ¶
func (r *InfoRouter) Register(server grpc.ServiceRegistrar)
func (*InfoRouter) RemoveHailInfoClient ¶
func (r *InfoRouter) RemoveHailInfoClient(name string) traits.HailInfoClient
type InfoWrapper ¶
type InfoWrapper struct { traits.HailInfoClient // contains filtered or unexported fields }
func WrapInfo ¶
func WrapInfo(server traits.HailInfoServer) *InfoWrapper
WrapInfo adapts a traits.HailInfoServer and presents it as a traits.HailInfoClient
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.HailInfoServer
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 describes the data structure needed to implement the Hail trait.
func (*Model) DeleteHail ¶
func (*Model) PullHail ¶
func (m *Model) PullHail(ctx context.Context, id string, opts ...resource.ReadOption) <-chan HailChange
PullHail subscribes to changes in a single hail. The returned channel is closed when ctx is Done or the hail identified by id is deleted.
func (*Model) PullHails ¶
func (m *Model) PullHails(ctx context.Context, opts ...resource.ReadOption) <-chan HailsChange
func (*Model) UpdateHail ¶
type ModelOption ¶
ModelOption defined the base type for all options that apply to this traits model.
func WithKeepAlive ¶
func WithKeepAlive(keepAlive time.Duration) ModelOption
WithKeepAlive configures the minimum time a Hail will live after it has reached the ARRIVED state before it is deleted. It may last longer than this time.
Negative durations imply hails are never automatically removed.
type ModelServer ¶
type ModelServer struct { traits.UnimplementedHailApiServer // contains filtered or unexported fields }
ModelServer adapts a Model to implement traits.HailApiServer.
func NewModelServer ¶
func NewModelServer(model *Model) *ModelServer
func (*ModelServer) CreateHail ¶
func (m *ModelServer) CreateHail(_ context.Context, request *traits.CreateHailRequest) (*traits.Hail, error)
func (*ModelServer) DeleteHail ¶
func (m *ModelServer) DeleteHail(_ context.Context, request *traits.DeleteHailRequest) (*traits.DeleteHailResponse, error)
func (*ModelServer) GetHail ¶
func (m *ModelServer) GetHail(_ context.Context, request *traits.GetHailRequest) (*traits.Hail, error)
func (*ModelServer) ListHails ¶
func (m *ModelServer) ListHails(_ context.Context, request *traits.ListHailsRequest) (*traits.ListHailsResponse, error)
func (*ModelServer) PullHail ¶
func (m *ModelServer) PullHail(request *traits.PullHailRequest, server traits.HailApi_PullHailServer) error
func (*ModelServer) PullHails ¶
func (m *ModelServer) PullHails(request *traits.PullHailsRequest, server traits.HailApi_PullHailsServer) error
func (*ModelServer) Register ¶
func (m *ModelServer) Register(server grpc.ServiceRegistrar)
func (*ModelServer) Unwrap ¶
func (m *ModelServer) Unwrap() any
func (*ModelServer) UpdateHail ¶
func (m *ModelServer) UpdateHail(_ context.Context, request *traits.UpdateHailRequest) (*traits.Hail, error)