chatd

package
v2.32.4 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
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.

Jump to

Keyboard shortcuts

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