committee

package
v0.2011.3 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2020 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// GetConnections returns the set of connections to active committee nodes.
	GetConnections() []*grpc.ClientConn

	// GetConnectionsWith returns the set of connections to active committee nodes including node
	// metadata for each connection.
	GetConnectionsWithMeta() []*ClientConnWithMeta

	// GetConnection returns a connection based on the configured node selection policy.
	//
	// If no connections are available this method will return nil.
	GetConnection() *grpc.ClientConn

	// UpdateNodeSelectionPolicy submits feedback to the policy which can cause the policy to update
	// its current node selection.
	UpdateNodeSelectionPolicy(feedback NodeSelectionFeedback)

	// EnsureVersion waits for the committee client to be fully synced to the given version.
	EnsureVersion(ctx context.Context, version int64) error

	// Initialized returns a channel that will be closed once the first connection is available.
	Initialized() <-chan struct{}
}

Client is a committee gRPC client interface. It automatically maintains gRPC connections to all nodes as directed by the committee watcher.

func NewClient

func NewClient(ctx context.Context, nw NodeDescriptorLookup, options ...ClientOption) (Client, error)

NewClient creates a new committee client.

type ClientConnWithMeta

type ClientConnWithMeta struct {
	*grpc.ClientConn

	Node *node.Node
}

ClientConnWithMeta is a gRPC client connection together with node metadata.

type ClientOption

type ClientOption func(cc *committeeClient)

ClientOption is an option for NewClient.

func WithClientAuthentication

func WithClientAuthentication(identity *identity.Identity) ClientOption

WithClientAuthentication is an option for configuring client authentication on TLS connections.

func WithCloseDelay

func WithCloseDelay(delay time.Duration) ClientOption

WithCloseDelay is an option for configuring the connection close delay after rotating a connection.

If not configured it defaults to 5 seconds.

func WithNodeSelectionPolicy

func WithNodeSelectionPolicy(policy NodeSelectionPolicy) ClientOption

WithNodeSelectionPolicy is an option for configuring the node selection policy.

If not configured it defaults to the round-robin policy.

type Filter

type Filter func(*scheduler.CommitteeNode) bool

Filter is filter function for the committee watcher. It should return false for any members which should be excluded.

func IgnoreNodeFilter added in v0.2010.0

func IgnoreNodeFilter(pk signature.PublicKey) Filter

IgnoreNodeFilter is a committee watcher filter that filters out nodes based on their public key.

type NodeDescriptorLookup

type NodeDescriptorLookup interface {
	// Lookup looks up a node descriptor given its identifier.
	Lookup(id signature.PublicKey) *node.Node

	// LookupByPeerID looks up a node descriptor given its P2P peer ID.
	LookupByPeerID(id signature.PublicKey) *node.Node

	// LookupTags looks up tags for a given node.
	LookupTags(id signature.PublicKey) []string

	// WatchNodeUpdates subscribes to notifications about node descriptor updates.
	//
	// On subscription the current nodes will be sent immediately.
	WatchNodeUpdates() (<-chan *NodeUpdate, pubsub.ClosableSubscription, error)
}

NodeDescriptorLookup is the node descriptor lookup interface.

func NewFilteredNodeLookup added in v0.2010.0

func NewFilteredNodeLookup(nl NodeDescriptorLookup, f NodeFilterFunc) NodeDescriptorLookup

NewFilteredNodeLookup creates a NodeDescriptorLookup with a node filter function applied.

type NodeDescriptorWatcher

