MCPcopy Index your code
hub / github.com/coder/coder / New

Function New

coderd/x/chatd/chatd.go:4202–4340  ·  view source on GitHub ↗

New creates a new chat processor. The processor polls for pending chats and processes them. It is the caller's responsibility to call Close on the returned instance.

(cfg Config)

Source from the content-addressed store, hash-verified

4200// chats and processes them. It is the caller's responsibility to call Close
4201// on the returned instance.
4202func New(cfg Config) *Server {
4203 ctx, cancel := context.WithCancel(context.Background())
4204
4205 pendingChatAcquireInterval := cfg.PendingChatAcquireInterval
4206 if pendingChatAcquireInterval == 0 {
4207 pendingChatAcquireInterval = DefaultPendingChatAcquireInterval
4208 }
4209
4210 inFlightChatStaleAfter := cfg.InFlightChatStaleAfter
4211 if inFlightChatStaleAfter == 0 {
4212 inFlightChatStaleAfter = DefaultInFlightChatStaleAfter
4213 }
4214
4215 maxChatsPerAcquire := cfg.MaxChatsPerAcquire
4216 if maxChatsPerAcquire <= 0 {
4217 maxChatsPerAcquire = DefaultMaxChatsPerAcquire
4218 }
4219
4220 chatHeartbeatInterval := cfg.ChatHeartbeatInterval
4221 if chatHeartbeatInterval == 0 {
4222 chatHeartbeatInterval = DefaultChatHeartbeatInterval
4223 }
4224
4225 clk := cfg.Clock
4226 if clk == nil {
4227 clk = quartz.NewReal()
4228 }
4229
4230 instructionLookupTimeout := cfg.InstructionLookupTimeout
4231 if instructionLookupTimeout == 0 {
4232 instructionLookupTimeout = homeInstructionLookupTimeout
4233 }
4234
4235 workerID := cfg.ReplicaID
4236 if workerID == uuid.Nil {
4237 workerID = uuid.New()
4238 }
4239
4240 allowBYOK := true
4241 if cfg.AllowBYOKSet {
4242 allowBYOK = cfg.AllowBYOK
4243 }
4244
4245 p := &Server{
4246 cancel: cancel,
4247 db: cfg.Database,
4248 workerID: workerID,
4249 logger: cfg.Logger.Named("processor"),
4250 subscribeFn: cfg.SubscribeFn,
4251 agentConnFn: cfg.AgentConn,
4252 agentInactiveDisconnectTimeout: cfg.AgentInactiveDisconnectTimeout,
4253 dialTimeout: defaultDialTimeout,
4254 instructionLookupTimeout: instructionLookupTimeout,
4255 createWorkspaceFn: cfg.CreateWorkspace,
4256 startWorkspaceFn: cfg.StartWorkspace,
4257 stopWorkspaceFn: cfg.StopWorkspace,
4258 pubsub: cfg.Pubsub,
4259 webpushDispatcher: cfg.WebpushDispatcher,

Calls 15

SetStaleAfterMethod · 0.95
recoverStaleChatsMethod · 0.95
debugServiceMethod · 0.95
FinalizeStaleMethod · 0.95
heartbeatLoopMethod · 0.95
streamJanitorLoopMethod · 0.95
NewServiceFunction · 0.92
WithAlwaysEnableFunction · 0.92
NewMetricsFunction · 0.92
NopMetricsFunction · 0.92
AsChatdFunction · 0.92
newChatConfigCacheFunction · 0.85