registry

package
v0.2500.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2025 License: Apache-2.0 Imports: 60 Imported by: 1

Documentation

Overview

Package registry provides a registry of runtimes supported by the running oasis-node. It serves as a central point of runtime configuration.

Index

Constants

View Source
const (
	// MaxRuntimeCount is the maximum number of runtimes that can be supported
	// by a single node.
	MaxRuntimeCount = 64

	// LocalStorageFile is the filename of the worker's local storage database.
	LocalStorageFile = "worker-local-storage.badger.db"
)
View Source
const (
	// RuntimesDir is the name of the directory located inside the node's data
	// directory which contains the per-runtime state.
	RuntimesDir = "runtimes"
)

Variables

View Source
var ErrRuntimeHostNotConfigured = errors.New("runtime/registry: runtime host not configured")

ErrRuntimeHostNotConfigured is the error returned when the runtime host is not configured for a specified runtime and a request is made to get the runtime host provisioner.

Functions

func EnsureRuntimeStateDir

func EnsureRuntimeStateDir(dataDir string, runtimeID common.Namespace) (string, error)

EnsureRuntimeStateDir ensures a specific per-runtime directory exists and returns its full path.

func GetRuntimeStateDir added in v0.2100.0

func GetRuntimeStateDir(dataDir string, runtimeID common.Namespace) string

func NewRuntimeHostHandler added in v0.2103.0

func NewRuntimeHostHandler(
	env RuntimeHostHandlerEnvironment,
	runtime Runtime,
	consensus consensus.Backend,
) host.RuntimeHandler

NewRuntimeHostHandler returns a protocol handler that provides the required host methods for the runtime to interact with the outside world.

The passed identity may be nil.

func NewRuntimeHostNotifier added in v0.2103.0

func NewRuntimeHostNotifier(runtime Runtime, hostRt host.Runtime, consensus consensus.Backend) protocol.Notifier

NewRuntimeHostNotifier returns a protocol notifier that handles key manager policy updates.

func ParseRuntimeMap

func ParseRuntimeMap(rawItems []string) (map[common.Namespace]string, error)

ParseRuntimeMap parses strings in the format of <runtime-id>[:<value>] and returns them as a map of runtime IDs to value.

Types

type Registry

type Registry interface {
	service.BackgroundService

	// GetRuntime returns the per-runtime interface.
	GetRuntime(runtimeID common.Namespace) (Runtime, error)

	// Runtimes returns a list of all runtimes.
	Runtimes() []Runtime

	// NewRuntime creates a new runtime that may or may not be managed
	// by this registry.
	NewRuntime(ctx context.Context, runtimeID common.Namespace, managed bool) (Runtime, error)

	// RegisterClient registers a runtime client service. If the service has already been registered
	// this method returns an error.
	RegisterClient(rc runtimeClient.RuntimeClient) error

	// Client returns the runtime client service if available.
	Client() (runtimeClient.RuntimeClient, error)

	// FinishInitialization finalizes setup for all runtimes.
	FinishInitialization() error

	// GetBundleRegistry returns the bundle registry.
	GetBundleRegistry() *bundle.Registry

	// GetBundleManager returns the bundle manager.
	GetBundleManager() *bundle.Manager
}

Registry is the running node's runtime registry interface.

func New

func New(
	ctx context.Context,
	dataDir string,
	commonStore *persistent.CommonStore,
	identity *identity.Identity,
	consensus consensus.Backend,
	ias []ias.Endpoint,
) (Registry, error)

New creates a new runtime registry.

type Runtime

type Runtime interface {
	// ID is the runtime identifier.
	ID() common.Namespace

	// DataDir returns the runtime-specific data directory.
	DataDir() string

	// IsManaged returns true iff the runtime is managed by the registry.
	IsManaged() bool

	// RegistryDescriptor waits for the runtime to be registered and
	// then returns its registry descriptor.
	RegistryDescriptor(ctx context.Context) (*registry.Runtime, error)

	// WatchRegistryDescriptor subscribes to registry descriptor updates.
	WatchRegistryDescriptor() (<-chan *registry.Runtime, pubsub.ClosableSubscription, error)

	// ActiveDescriptor waits for runtime to be initialized and then returns
	// currently active runtime descriptor.
	ActiveDescriptor(ctx context.Context) (*registry.Runtime, error)

	// WatchActiveDescriptor subscribes to runtime active descriptor updates.
	WatchActiveDescriptor() (<-chan *registry.Runtime, pubsub.ClosableSubscription, error)

	// RegisterStorage sets the given local storage backend for the runtime.
	RegisterStorage(storage storageAPI.Backend)

	// History returns the history for this runtime.
	History() history.History

	// Storage returns the per-runtime storage backend.
	Storage() storageAPI.Backend

	// LocalStorage returns the per-runtime local storage.
	LocalStorage() localstorage.LocalStorage

	// HostProvisioner returns the runtime host provisioner when available. Otherwise returns nil.
	HostProvisioner() runtimeHost.Provisioner
}

Runtime is the running node's supported runtime interface.

type RuntimeHostHandlerEnvironment added in v0.2103.0

type RuntimeHostHandlerEnvironment interface {
	// GetKeyManagerClient returns the key manager client for this runtime.
	GetKeyManagerClient() (runtimeKeymanager.Client, error)

	// GetTxPool returns the transaction pool for this runtime.
	GetTxPool() (txpool.TransactionPool, error)

	// GetNodeIdentity returns the identity of a node running this runtime.
	GetNodeIdentity() (*identity.Identity, error)

	// GetLightClient returns the consensus light client.
	GetLightClient() (consensus.LightClient, error)

	// GetRuntimeRegistry returns the runtime registry.
	GetRuntimeRegistry() Registry
}

RuntimeHostHandlerEnvironment is the host environment interface.

type RuntimeHostHandlerFactory added in v0.2100.0

type RuntimeHostHandlerFactory interface {
	// GetRuntime returns the registered runtime for which a runtime host handler is to be created.
	GetRuntime() Runtime

	// NewRuntimeHostHandler creates a new runtime host handler.
	NewRuntimeHostHandler() host.RuntimeHandler

	// NewRuntimeHostNotifier creates a new runtime host notifier.
	NewRuntimeHostNotifier(host host.Runtime) protocol.Notifier
}

RuntimeHostHandlerFactory is an interface that can be used to create new runtime handlers and notifiers when provisioning hosted runtimes.

type RuntimeHostNode added in v0.2100.0

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

RuntimeHostNode provides methods for nodes that need to host runtimes.

func NewRuntimeHostNode added in v0.2100.0

func NewRuntimeHostNode(factory RuntimeHostHandlerFactory) (*RuntimeHostNode, error)

NewRuntimeHostNode creates a new runtime host node.

func (*RuntimeHostNode) GetHostedRuntime added in v0.2100.0

func (n *RuntimeHostNode) GetHostedRuntime() host.RichRuntime

GetHostedRuntime returns the hosted runtime.

func (*RuntimeHostNode) GetHostedRuntimeActiveVersion added in v0.2400.0

func (n *RuntimeHostNode) GetHostedRuntimeActiveVersion() (*version.Version, error)

GetHostedRuntimeActiveVersion returns the version of the active runtime.

func (*RuntimeHostNode) GetHostedRuntimeCapabilityTEE added in v0.2300.0

func (n *RuntimeHostNode) GetHostedRuntimeCapabilityTEE() (*node.CapabilityTEE, error)

GetHostedRuntimeCapabilityTEE returns the CapabilityTEE for the active runtime version.

It may be nil in case the CapabilityTEE is not available or if the runtime is not running inside a TEE.

func (*RuntimeHostNode) GetHostedRuntimeCapabilityTEEForVersion added in v0.2400.0

func (n *RuntimeHostNode) GetHostedRuntimeCapabilityTEEForVersion(version version.Version) (*node.CapabilityTEE, error)

GetHostedRuntimeCapabilityTEEForVersion returns the CapabilityTEE for a specific runtime version.

It may be nil in case the CapabilityTEE is not available or if the runtime is not running inside a TEE.

func (*RuntimeHostNode) GetRuntimeHostNotifier added in v0.2500.0

func (n *RuntimeHostNode) GetRuntimeHostNotifier() protocol.Notifier

GetRuntimeHostNotifier returns the runtime host notifier.

func (*RuntimeHostNode) ProvisionHostedRuntimeComponent added in v0.2500.0

func (n *RuntimeHostNode) ProvisionHostedRuntimeComponent(comp *bundle.ExplodedComponent) error

ProvisionHostedRuntimeComponent provisions the given runtime component.

func (*RuntimeHostNode) SetHostedRuntimeVersion added in v0.2200.0

func (n *RuntimeHostNode) SetHostedRuntimeVersion(active *version.Version, next *version.Version)

SetHostedRuntimeVersion sets the currently active and next versions for the hosted runtime.

Jump to

Keyboard shortcuts

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