Documentation
¶
Overview ¶
Package nodes provides lookup and watcher utilities for groups of nodes.
Index ¶
- type NodeDescriptorLookup
- type NodeFilterFunc
- type NodeUpdate
- type VersionEvent
- type VersionedNodeDescriptorWatcher
- func (nw *VersionedNodeDescriptorWatcher) BumpVersion(version int64)
- func (nw *VersionedNodeDescriptorWatcher) Freeze(version int64)
- func (nw *VersionedNodeDescriptorWatcher) GetNodes() []*node.Node
- func (nw *VersionedNodeDescriptorWatcher) Lookup(id signature.PublicKey) *node.Node
- func (nw *VersionedNodeDescriptorWatcher) LookupByPeerID(id signature.PublicKey) *node.Node
- func (nw *VersionedNodeDescriptorWatcher) LookupTags(id signature.PublicKey) []string
- func (nw *VersionedNodeDescriptorWatcher) Reset()
- func (nw *VersionedNodeDescriptorWatcher) Serve(ctx context.Context) error
- func (nw *VersionedNodeDescriptorWatcher) Versioned() bool
- func (nw *VersionedNodeDescriptorWatcher) WatchNode(ctx context.Context, id signature.PublicKey) (*node.Node, error)
- func (nw *VersionedNodeDescriptorWatcher) WatchNodeUpdates() (<-chan *NodeUpdate, pubsub.ClosableSubscription, error)
- func (nw *VersionedNodeDescriptorWatcher) WatchNodeWithTag(ctx context.Context, id signature.PublicKey, tag string) (*node.Node, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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
// GetNodes returns current list of nodes.
GetNodes() []*node.Node
// WatchNodeUpdates subscribes to notifications about node descriptor updates.
//
// For non-Versioned descriptor lookups there should be NO Versioned events.
// On subscription the current nodes will be sent immediately.
WatchNodeUpdates() (<-chan *NodeUpdate, pubsub.ClosableSubscription, error)
// Versioned returns true if this descriptor lookup is versioned.
//
// Versioned descriptor lookups are suitable to track versioned groups of nodes
// (e.g. committees versioned by the group number), while non-versioned lookups
// are suitable for watching non-versioned groups of nodes (e.g. all nodes,
// or all nodes registered for a specific runtime).
Versioned() bool
}
NodeDescriptorLookup is the node descriptor lookup interface.
func NewFilteredNodeLookup ¶
func NewFilteredNodeLookup(nl NodeDescriptorLookup, f NodeFilterFunc) NodeDescriptorLookup
NewFilteredNodeLookup creates a NodeDescriptorLookup with a node filter function applied.
type NodeFilterFunc ¶
NodeFilterFunc is a function that performs node filtering.
func IgnoreNodeFilter ¶
func IgnoreNodeFilter(id signature.PublicKey) NodeFilterFunc
IgnoreNodeFilter returns a node filter function that filters out the node with the provided id.
func TagFilter ¶
func TagFilter(tag string) NodeFilterFunc
TagFilter returns a node filter function that only includes nodes with the given tag.
func WithAllFilters ¶
func WithAllFilters(filters ...NodeFilterFunc) NodeFilterFunc
WithAllFilters combines multiple filters into a single NodeFilterFunc that only includes nodes passing all of the provided filters.
type NodeUpdate ¶
type NodeUpdate struct {
Update *node.Node
Delete *signature.PublicKey
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 VersionedNodeDescriptorWatcher ¶
type VersionedNodeDescriptorWatcher struct {
sync.RWMutex
// contains filtered or unexported fields
}
VersionedNodeDescriptorWatcher is the versioned node descriptor watcher.
func NewVersionedNodeDescriptorWatcher ¶
func NewVersionedNodeDescriptorWatcher(consensus consensus.Service) *VersionedNodeDescriptorWatcher
NewVersionedNodeDescriptorWatcher creates a new base versioned node descriptor watcher.
This watcher will only track nodes that will be explicitly marked to watch via WatchNode/WatchNodeWithTags methods.
func (*VersionedNodeDescriptorWatcher) BumpVersion ¶
func (nw *VersionedNodeDescriptorWatcher) BumpVersion(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.
func (*VersionedNodeDescriptorWatcher) Freeze ¶
func (nw *VersionedNodeDescriptorWatcher) Freeze(version int64)
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.
func (*VersionedNodeDescriptorWatcher) GetNodes ¶ added in v0.2603.0
func (nw *VersionedNodeDescriptorWatcher) GetNodes() []*node.Node
func (*VersionedNodeDescriptorWatcher) Lookup ¶ added in v0.2603.0
func (nw *VersionedNodeDescriptorWatcher) Lookup(id signature.PublicKey) *node.Node
func (*VersionedNodeDescriptorWatcher) LookupByPeerID ¶ added in v0.2603.0
func (nw *VersionedNodeDescriptorWatcher) LookupByPeerID(id signature.PublicKey) *node.Node
func (*VersionedNodeDescriptorWatcher) LookupTags ¶ added in v0.2603.0
func (nw *VersionedNodeDescriptorWatcher) LookupTags(id signature.PublicKey) []string
func (*VersionedNodeDescriptorWatcher) Reset ¶
func (nw *VersionedNodeDescriptorWatcher) Reset()
Reset clears the watcher so it doesn't watch any nodes.
func (*VersionedNodeDescriptorWatcher) Serve ¶ added in v0.2603.0
func (nw *VersionedNodeDescriptorWatcher) Serve(ctx context.Context) error
Serve starts the watcher.
func (*VersionedNodeDescriptorWatcher) Versioned ¶ added in v0.2603.0
func (nw *VersionedNodeDescriptorWatcher) Versioned() bool
func (*VersionedNodeDescriptorWatcher) WatchNode ¶
func (nw *VersionedNodeDescriptorWatcher) WatchNode(ctx context.Context, id signature.PublicKey) (*node.Node, error)
WatchNode starts watching a given node.
It returns the latest version of the node descriptor.
func (*VersionedNodeDescriptorWatcher) WatchNodeUpdates ¶ added in v0.2603.0
func (nw *VersionedNodeDescriptorWatcher) WatchNodeUpdates() (<-chan *NodeUpdate, pubsub.ClosableSubscription, error)
func (*VersionedNodeDescriptorWatcher) WatchNodeWithTag ¶
func (nw *VersionedNodeDescriptorWatcher) WatchNodeWithTag(ctx context.Context, id signature.PublicKey, tag string) (*node.Node, error)
WatchNodeWithTag starts watching a given node, tagging it with a specific tag.
It returns the latest version of the node descriptor.