type NodeDescriptorWatcher interface {
	NodeDescriptorLookup

	// Reset clears the watcher so it doesn't watch any nodes.
	Reset()

	// Freeze freezes the node descriptor watcher so no new nodes can be watched.
	//
	// In order to watch new nodes, the caller must first call Reset. Calling this method on an
	// already frozen watcher may result in a panic.
	//
	// The version argument may be used to signal which committee version this is.
	Freeze(version int64)

	// BumpVersion updates the committee version without performing a reset.
	//
	// This method may be used when the new committee version is exactly the same as the old one
	// without introducing a needless reset.
	//
	// The watcher must have previously been frozen. Calling this method on an unfrozen watcher may
	// result in a panic.
	BumpVersion(version int64)

	// WatchNode starts watching a given node.
	//
	// It returns the latest version of the node descriptor.
	WatchNode(ctx context.Context, id signature.PublicKey) (*node.Node, error)

	// WatchNodeWithTag starts watching a given node, tagging it with a specific tag.
	//
	// It returns the latest version of the node descriptor.
	WatchNodeWithTag(ctx context.Context, id signature.PublicKey, tag string) (*node.Node, error)
}

NodeDescriptorWatcher is the node descriptor watcher interface.

func NewNodeDescriptorWatcher

func NewNodeDescriptorWatcher(ctx context.Context, registry registry.Backend) (NodeDescriptorWatcher, error)

NewNodeDescriptorWatcher creates a new node descriptor watcher.

type NodeFilterFunc added in v0.2010.0

type NodeFilterFunc func(*node.Node, []string) bool

NodeFilterFunc is a function that performs node filtering.

func TagFilter added in v0.2010.0

func TagFilter(tag string) NodeFilterFunc

TagFilter returns a node filter function that only includes nodes with the given tag.

type NodeSelectionFeedback

type NodeSelectionFeedback struct {
	// ID is the node identifier.
	ID signature.PublicKey

	// Bad being non-nil signals that the currently selected node is bad and contains the reason
	// that lead to the decision.
	Bad error
}

NodeSelectionFeedback is feedback to the node selection policy.

type NodeSelectionPolicy

type NodeSelectionPolicy interface {
	// UpdateNodes updates the set of available nodes.
	UpdateNodes([]signature.PublicKey)

	// UpdatePolicy submits feedback to the policy which can cause the policy to update its current
	// node selection.
	UpdatePolicy(feedback NodeSelectionFeedback)

	// Pick picks a node from the set of available nodes accoording to the policy.
	Pick() signature.PublicKey
}

NodeSelectionPolicy is a node selection policy.

func NewRoundRobinNodeSelectionPolicy

func NewRoundRobinNodeSelectionPolicy() NodeSelectionPolicy

NewRoundRobinNodeSelectionPolicy creates a new round-robin node selection policy.

type NodeUpdate

type NodeUpdate struct {
	Update      *node.Node
	Reset       bool
	Freeze      *VersionEvent
	BumpVersion *VersionEvent
}

NodeUpdate is a node update.

type VersionEvent

type VersionEvent struct {
	Version int64
}

VersionEvent is a committee version event.

type Watcher

type Watcher interface {
	// Nodes returns a node descriptor lookup interface that watches all nodes in the committee.
	Nodes() NodeDescriptorLookup

	// EpochTransition signals an epoch transition to the committee watcher.
	EpochTransition(ctx context.Context, height int64) error
}

Watcher is the committee watcher interface.

func NewWatcher

func NewWatcher(
	ctx context.Context,
	scheduler scheduler.Backend,
	registry registry.Backend,
	runtimeID common.Namespace,
	kind scheduler.CommitteeKind,
	options ...WatcherOption,
) (Watcher, error)

NewWatcher creates a new committee watcher.

type WatcherOption

type WatcherOption func(cw *committeeWatcher)

WatcherOption is an option for NewWatcher.

func WithAutomaticEpochTransitions

func WithAutomaticEpochTransitions() WatcherOption

WithAutomaticEpochTransitions is an option for enabling automatic epoch transitions in the committee watcher. Committees will be updated whenever the scheduler elects new committees.

func WithFilter

func WithFilter(f Filter) WatcherOption

WithFilter is an option that adds a given filter to the committee watcher.

Jump to

Keyboard shortcuts

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