node

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 11 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Drainer added in v0.28.0

type Drainer interface {
	Drain(ctx context.Context) error
}

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

func NewFromConfPath(confPath string) *Node

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

func NewFromConfPathE(confPath string) (*Node, error)

NewFromConfPathE returns a new node for the given configuration path or an error.

func (*Node) AddSDK added in v0.4.1

func (n *Node) AddSDK(sdk SDK)

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) GetService added in v0.4.1

func (n *Node) GetService(v any) (any, error)

func (*Node) ID added in v0.4.1

func (n *Node) ID() string

func (*Node) InstallSDK added in v0.4.1

func (n *Node) InstallSDK(p SDK) error

func (*Node) Migrate added in v0.28.0

func (n *Node) Migrate(ctx context.Context, checkOnly bool) error

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 (n *Node) RegisterService(service any) error

func (*Node) Start added in v0.4.1

func (n *Node) Start() (err error)

func (*Node) Stop added in v0.4.1

func (n *Node) Stop()

Stop shuts the node down and returns once it has stopped:

  1. it drains: the Drainer in the registry refuses new work and waits for running views, for at most fsc.shutdown.drainTimeout;
  2. it cancels the node context passed to Start;
  3. 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

type PostStart interface {
	PostStart(context.Context) error
}

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

type StoreOpener interface {
	OpenStores(ctx context.Context) error
}

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.

Jump to

Keyboard shortcuts

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