1package memberlist
2
3// Delegate is the interface that clients must implement if they want to hook
4// into the gossip layer of Memberlist. All the methods must be thread-safe,
5// as they can and generally will be called concurrently.
6type Delegate interface {
7	// NodeMeta is used to retrieve meta-data about the current node
8	// when broadcasting an alive message. It's length is limited to
9	// the given byte size. This metadata is available in the Node structure.
10	NodeMeta(limit int) []byte
11
12	// NotifyMsg is called when a user-data message is received.
13	// Care should be taken that this method does not block, since doing
14	// so would block the entire UDP packet receive loop. Additionally, the byte
15	// slice may be modified after the call returns, so it should be copied if needed.
16	NotifyMsg([]byte)
17
18	// GetBroadcasts is called when user data messages can be broadcast.
19	// It can return a list of buffers to send. Each buffer should assume an
20	// overhead as provided with a limit on the total byte size allowed.
21	// The total byte size of the resulting data to send must not exceed
22	// the limit. Care should be taken that this method does not block,
23	// since doing so would block the entire UDP packet receive loop.
24	GetBroadcasts(overhead, limit int) [][]byte
25
26	// LocalState is used for a TCP Push/Pull. This is sent to
27	// the remote side in addition to the membership information. Any
28	// data can be sent here. See MergeRemoteState as well. The `join`
29	// boolean indicates this is for a join instead of a push/pull.
30	LocalState(join bool) []byte
31
32	// MergeRemoteState is invoked after a TCP Push/Pull. This is the
33	// state received from the remote side and is the result of the
34	// remote side's LocalState call. The 'join'
35	// boolean indicates this is for a join instead of a push/pull.
36	MergeRemoteState(buf []byte, join bool)
37}
38