Skip to content

chore: send workspace pubsub events by owner id #14964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 1, 2024
Merged

Conversation

ethanndickson
Copy link
Member

@ethanndickson ethanndickson commented Oct 3, 2024

We currently send empty payloads to pubsub channels of the form workspace:<workspace_id> to notify listeners of updates to workspaces (such as for refreshing the workspace dashboard).

To support #14716, we'll instead send WorkspaceEvent payloads to pubsub channels of the form workspace_owner:<owner_id>. This enables a listener to receive events for all workspaces owned by a user.
This PR replaces the usage of the old channels without modifying any existing behaviors.

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"`
}

We've defined WorkspaceEventKinds based on how the old channel was used, but it's not yet necessary to inspect the types of any of the events, as the existing listeners are designed to fire off any of them.

WorkspaceEventKindStateChange     WorkspaceEventKind = "state_change"
WorkspaceEventKindStatsUpdate     WorkspaceEventKind = "stats_update"
WorkspaceEventKindMetadataUpdate  WorkspaceEventKind = "mtd_update"
WorkspaceEventKindAppHealthUpdate WorkspaceEventKind = "app_health"

WorkspaceEventKindAgentLifecycleUpdate  WorkspaceEventKind = "agt_lifecycle_update"
WorkspaceEventKindAgentLogsUpdate       WorkspaceEventKind = "agt_logs_update"
WorkspaceEventKindAgentConnectionUpdate WorkspaceEventKind = "agt_connection_update"
WorkspaceEventKindAgentLogsOverflow     WorkspaceEventKind = "agt_logs_overflow"
WorkspaceEventKindAgentTimeout          WorkspaceEventKind = "agt_timeout"

Copy link
Member Author

// Optional:
// WorkspaceID avoids a future lookup to find the workspace ID by setting
// the cache in advance.
WorkspaceID uuid.UUID
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need to be optional anymore, presumably since we removed the v1 agent api.

@coder coder deleted a comment from alwaysmeticulous bot Oct 4, 2024
@ethanndickson ethanndickson marked this pull request as ready for review October 4, 2024 11:57
@github-actions github-actions bot added the stale This issue is like stale bread. label Oct 12, 2024
@matifali matifali removed the stale This issue is like stale bread. label Oct 12, 2024
@ethanndickson ethanndickson force-pushed the ethan/owner-pubsub branch 3 times, most recently from 8544d74 to b7c333d Compare October 18, 2024 03:21
@ethanndickson ethanndickson force-pushed the ethan/owner-pubsub branch 3 times, most recently from 31a3d36 to f6d811f Compare October 24, 2024 04:36
@ethanndickson ethanndickson force-pushed the ethan/owner-pubsub branch 4 times, most recently from 03379ee to 9dfa2af Compare October 29, 2024 09:52
@ethanndickson ethanndickson merged commit 31506e6 into main Nov 1, 2024
27 checks passed
@ethanndickson ethanndickson deleted the ethan/owner-pubsub branch November 1, 2024 03:17
@github-actions github-actions bot locked and limited conversation to collaborators Nov 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants