wspubsub

package
v2.37.10 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: AGPL-3.0 Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const AllWorkspaceEventChannel = "workspace_updates:all"

AllWorkspaceEventChannel is a global channel that receives events for all workspaces. This is useful when you need to watch N workspaces without creating N separate subscriptions.

View Source
const WorkspaceBuildOrchestrationWakeChannel = "workspace_build_orchestrations:wake"

WorkspaceBuildOrchestrationWakeChannel wakes the internal worker that processes pending workspace build orchestration rows.

Variables

This section is empty.

Functions

func HandleWorkspaceBuildUpdate added in v2.32.0

func HandleWorkspaceBuildUpdate(cb func(ctx context.Context, payload codersdk.WorkspaceBuildUpdate, err error)) func(ctx context.Context, message []byte, err error)

HandleWorkspaceBuildUpdate wraps a callback to parse WorkspaceBuildUpdate messages from the pubsub.

func HandleWorkspaceEvent

func HandleWorkspaceEvent(cb func(ctx context.Context, payload WorkspaceEvent, err error)) func(ctx context.Context, message []byte, err error)

func PublishWorkspaceBuildOrchestrationWake added in v2.36.0

func PublishWorkspaceBuildOrchestrationWake(_ context.Context, ps pubsub.Pubsub) error

PublishWorkspaceBuildOrchestrationWake wakes coderd instances that can process pending workspace build orchestration rows. Call this after any workspace build reaches a terminal state: succeeded, failed, or canceled.

func PublishWorkspaceBuildUpdate added in v2.32.0

func PublishWorkspaceBuildUpdate(_ context.Context, ps pubsub.Pubsub, update codersdk.WorkspaceBuildUpdate) error

PublishWorkspaceBuildUpdate is a helper to publish a workspace build update to the AllWorkspaceEventChannel. This should be called when a build completes (succeeds, fails, or is canceled).

func PublishWorkspaceEvent added in v2.36.0

func PublishWorkspaceEvent(_ context.Context, ps pubsub.Pubsub, ownerID uuid.UUID, event WorkspaceEvent) error

PublishWorkspaceEvent validates and publishes a workspace event to the owner's event channel.

func WorkspaceEventChannel

func WorkspaceEventChannel(ownerID uuid.UUID) string

WorkspaceEventChannel can be used to subscribe to events for workspaces owned by the provided user ID.

Types

type WorkspaceEvent

type WorkspaceEvent struct {
	Kind        WorkspaceEventKind `json:"kind"`
	WorkspaceID uuid.UUID          `json:"workspace_id" format:"uuid"`
	// AgentID is only set for WorkspaceEventKindAgent* events
	// (excluding AgentTimeout)
	AgentID *uuid.UUID `json:"agent_id,omitempty" format:"uuid"`
}

func (*WorkspaceEvent) Validate

func (w *WorkspaceEvent) Validate() error

type WorkspaceEventKind

type WorkspaceEventKind string
const (
	WorkspaceEventKindStateChange     WorkspaceEventKind = "state_change"
	WorkspaceEventKindStatsUpdate     WorkspaceEventKind = "stats_update"
	WorkspaceEventKindMetadataUpdate  WorkspaceEventKind = "mtd_update"
	WorkspaceEventKindAppHealthUpdate WorkspaceEventKind = "app_health"

	WorkspaceEventKindAgentLifecycleUpdate  WorkspaceEventKind = "agt_lifecycle_update"
	WorkspaceEventKindAgentConnectionUpdate WorkspaceEventKind = "agt_connection_update"
	WorkspaceEventKindAgentFirstLogs        WorkspaceEventKind = "agt_first_logs"
	WorkspaceEventKindAgentLogsOverflow     WorkspaceEventKind = "agt_logs_overflow"
	WorkspaceEventKindAgentTimeout          WorkspaceEventKind = "agt_timeout"
	WorkspaceEventKindAgentAppStatusUpdate  WorkspaceEventKind = "agt_app_status_update"
)

Jump to

Keyboard shortcuts

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