xcweaver

package
v0.24.3 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: Apache-2.0 Imports: 56 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// SetLogger sets the logger of a component implementation struct. impl
	// should be a pointer to the implementation struct.
	SetLogger func(impl any, logger *slog.Logger) error

	// SetWeaverInfo sets the application's runtime information.
	SetWeaverInfo func(impl any, info *WeaverInfo) error

	// HasRefs returns whether the provided component implementation has
	// xcweaver.Refs fields.
	HasRefs func(impl any) bool

	// FillRefs initializes Ref[T] fields in a component implement struct.
	//   - impl should be a pointer to the implementation struct
	//   - get should be a function that returns the component of interface
	//     type T when passed the reflect.Type for T.
	FillRefs func(impl any, get func(reflect.Type) (any, error)) error

	// HasListeners returns whether the provided component implementation has
	// xcweaver.Listener fields.
	HasListeners func(impl any) bool

	// FillListeners initializes Listener fields in a component implementation
	// struct.
	//   - impl should be a pointer to the implementation struct
	//   - get should be a function that returns the required Listener values,
	//     namely the network listener and the proxy address.
	FillListeners func(impl any, get func(string) (net.Listener, string, error)) error

	// HasAntipodeAgents returns whether the provided component implementation has
	// xcweaver.Antipode fields.
	HasAntipodeAgents func(impl any) bool

	// FillAntipodeAgents initializes Antipode fields in a component implementation
	// struct.
	//   - impl should be a pointer to the implementation struct
	//   - get should be a function that returns the required Antipode values,
	//     namely the datastore type and the datastore id.
	FillAntipodeAgents func(impl any, get func(string) (antipode.Datastore_type, string, error)) error

	// HasConfig returns whether the provided component implementation has
	// an embedded xcweaver.Config field.
	HasConfig func(impl any) bool

	// GetConfig returns the config stored in the provided component
	// implementation, or returns nil if there is no config.
	GetConfig func(impl any) any
)

Functions

This section is empty.

Types

type RemoteWeavelet

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

RemoteWeavelet is a weavelet that runs some components locally, but coordinates with a deployer over a set of Unix pipes to start other components remotely. It is the weavelet used by all deployers, except for the single process deployer.

RemoteWeavelet must implement the xcweaver.controller component interface.

func NewRemoteWeavelet

func NewRemoteWeavelet(ctx context.Context, regs []*codegen.Registration, bootstrap runtime.Bootstrap, opts RemoteWeaveletOptions) (*RemoteWeavelet, error)

NewRemoteWeavelet returns a new RemoteWeavelet that hosts the components specified in the provided registrations. bootstrap is used to establish a connection with an envelope.

func (*RemoteWeavelet) GetHealth

GetHealth implements controller.GetHealth.

func (*RemoteWeavelet) GetImpl

func (w *RemoteWeavelet) GetImpl(t reflect.Type) (any, error)

GetImpl implements the Weavelet interface.

func (*RemoteWeavelet) GetIntf

func (w *RemoteWeavelet) GetIntf(t reflect.Type) (any, error)

GetIntf implements the Weavelet interface.

func (*RemoteWeavelet) GetLoad

GetLoad implements controller interface.

func (*RemoteWeavelet) GetMetrics

GetMetrics implements controller.GetMetrics.

func (*RemoteWeavelet) GetProfile

GetProfile implements controller.GetProfile.

func (*RemoteWeavelet) Info

func (w *RemoteWeavelet) Info() *protos.WeaveletArgs

Info returns the WeaveletArgs received from the envelope.

func (*RemoteWeavelet) InitWeavelet

InitWeavelet implements xcweaver.controller and conn.WeaverHandler interfaces.

func (*RemoteWeavelet) UpdateComponents

UpdateComponents implements xcweaver.controller and conn.WeaverHandler interfaces.

func (*RemoteWeavelet) UpdateRoutingInfo

UpdateRoutingInfo implements controller.UpdateRoutingInfo.

func (*RemoteWeavelet) Wait

func (w *RemoteWeavelet) Wait() error

Wait waits for the RemoteWeavelet to fully shut down after its context has been cancelled.

type RemoteWeaveletOptions

type RemoteWeaveletOptions struct {
	Fakes         map[reflect.Type]any // component fakes, by component interface type
	InjectRetries int                  // Number of artificial retries to inject per retriable call
}

RemoteWeaveletOptions configure a RemoteWeavelet.

type SingleWeavelet

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

SingleWeavelet is a weavelet that runs all components locally in a single process. It is the weavelet used when you "go run" a Service Weaver app.

func NewSingleWeavelet

func NewSingleWeavelet(ctx context.Context, regs []*codegen.Registration, opts SingleWeaveletOptions) (*SingleWeavelet, error)

NewSingleWeavelet returns a new SingleWeavelet that hosts the components specified in the provided registrations.

func (*SingleWeavelet) GetImpl

func (w *SingleWeavelet) GetImpl(t reflect.Type) (any, error)

GetImpl implements the Weavelet interface.

func (*SingleWeavelet) GetIntf

func (w *SingleWeavelet) GetIntf(t reflect.Type) (any, error)

GetIntf implements the Weavelet interface.

func (*SingleWeavelet) Metrics

Metrics implements the status.Server interface.

func (*SingleWeavelet) Profile

Profile implements the status.Server interface.

func (*SingleWeavelet) ServeStatus

func (w *SingleWeavelet) ServeStatus(ctx context.Context) error

ServeStatus runs an HTTP status server.

func (*SingleWeavelet) Status

Status implements the status.Server interface.

type SingleWeaveletOptions

type SingleWeaveletOptions struct {
	ConfigFilename string               // TOML config filename
	Config         string               // TOML config contents
	Fakes          map[reflect.Type]any // component fakes, by component interface type
	Quiet          bool                 // if true, do not print or log anything
}

SingleWeaveletOptions configure a SingleWeavelet.

type Weavelet

type Weavelet interface {
	// GetIntf returns a handle to the component with the provided interface
	// type. For example, given component interface Foo, GetIntf(Foo) returns a
	// value of type Foo.
	GetIntf(t reflect.Type) (any, error)

	// GetImpl returns the component implementation with the provided type. If
	// the component does not exist, it is created. For example, given
	// component interface Foo and implementing struct foo, GetImpl(foo)
	// returns an instance of type *foo.
	GetImpl(t reflect.Type) (any, error)
}

A Weavelet is an agent that hosts a set of components.

type WeaverInfo

type WeaverInfo struct {
	// Unique identifier for the application deployment.
	DeploymentID string
}

Copy of the same struct in the main xcweaver package.

Jump to

Keyboard shortcuts

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