weaver

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: Apache-2.0 Imports: 48 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

	// 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

	// 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
)

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.

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) 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 the conn.WeaveletHandler interface.

func (*RemoteWeavelet) Info

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

Info returns the EnvelopeInfo received from the envelope.

func (*RemoteWeavelet) UpdateComponents

UpdateComponents implements the conn.WeaverHandler interface.

func (*RemoteWeavelet) UpdateRoutingInfo

func (w *RemoteWeavelet) UpdateRoutingInfo(req *protos.UpdateRoutingInfoRequest) (reply *protos.UpdateRoutingInfoReply, err error)

UpdateRoutingInfo implements the conn.WeaverHandler interface.

type RemoteWeaveletOptions

type RemoteWeaveletOptions struct {
	Fakes map[reflect.Type]any // component fakes, by component interface type
}

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.

Jump to

Keyboard shortcuts

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