Documentation
¶
Index ¶
- type Drainer
- type Node
- func (n *Node) AddSDK(sdk SDK)
- func (n *Node) Config() (driver.ConfigService, error)
- func (n *Node) GetService(v any) (any, error)
- func (n *Node) ID() string
- func (n *Node) InstallSDK(p SDK) error
- func (n *Node) Migrate(ctx context.Context, checkOnly bool) error
- func (n *Node) RegisterService(service any) error
- func (n *Node) Start() (err error)
- func (n *Node) Stop()
- type PostStart
- type SDK
- type StoreOpener
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Drainer ¶ added in v0.28.0
Drainer is a service, registered in the node's registry, that lets running work finish before the node stops; the view SDK registers the view manager. Node.Stop calls Drain on the first Drainer the registry returns before it cancels the node context. Drain makes the node refuse new work and returns once running work has finished. When ctx is done first, it returns promptly, even if some work ignores cancellation.
type Node ¶ added in v0.4.1
type Node struct {
// contains filtered or unexported fields
}
Node is a struct that allows the developer to compose sequentially multiple SDKs. The struct offers also a service locator that the SDKs can use to register services.
func NewFromConfPath ¶
NewFromConfPath returns a new node for the given configuration path. If no configuration file is found, the node is built on an empty configuration and Start, Migrate and Config return that error, so commands that need no configuration, such as `version`, still run. It panics on any other configuration error.
func NewFromConfPathE ¶ added in v0.12.0
NewFromConfPathE returns a new node for the given configuration path or an error.
func (*Node) Config ¶ added in v0.28.0
func (n *Node) Config() (driver.ConfigService, error)
Config returns the node's configuration, or the error that loading it failed with.
func (*Node) InstallSDK ¶ added in v0.4.1
func (*Node) Migrate ¶ added in v0.28.0
Migrate installs every SDK without starting it, so no server, P2P or delivery starts, and opens every store through the StoreOpener in the registry. With checkOnly it runs no schema step and fails if a store has steps pending; otherwise it runs the pending steps. Installing loads the node's identities, so Migrate needs the same configuration and key material as a running node. Stores opened only after Start, such as a channel's vault added at runtime, are not reached.
Installing builds services that open stores, so with checkOnly a store with pending steps can fail Install. Migrate then still calls the StoreOpener if one was registered, so every store is reported, and joins both errors. Without checkOnly a failed Install ends Migrate, so no step runs on a node that cannot install.
func (*Node) RegisterService ¶ added in v0.4.1
func (*Node) Stop ¶ added in v0.4.1
func (n *Node) Stop()
Stop shuts the node down and returns once it has stopped:
- it drains: the Drainer in the registry refuses new work and waits for running views, for at most fsc.shutdown.drainTimeout;
- it cancels the node context passed to Start;
- it calls Stop on every SDK that has a Stop() error method, in reverse install order, for at most fsc.shutdown.teardownTimeout in total. SDKs still stopping at the timeout are logged and left running.
A call while a shutdown runs skips the rest of its drain and waits for it to finish. Stop is safe to call on a node that was never started or failed to start.
type PostStart ¶
PostStart enables a platform to execute additional tasks after all platforms have started
type SDK ¶ added in v0.4.1
type SDK interface {
// Install signals the SDK that it is time to install itself.
Install() error
// Start signals the SDK that it is time to start any computation/server this SDK offers.
Start(ctx context.Context) error
}
SDK models an abstract kit that can be installed and started.
type StoreOpener ¶ added in v0.28.0
StoreOpener opens every store an SDK uses, so that opening them prepares their schema. The view SDK registers one in the node's registry that calls every entry of the dig value group "fsc-store-openers"; an SDK provides an entry with a dig.Out struct whose field has the tag `group:"fsc-store-openers"`. OpenStores returns the first store that fails to open.