events

package
v0.3.25 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClusterEventsChannel         = "cluster.events"
	KindNodeJoinEvent            = "node-join-event"
	KindNodeLeftEvent            = "node-left-event"
	KindFragmentMigrationEvent   = "fragment-migration-event"
	KindFragmentReceivedEvent    = "fragment-received-event"
	KindRebalanceStartEvent      = "rebalance-start-event"
	KindRebalanceCompleteEvent   = "rebalance-complete-event"
	KindInitialSyncCompleteEvent = "initial-sync-complete-event"
	KindMembershipChangeEvent    = "membership-change-event"

	// MembershipChangeJoin, MembershipChangeLeft and MembershipChangeUpdate
	// are the values of MembershipChangeEvent.Change.
	MembershipChangeJoin   = "join"
	MembershipChangeLeft   = "left"
	MembershipChangeUpdate = "update"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event interface {
	Encode() (string, error)
}

type FragmentMigrationEvent

type FragmentMigrationEvent struct {
	Kind          string `json:"kind"`
	Source        string `json:"source"`
	Target        string `json:"target"`
	Identifier    string `json:"identifier"`
	PartitionID   uint64 `json:"partition_id"`
	DataStructure string `json:"data_structure"`
	Length        int    `json:"length"`
	IsBackup      bool   `json:"is_backup"`
	Timestamp     int64  `json:"timestamp"`
}

func (*FragmentMigrationEvent) Encode

func (f *FragmentMigrationEvent) Encode() (string, error)

type FragmentReceivedEvent

type FragmentReceivedEvent struct {
	Kind          string `json:"kind"`
	Source        string `json:"source"`
	Identifier    string `json:"identifier"`
	PartitionID   uint64 `json:"partition_id"`
	DataStructure string `json:"data_structure"`
	Length        int    `json:"length"`
	IsBackup      bool   `json:"is_backup"`
	Timestamp     int64  `json:"timestamp"`
}

func (*FragmentReceivedEvent) Encode

func (f *FragmentReceivedEvent) Encode() (string, error)

type InitialSyncCompleteEvent added in v0.3.8

type InitialSyncCompleteEvent struct {
	Kind      string `json:"kind"`
	Source    string `json:"source"`
	Timestamp int64  `json:"timestamp"`
}

InitialSyncCompleteEvent is emitted when the local node has received initial data for all partitions it is responsible for. Use this to signal Kubernetes that the Pod is ready (e.g. in a readiness probe).

func (*InitialSyncCompleteEvent) Encode added in v0.3.8

func (i *InitialSyncCompleteEvent) Encode() (string, error)

type MembershipChangeEvent added in v0.3.20

type MembershipChangeEvent struct {
	Kind       string   `json:"kind"`
	Source     string   `json:"source"`
	Change     string   `json:"change"`
	Node       string   `json:"node"`
	NodeMeta   string   `json:"node_meta"`
	Members    []string `json:"members"`
	Generation uint64   `json:"generation"`
	Timestamp  int64    `json:"timestamp"`
}

MembershipChangeEvent is the coordinator's announcement of a membership change: one event per member that joined, left or was updated, published before the routing table is recomputed for it, whether or not that recomputation changes the table or is allowed by the member-count quorum. Members lists, sorted, the addresses of the members after the change, and Generation is the coordinator's install generation when it observed the change; every epoch it starts for a table that reflects the change carries a higher one. It is the authoritative membership signal of the cluster, while NodeJoinEvent and NodeLeftEvent are each member's own observations, which reach that member's subscribers only.

func (*MembershipChangeEvent) Encode added in v0.3.20

func (x *MembershipChangeEvent) Encode() (string, error)

Encode serializes the event as JSON for publication on the cluster events channel.

type NodeJoinEvent

type NodeJoinEvent struct {
	Kind     string `json:"kind"`
	Source   string `json:"source"`
	NodeJoin string `json:"node_join"`
	NodeMeta string `json:"node_meta"`
	// Generation is the install generation of the routing table the publisher
	// held when it observed the join (see RoutingTable.Generation). On the
	// coordinator, every rebalance epoch started for a table that reflects
	// the join carries a higher generation than this value; if the join
	// leaves the table unchanged no epoch starts. Generations are comparable
	// only between events of the same Source.
	Generation uint64 `json:"generation"`
	Timestamp  int64  `json:"timestamp"`
}

NodeJoinEvent announces a member that joined the cluster. Every member publishes it for the joins it observes, so a subscriber receives one per publisher; Source tells them apart.

func (*NodeJoinEvent) Encode

func (n *NodeJoinEvent) Encode() (string, error)

type NodeLeftEvent

type NodeLeftEvent struct {
	Kind     string `json:"kind"`
	Source   string `json:"source"`
	NodeLeft string `json:"node_left"`
	NodeMeta string `json:"node_meta"`
	// Generation is the install generation of the routing table the publisher
	// held when it observed the departure (see RoutingTable.Generation). On
	// the coordinator, every rebalance epoch started for a table that reflects
	// the departure carries a higher generation than this value; if the
	// departure leaves the table unchanged no epoch starts. Generations are
	// comparable only between events of the same Source.
	Generation uint64 `json:"generation"`
	Timestamp  int64  `json:"timestamp"`
}

NodeLeftEvent announces a member that left the cluster. Every member publishes it for the departures it observes, so a subscriber receives one per publisher; Source tells them apart.

func (*NodeLeftEvent) Encode

func (n *NodeLeftEvent) Encode() (string, error)

type RebalanceCompleteEvent added in v0.3.4

type RebalanceCompleteEvent struct {
	Kind       string   `json:"kind"`
	Source     string   `json:"source"`
	Epoch      uint64   `json:"epoch"`
	Generation uint64   `json:"generation"`
	Members    []string `json:"members"`
	Timestamp  int64    `json:"timestamp"`
}

RebalanceCompleteEvent marks the completion of a rebalance epoch. It is emitted by the cluster coordinator after all live members have acknowledged that no further fragment moves are required for the epoch.

Field usage:

  • Kind: event type identifier, always KindRebalanceCompleteEvent.
  • Source: coordinator address that emitted the event.
  • Epoch: routing table signature for the completed rebalance cycle. Match against RebalanceStartEvent.Epoch together with Generation, because the content-derived signature recurs when the table returns to an earlier state.
  • Generation: install generation of the table this epoch converged on (see RoutingTable.Generation). It identifies the epoch even when Epoch recurs and is comparable only between events of the same Source.
  • Members: sorted addresses of the members the coordinator knew when it computed the converged table, so a subscriber can tell which joins and departures the table reflects.
  • Timestamp: coordinator wall-clock time in nanoseconds since epoch.

Application guidance: treat this as the point when rebalancing is complete for the given epoch. If a newer rebalance-start arrives before completion, the previous epoch should be considered superseded.

func (*RebalanceCompleteEvent) Encode added in v0.3.4

func (r *RebalanceCompleteEvent) Encode() (string, error)

type RebalanceStartEvent added in v0.3.4

type RebalanceStartEvent struct {
	Kind       string `json:"kind"`
	Source     string `json:"source"`
	Epoch      uint64 `json:"epoch"`
	Generation uint64 `json:"generation"`
	Reason     string `json:"reason"`
	Node       string `json:"node"`
	Timestamp  int64  `json:"timestamp"`
}

RebalanceStartEvent marks the beginning of a rebalance epoch in the cluster. It is emitted by the cluster coordinator after publishing a new routing table and before data movement completes.

Field usage:

  • Kind: event type identifier, always KindRebalanceStartEvent.
  • Source: coordinator address that emitted the event.
  • Epoch: routing table signature for this rebalance cycle. Correlate this with RebalanceCompleteEvent.Epoch to know when the cycle finishes. The signature is derived from the table content, so it recurs when the table returns to an earlier state; use Generation to tell such epochs apart.
  • Generation: install generation of the table the coordinator pushed for this epoch (see RoutingTable.Generation). It never recurs on a given coordinator and is comparable only between events of the same Source.
  • Reason: why the rebalance started (e.g., "node-join", "node-left", "node-update", "periodic", "manual").
  • Node: the node associated with the trigger, if any (for example the joined or left node). May be empty for periodic/manual updates.
  • Timestamp: coordinator wall-clock time in nanoseconds since epoch, taken before the epoch could complete, so a completion never carries an earlier timestamp than its start even when it is delivered first.

Application guidance: treat this as the start of data convergence for the routing table epoch. Do not use node-left events as completion signals; instead, wait for a matching RebalanceCompleteEvent with the same Epoch and Generation.

func (*RebalanceStartEvent) Encode added in v0.3.4

func (r *RebalanceStartEvent) Encode() (string, error)

Jump to

Keyboard shortcuts

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