[FEATURE] cluster package #353

Open
opened 2024-10-30 00:58:11 +03:00 by vtolstov · 1 comment
Owner


// Message sent to member in cluster
type Message interface {
	// Header returns message headers
	Header() metadata.Metadata
	// Body returns broker message may be []byte slice or some go struct or interface
	Body() interface{}
}

type Node interface {
	// Name returns node name
	Name() string
	// Address returns node address
	Address() string
	// Metadata returns node metadata
	Metadata() metadata.Metadata
}

// Cluster interface used for cluster communication across nodes
type Cluster interface {
	// Join is used to take an existing members and performing state sync
	Join(ctx context.Context, addr ...string) error
	// Leave broadcast a leave message and stop listeners
	Leave(ctx context.Context) error
	// Ping is used to probe live status of the node
	Ping(ctx context.Context, node Node, payload []byte) error
	// Members returns the cluster members
	Members() ([]Node, error)
	// Broadcast send message for all members in cluster, if filter is not nil, nodes may be filtered
	// by key/value pairs
	Broadcast(ctx context.Context, msg Message, filter ...string) error
	// Unicast send message to single member in cluster
	Unicast(ctx context.Context, node Node, msg Message) error
}


```go // Message sent to member in cluster type Message interface { // Header returns message headers Header() metadata.Metadata // Body returns broker message may be []byte slice or some go struct or interface Body() interface{} } type Node interface { // Name returns node name Name() string // Address returns node address Address() string // Metadata returns node metadata Metadata() metadata.Metadata } // Cluster interface used for cluster communication across nodes type Cluster interface { // Join is used to take an existing members and performing state sync Join(ctx context.Context, addr ...string) error // Leave broadcast a leave message and stop listeners Leave(ctx context.Context) error // Ping is used to probe live status of the node Ping(ctx context.Context, node Node, payload []byte) error // Members returns the cluster members Members() ([]Node, error) // Broadcast send message for all members in cluster, if filter is not nil, nodes may be filtered // by key/value pairs Broadcast(ctx context.Context, msg Message, filter ...string) error // Unicast send message to single member in cluster Unicast(ctx context.Context, node Node, msg Message) error } ```
Author
Owner

добавить редис вариант
в методы кластера надо добавить Watch(context.Context) (Event, error)
Event содрать с memberlist пакета может, тип ивента Join/Leave/Update/Alive/Conflict/Ping
type Event interface {
Type() EvenType
Node() Node
Metadata() metadata.Metadata
Body() interface{}
}

добавить редис вариант в методы кластера надо добавить Watch(context.Context) (Event, error) Event содрать с memberlist пакета может, тип ивента Join/Leave/Update/Alive/Conflict/Ping type Event interface { Type() EvenType Node() Node Metadata() metadata.Metadata Body() interface{} }
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: unistack-org/micro#353
No description provided.