Documentation
¶
Index ¶
- Constants
- func ChatEventChannel(ownerID uuid.UUID) string
- func ChatStreamNotifyChannel(chatID uuid.UUID) string
- func HandleChatConfigEvent(cb func(ctx context.Context, payload ChatConfigEvent, err error)) func(ctx context.Context, message []byte, err error)
- func HandleChatEvent(cb func(ctx context.Context, payload ChatEvent, 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
- type ChatConfigEvent
- type ChatConfigEventKind
- type ChatEvent
- type ChatEventKind
- type ChatStreamNotifyMessage
- type InboxNotificationEvent
- type InboxNotificationEventKind
Constants ¶
const ChatConfigEventChannel = "chat:config_change"
ChatConfigEventChannel is the pubsub channel for chat config changes (providers, model configs, user prompts). All replicas subscribe to this channel to invalidate their local caches.
Variables ¶
This section is empty.
Functions ¶
func ChatEventChannel ¶ added in v2.32.0
func ChatStreamNotifyChannel ¶ added in v2.32.0
ChatStreamNotifyChannel returns the pubsub channel for per-chat stream notifications. Subscribers receive lightweight notifications and read actual content from the database.
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 HandleChatEvent.
func HandleChatEvent ¶ added in v2.32.0
Types ¶
type ChatConfigEvent ¶ added in v2.32.0
type ChatConfigEvent struct {
Kind ChatConfigEventKind `json:"kind"`
// EntityID carries context for the invalidation:
// - For providers: uuid.Nil (all providers are invalidated).
// - For model configs: the specific config ID.
// - For user prompts: the user ID.
EntityID uuid.UUID `json:"entity_id"`
}
ChatConfigEvent is published when chat configuration changes (provider CRUD, model config CRUD, or user prompt updates). Subscribers use this to invalidate their local caches.
type ChatConfigEventKind ¶ added in v2.32.0
type ChatConfigEventKind string
const ( ChatConfigEventProviders ChatConfigEventKind = "providers" ChatConfigEventModelConfig ChatConfigEventKind = "model_config" ChatConfigEventUserPrompt ChatConfigEventKind = "user_prompt" )
type ChatEvent ¶ added in v2.32.0
type ChatEvent struct {
Kind ChatEventKind `json:"kind"`
Chat codersdk.Chat `json:"chat"`
}
type ChatEventKind ¶ added in v2.32.0
type ChatEventKind string
const ( ChatEventKindStatusChange ChatEventKind = "status_change" ChatEventKindTitleChange ChatEventKind = "title_change" ChatEventKindCreated ChatEventKind = "created" ChatEventKindDeleted ChatEventKind = "deleted" ChatEventKindDiffStatusChange ChatEventKind = "diff_status_change" )
type ChatStreamNotifyMessage ¶ added in v2.32.0
type ChatStreamNotifyMessage struct {
// AfterMessageID tells subscribers to query messages after this
// ID. Set when a new message is persisted.
AfterMessageID int64 `json:"after_message_id,omitempty"`
// Status is set when the chat status changes. Subscribers use
// this to update clients and to manage relay lifecycle.
Status string `json:"status,omitempty"`
// WorkerID identifies which replica is running the chat. Used
// by enterprise relay to know where to connect.
WorkerID string `json:"worker_id,omitempty"`
// Retry carries a structured retry event for cross-replica live
// delivery. This is transient stream state and is not read back
// from the database.
Retry *codersdk.ChatStreamRetry `json:"retry,omitempty"`
// ErrorPayload carries a structured error event for cross-replica
// live delivery. Keep Error for backward compatibility with older
// replicas during rolling deploys.
ErrorPayload *codersdk.ChatStreamError `json:"error_payload,omitempty"`
// Error is the legacy string-only error payload kept for mixed-
// version compatibility during rollout.
Error string `json:"error,omitempty"`
// QueueUpdate is set when the queued messages change.
QueueUpdate bool `json:"queue_update,omitempty"`
// FullRefresh signals that subscribers should re-fetch all
// messages from the beginning (e.g. after an edit that
// truncates message history).
FullRefresh bool `json:"full_refresh,omitempty"`
}
ChatStreamNotifyMessage is the payload published on the per-chat stream notification channel. Durable message content is still read from the database, while transient control events can be carried inline for cross-replica delivery.
type InboxNotificationEvent ¶
type InboxNotificationEvent struct {
Kind InboxNotificationEventKind `json:"kind"`
InboxNotification codersdk.InboxNotification `json:"inbox_notification"`
}
type InboxNotificationEventKind ¶
type InboxNotificationEventKind string
const (
InboxNotificationEventKindNew InboxNotificationEventKind = "new"
)