hail

package
v0.0.0-...-084e4ab Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultModelOptions = []resource.Option{
	WithKeepAlive(30 * time.Second),
}

DefaultModelOptions holds the default options for the model.

Functions

func WithHailApiClientFactory

func WithHailApiClientFactory(f func(name string) (traits.HailApiClient, error)) router.Option

WithHailApiClientFactory instructs the router to create a new client the first time Get is called for that name.

func WithHailInfoClientFactory

func WithHailInfoClientFactory(f func(name string) (traits.HailInfoClient, error)) router.Option

WithHailInfoClientFactory instructs the router to create a new client the first time Get is called for that name.

func WrapApi

func WrapApi(server traits.HailApiServer) traits.HailApiClient

WrapApi adapts a traits.HailApiServer and presents it as a traits.HailApiClient

func WrapInfo

func WrapInfo(server traits.HailInfoServer) traits.HailInfoClient

WrapInfo adapts a traits.HailInfoServer and presents it as a traits.HailInfoClient

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 NewApiRouter(opts ...router.Option) *ApiRouter

func (*ApiRouter) Add

func (r *ApiRouter) Add(name string, client any) any

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 (r *ApiRouter) CreateHail(ctx context.Context, request *traits.CreateHailRequest) (*traits.Hail, error)

func (*ApiRouter) DeleteHail

func (*ApiRouter) GetHail

func (r *ApiRouter) GetHail(ctx context.Context, request *traits.GetHailRequest) (*traits.Hail, error)

func (*ApiRouter) GetHailApiClient

func (r *ApiRouter) GetHailApiClient(name string) (traits.HailApiClient, error)

func (*ApiRouter) HoldsType

func (r *ApiRouter) HoldsType(client any) bool

func (*ApiRouter) ListHails

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.Server)

func (*ApiRouter) RemoveHailApiClient

func (r *ApiRouter) RemoveHailApiClient(name string) traits.HailApiClient

func (*ApiRouter) UpdateHail

func (r *ApiRouter) UpdateHail(ctx context.Context, request *traits.UpdateHailRequest) (*traits.Hail, error)

type HailChange

type HailChange struct {
	ChangeTime time.Time
	Value      *traits.Hail
}

type HailsChange

type HailsChange struct {
	ChangeType types.ChangeType
	ChangeTime time.Time
	OldValue   *traits.Hail
	NewValue   *traits.Hail
}

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.Server)

func (*InfoRouter) RemoveHailInfoClient

func (r *InfoRouter) RemoveHailInfoClient(name string) traits.HailInfoClient

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model describes the data structure needed to implement the Hail trait.

func NewModel

func NewModel(opts ...resource.Option) *Model

NewModel creates a new model.

func (*Model) CreateHail

func (m *Model) CreateHail(hail *traits.Hail) (*traits.Hail, error)

func (*Model) DeleteHail

func (m *Model) DeleteHail(id string, opts ...resource.WriteOption) (*traits.Hail, error)

func (*Model) GetHail

func (m *Model) GetHail(id string, opts ...resource.ReadOption) (*traits.Hail, bool)

func (*Model) ListHails

func (m *Model) ListHails(opts ...resource.ReadOption) []*traits.Hail

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

func (m *Model) UpdateHail(hail *traits.Hail, opts ...resource.WriteOption) (*traits.Hail, error)

type ModelOption

type ModelOption interface {
	resource.Option
	// contains filtered or unexported methods
}

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 (*ModelServer) GetHail

func (m *ModelServer) GetHail(_ context.Context, request *traits.GetHailRequest) (*traits.Hail, error)

func (*ModelServer) ListHails

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.Server)

func (*ModelServer) Unwrap

func (m *ModelServer) Unwrap() any

func (*ModelServer) UpdateHail

func (m *ModelServer) UpdateHail(_ context.Context, request *traits.UpdateHailRequest) (*traits.Hail, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL