Documentation
¶
Index ¶
- Constants
- func ChatStateUpdateChannel(chatID uuid.UUID) string
- func ChatWatchEventChannel(ownerID uuid.UUID) string
- func HandleChatConfigEvent(cb func(ctx context.Context, payload ChatConfigEvent, err error)) func(ctx context.Context, message []byte, err error)
- func HandleChatStateOwnership(cb func(ctx context.Context, payload ChatStateOwnershipMessage, err error)) func(ctx context.Context, message []byte, err error)
- func HandleChatStateUpdate(cb func(ctx context.Context, payload ChatStateUpdateMessage, err error)) func(ctx context.Context, message []byte, err error)
- func HandleChatWatchEvent(cb func(ctx context.Context, payload codersdk.ChatWatchEvent, err error)) func(ctx context.Context, message []byte, err error)
- func HandleInboxNotificationEvent(cb func(ctx context.Context, payload InboxNotificationEvent, err error)) func(ctx context.Context, message []byte, err error)
- func InboxNotificationForOwnerEventChannel(ownerID uuid.UUID) string
- func ProvisionerKeyDeletedChannel(keyID uuid.UUID) string
- type ChatConfigEvent
- type ChatConfigEventKind
- type ChatStateOwnershipMessage
- type ChatStateUpdateMessage
- type InboxNotificationEvent
- type InboxNotificationEventKind
Constants ¶
const AIProvidersChangedChannel = "ai_providers_changed"
AIProvidersChangedChannel is the pubsub channel that carries AI provider lifecycle events: provider create / update / soft-delete and key insert / delete. Subscribers (aibridged, aibridgeproxyd, chatd) reload their in-memory provider snapshot on receipt.
The payload is an empty invalidation hint; subscribers refetch the authoritative state from the database, so dropped messages only delay convergence rather than diverge state.
const ChatConfigEventChannel = "chat:config_change"
ChatConfigEventChannel is the pubsub channel for chat config changes (model configs, user prompts, advisor config). All replicas subscribe to this channel to invalidate their local caches.
const ChatStateOwnershipChannel = "chat:ownership"
ChatStateOwnershipChannel is the global pubsub channel that receives ownership hints when a chat is runnable but currently has missing or stale ownership. Workers listen on this channel to know when to attempt acquisition.
Variables ¶
This section is empty.
Functions ¶
func ChatStateUpdateChannel ¶ added in v2.35.0
ChatStateUpdateChannel returns the pubsub channel that receives one `chat:update:{chat_id}` message every time the chatstate state machine commits a transition for the chat.
func ChatWatchEventChannel ¶ added in v2.33.0
ChatWatchEventChannel returns the pubsub channel for chat lifecycle events scoped to a single user.
func HandleChatConfigEvent ¶ added in v2.32.0
func HandleChatConfigEvent(cb func(ctx context.Context, payload ChatConfigEvent, err error)) func(ctx context.Context, message []byte, err error)
HandleChatConfigEvent wraps a typed callback for ChatConfigEvent messages, following the same pattern as HandleChatWatchEvent.
func HandleChatStateOwnership ¶ added in v2.35.0
func HandleChatStateOwnership(cb func(ctx context.Context, payload ChatStateOwnershipMessage, err error)) func(ctx context.Context, message []byte, err error)
HandleChatStateOwnership wraps a typed callback for ChatStateOwnershipMessage consumption.
func HandleChatStateUpdate ¶ added in v2.35.0
func HandleChatStateUpdate(cb func(ctx context.Context, payload ChatStateUpdateMessage, err error)) func(ctx context.Context, message []byte, err error)
HandleChatStateUpdate wraps a typed callback for ChatStateUpdateMessage consumption, following the same pattern as HandleChatWatchEvent.
func HandleChatWatchEvent ¶ added in v2.33.0
func HandleChatWatchEvent(cb func(ctx context.Context, payload codersdk.ChatWatchEvent, err error)) func(ctx context.Context, message []byte, err error)
HandleChatWatchEvent wraps a typed callback for ChatWatchEvent messages delivered via pubsub.
func ProvisionerKeyDeletedChannel ¶ added in v2.37.0
ProvisionerKeyDeletedChannel returns the pubsub channel that carries a notification when the provisioner key with the given ID is deleted.
Types ¶
type ChatConfigEvent ¶ added in v2.32.0
type ChatConfigEvent struct {
Kind ChatConfigEventKind `json:"kind"`
// EntityID carries context for the invalidation:
// - For model configs: the specific config ID.
// - For user prompts: the user ID.
// - For advisor config: uuid.Nil (singleton site-config row).
EntityID uuid.UUID `json:"entity_id"`
}
ChatConfigEvent is published when chat configuration changes (model config CRUD, user prompt updates, or advisor config updates). Subscribers use this to invalidate their local caches.
type ChatConfigEventKind ¶ added in v2.32.0
type ChatConfigEventKind string
const ( ChatConfigEventModelConfig ChatConfigEventKind = "model_config" ChatConfigEventUserPrompt ChatConfigEventKind = "user_prompt" ChatConfigEventAdvisorConfig ChatConfigEventKind = "advisor_config" )
type ChatStateOwnershipMessage ¶ added in v2.35.0
type ChatStateOwnershipMessage struct {
ChatID uuid.UUID `json:"chat_id"`
SnapshotVersion int64 `json:"snapshot_version"`
}
ChatStateOwnershipMessage is the JSON payload published on ChatStateOwnershipChannel when ownership is missing or stale for a runnable chat. Subscribers should reload the chat row to confirm ownership before acting.
type ChatStateUpdateMessage ¶ added in v2.35.0
type ChatStateUpdateMessage struct {
SnapshotVersion int64 `json:"snapshot_version"`
WorkerID *uuid.UUID `json:"worker_id"`
RunnerID *uuid.UUID `json:"runner_id"`
HistoryVersion int64 `json:"history_version"`
QueueVersion int64 `json:"queue_version"`
RetryStateVersion int64 `json:"retry_state_version"`
GenerationAttempt int64 `json:"generation_attempt"`
Status string `json:"status"`
Archived bool `json:"archived"`
}
ChatStateUpdateMessage is the JSON payload published on ChatStateUpdateChannel after every successful CreateChat or ChatMachine.Update commit. It carries the committed post-transition versions and ownership identifiers so stream loops and workers can decide whether to refetch state.
type InboxNotificationEvent ¶
type InboxNotificationEvent struct {
Kind InboxNotificationEventKind `json:"kind"`
InboxNotification codersdk.InboxNotification `json:"inbox_notification"`
}
type InboxNotificationEventKind ¶
type InboxNotificationEventKind string
const (
InboxNotificationEventKindNew InboxNotificationEventKind = "new"
)