cluster

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LEAF_PING_INTERVAL = 2 * time.Second
	RECONNECT_DELAY    = 5 * time.Second
)
View Source
const (
	GroupFullSyncMsg gossip.MessageType = iota + gossip.UserMsg
	GroupGossipMsg
	RoleFullSyncMsg
	RoleGossipMsg
	SpaceFullSyncMsg
	SpaceGossipMsg
	TemplateFullSyncMsg
	TemplateGossipMsg
	TemplateVarFullSyncMsg
	TemplateVarGossipMsg
	UserFullSyncMsg
	UserGossipMsg
	TokenFullSyncMsg
	TokenGossipMsg
	SessionFullSyncMsg
	SessionGossipMsg
	VolumeFullSyncMsg
	VolumeGossipMsg
	AuditLogGossipMsg
	ScriptFullSyncMsg
	ScriptGossipMsg
	SkillFullSyncMsg
	SkillGossipMsg
	CommandFullSyncMsg
	CommandGossipMsg
	StackDefinitionFullSyncMsg
	StackDefinitionGossipMsg
	ResponseFullSyncMsg
	ResponseGossipMsg
	SpaceUsageFullSyncMsg
	SpaceUsageGossipMsg
	SpaceMigrationStartMsg
	PoolDefinitionFullSyncMsg
	PoolDefinitionGossipMsg
	PoolDrainMsg
	EventSinkFullSyncMsg
	EventSinkGossipMsg
	EventBroadcastMsg
	EventDoneMsg
	InFlightStateMsg
	ConversationFullSyncMsg
	ConversationGossipMsg
	MCPServerFullSyncMsg
	MCPServerGossipMsg
	AuthFailureGossipMsg
)
View Source
const (
	// ResourceLockTTL is how long a resource lock is held before it expires.
	// In cluster mode it is the TTL given to the distributed lock (generous,
	// so container operations that pull images comfortably fit inside it); in
	// single-process mode it bounds how long an abandoned local lock can wedge
	// its resource.
	ResourceLockTTL        = 5 * time.Minute
	ResourceLockGCInterval = 30 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	// contains filtered or unexported fields
}

func NewCluster

func NewCluster(
	clusterKey string,
	advertiseAddr string,
	bindAddr string,
	routes *http.ServeMux,
	compress bool,
	allowLeaf bool,
	tcpOnly bool,
) *Cluster

func (*Cluster) BroadcastEvent added in v0.28.0

func (c *Cluster) BroadcastEvent(envelope *service.EventEnvelope)

func (*Cluster) CalcLeafPayloadSize

func (c *Cluster) CalcLeafPayloadSize(totalNodes int) int

This is a duplicate of the gossip payload size calculation, however when gossip isn't running we still need this for sending to leaf nodes

func (*Cluster) DoCommandFullSync added in v0.29.0

func (c *Cluster) DoCommandFullSync(node *gossip.Node) error

func (*Cluster) DoConversationFullSync added in v0.29.0

func (c *Cluster) DoConversationFullSync(node *gossip.Node) error

func (*Cluster) DoEventSinkFullSync added in v0.28.0

func (c *Cluster) DoEventSinkFullSync(node *gossip.Node) error

func (*Cluster) DoGroupFullSync

func (c *Cluster) DoGroupFullSync(node *gossip.Node) error

func (*Cluster) DoMCPServerFullSync added in v0.29.0

func (c *Cluster) DoMCPServerFullSync(node *gossip.Node) error

func (*Cluster) DoPoolDefinitionFullSync added in v0.28.0

func (c *Cluster) DoPoolDefinitionFullSync(node *gossip.Node) error

func (*Cluster) DoResponseFullSync added in v0.23.0

func (c *Cluster) DoResponseFullSync(node *gossip.Node) error

func (*Cluster) DoRoleFullSync

func (c *Cluster) DoRoleFullSync(node *gossip.Node) error

func (*Cluster) DoScriptFullSync added in v0.23.0

func (c *Cluster) DoScriptFullSync(node *gossip.Node) error

func (*Cluster) DoSessionFullSync

func (c *Cluster) DoSessionFullSync(node *gossip.Node) error

func (*Cluster) DoSkillFullSync added in v0.23.0

func (c *Cluster) DoSkillFullSync(node *gossip.Node) error

func (*Cluster) DoSpaceFullSync

func (c *Cluster) DoSpaceFullSync(node *gossip.Node) error

func (*Cluster) DoSpaceUsageFullSync added in v0.24.0

func (c *Cluster) DoSpaceUsageFullSync(node *gossip.Node) error

func (*Cluster) DoStackDefinitionFullSync added in v0.24.0

func (c *Cluster) DoStackDefinitionFullSync(node *gossip.Node) error

func (*Cluster) DoTemplateFullSync

func (c *Cluster) DoTemplateFullSync(node *gossip.Node) error

func (*Cluster) DoTemplateVarFullSync

func (c *Cluster) DoTemplateVarFullSync(node *gossip.Node) error

func (*Cluster) DoTokenFullSync

func (c *Cluster) DoTokenFullSync(node *gossip.Node) error

func (*Cluster) DoUserFullSync

func (c *Cluster) DoUserFullSync(node *gossip.Node) error

func (*Cluster) DoVolumeFullSync

func (c *Cluster) DoVolumeFullSync(node *gossip.Node) error

func (*Cluster) EnqueueSpaceCleanup added in v0.25.0

func (c *Cluster) EnqueueSpaceCleanup(space *model.Space)

func (*Cluster) GetAgentEndpoints

