Documentation
¶
Index ¶
Constants ¶
const RelaySourceHeader = "X-Coder-Relay-Source-Replica"
RelaySourceHeader marks replica-relayed stream requests.
Variables ¶
This section is empty.
Functions ¶
func NewMultiReplicaSubscribeFn ¶
func NewMultiReplicaSubscribeFn( cfg MultiReplicaSubscribeConfig, ) osschatd.SubscribeFn
NewMultiReplicaSubscribeFn returns a SubscribeFn that manages relay connections to remote replicas and returns relay message_part events only. OSS handles pubsub subscription, message catch-up, queue updates, status forwarding, and local parts merging.
Types ¶
type MultiReplicaSubscribeConfig ¶
type MultiReplicaSubscribeConfig struct {
ResolveReplicaAddress func(context.Context, uuid.UUID) (string, bool)
ReplicaHTTPClient *http.Client
ReplicaIDFn func() uuid.UUID
DialerFn func(
ctx context.Context,
chatID uuid.UUID,
workerID uuid.UUID,
requestHeader http.Header,
) (
snapshot []codersdk.ChatStreamEvent,
parts <-chan codersdk.ChatStreamEvent,
cancel func(),
err error,
)
// Clock is used for creating timers. In production use
// quartz.NewReal(); in tests use quartz.NewMock(t) to
// control reconnect timing deterministically.
Clock quartz.Clock
}
MultiReplicaSubscribeConfig holds the dependencies for multi-replica chat subscription. ReplicaIDFn is called lazily because the replica ID may not be known at construction time.
DialerFn, when set, overrides the default WebSocket relay dialer. This is used in tests to inject mock relay behavior without requiring real HTTP servers.