discovery

package
v0.0.0-...-be15534 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EventTypeAdd indicates that a node has been added.
	EventTypeAdd = EventType("add")

	// EventTypeDel indicates that a node has been removed.
	EventTypeDel = EventType("del")
)
View Source
const (
	// NodeTypeMaster indicates that the node is a master.
	NodeTypeMaster = NodeType("master")
	// NodeTypeExecutor indicates that the node is an executor.
	NodeTypeExecutor = NodeType("executor")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent interface {
	Run(ctx context.Context) error
	Subscribe(ctx context.Context) (Snapshot, *notifier.Receiver[Event], error)
}

Agent registers receives membership changes of all nodes.

func NewAgent

func NewAgent(
	discoveryClient client.DiscoveryClient,
	autoSyncInterval time.Duration,
) Agent

NewAgent creates a new Agent that receives membership changes from the discovery service. autoSyncInterval is the interval to update membership with the latest information and notify subscribers.

type Event

type Event struct {
	Tp   EventType
	Node Node
}

Event is a node membership change event.

type EventType

type EventType string

EventType describes the type of the event, i.e. Add or Del.

type Node

type Node struct {
	Tp   NodeType
	ID   string
	Addr string
}

Node describes the information of a node.

type NodeType

type NodeType string

NodeType describes the type of the node.

type Snapshot

type Snapshot map[string]Node

Snapshot is the current service membership snapshot.

Jump to

Keyboard shortcuts

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