func (c *Cluster) GetAgentEndpoints() []string

func (*Cluster) GetLocalNodeId added in v0.22.0

func (c *Cluster) GetLocalNodeId() (string, error)

func (*Cluster) GetNodeByIDString added in v0.22.0

func (c *Cluster) GetNodeByIDString(id string) *gossip.Node

func (*Cluster) GetTunnelServers

func (c *Cluster) GetTunnelServers() []string

func (*Cluster) GossipAuditLog

func (c *Cluster) GossipAuditLog(entry *model.AuditLogEntry)

func (*Cluster) GossipAuthFailure added in v0.33.0

func (c *Cluster) GossipAuthFailure(evt *authratelimit.Event)

func (*Cluster) GossipCommand added in v0.29.0

func (c *Cluster) GossipCommand(command *model.Command)

func (*Cluster) GossipConversation added in v0.29.0

func (c *Cluster) GossipConversation(conv *model.Conversation)

func (*Cluster) GossipEventSink added in v0.28.0

func (c *Cluster) GossipEventSink(sink *model.EventSink)

func (*Cluster) GossipGroup

func (c *Cluster) GossipGroup(group *model.Group)

func (*Cluster) GossipMCPServer added in v0.29.0

func (c *Cluster) GossipMCPServer(server *model.MCPServer)

func (*Cluster) GossipPoolDefinition added in v0.28.0

func (c *Cluster) GossipPoolDefinition(pool *model.PoolDefinition)

GossipPoolDefinition fans a pool definition change out to the cluster and notifies local SSE clients. It is the single choke point for local mutations (Create/SetSize/Start/Stop/Delete/UpdateStartupScript all route through it), so publishing the SSE event here ensures the editing server's other clients refresh immediately; mergePoolDefinitions does the same on receiving servers.

func (*Cluster) GossipPoolDrain added in v0.28.0

func (c *Cluster) GossipPoolDrain(spaceID string)

func (*Cluster) GossipPoolUndrain added in v0.28.0

func (c *Cluster) GossipPoolUndrain(spaceID string)

func (*Cluster) GossipResponse added in v0.23.0

func (c *Cluster) GossipResponse(response *model.Response)

func (*Cluster) GossipRole

func (c *Cluster) GossipRole(role *model.Role)

func (*Cluster) GossipScript added in v0.23.0

func (c *Cluster) GossipScript(script *model.Script)

func (*Cluster) GossipSession

func (c *Cluster) GossipSession(session *model.Session)

func (*Cluster) GossipSkill added in v0.23.0

func (c *Cluster) GossipSkill(skill *model.Skill)

func (*Cluster) GossipSpace

func (c *Cluster) GossipSpace(space *model.Space)

func (*Cluster) GossipSpaceUsageSample added in v0.24.0

func (c *Cluster) GossipSpaceUsageSample(sample *model.SpaceUsageSample)

func (*Cluster) GossipStackDefinition added in v0.24.0

func (c *Cluster) GossipStackDefinition(stackDef *model.StackDefinition)

func (*Cluster) GossipTemplate

func (c *Cluster) GossipTemplate(template *model.Template)

func (*Cluster) GossipTemplateVar

func (c *Cluster) GossipTemplateVar(templateVar *model.TemplateVar)

func (*Cluster) GossipToken

func (c *Cluster) GossipToken(token *model.Token)

func (*Cluster) GossipUser

func (c *Cluster) GossipUser(user *model.User)

func (*Cluster) GossipVolume

func (c *Cluster) GossipVolume(volume *model.Volume)

func (*Cluster) HandleLeafServer

func (c *Cluster) HandleLeafServer(w http.ResponseWriter, r *http.Request)

func (*Cluster) IsLeader added in v0.28.0

func (c *Cluster) IsLeader() bool

func (*Cluster) LockResource

func (c *Cluster) LockResource(resourceId string) string

LockResource takes a distributed lock on the given resource. In cluster mode the lock is granted by the zone's elected leader and replicated across the zone, so it survives leader failover; the returned token is opaque and must be passed to UnlockResource. An empty token means the lock was not acquired — either it is held elsewhere or leadership is unavailable.

Outside cluster mode (leaf nodes, and zones of one server where the election never starts) the lock is local to this process, which is sufficient because no other process contends for it.

func (*Cluster) Nodes

func (c *Cluster) Nodes() []*gossip.Node

func (*Cluster) NotifyEventDone added in v0.28.0

func (c *Cluster) NotifyEventDone(eventId string)

NotifyEventDone sends an immediate notification to all zone members that an event is fully delivered. Called by the leader via the Transport interface.

func (*Cluster) Start

func (c *Cluster) Start(peers []string, originServer string, originToken string)

func (*Cluster) Stop

func (c *Cluster) Stop()

func (*Cluster) UnlockResource

func (c *Cluster) UnlockResource(resourceId, unlockToken string)

UnlockResource releases a lock previously granted by LockResource.

type PoolDrainRequest added in v0.28.0

type PoolDrainRequest struct {
	SpaceID string `json:"space_id" msgpack:"space_id"`
	Undrain bool   `json:"undrain" msgpack:"undrain"`
}

type ResourceLock

type ResourceLock struct {
	Id           string
	UnlockToken  string
	IsDeleted    bool
	ExpiresAfter time.Time
	UpdatedAt    hlc.Timestamp
}

ResourceLock is the local, single-process lock record used when the cluster is not running (leaf nodes, single-server zones). Cluster-mode locking is handled by the distributed lock pool in the gossip lock package; see Cluster.LockResource.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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