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

Method init

coderd/workspaceagentsrpc.go:355–378  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

353}
354
355func (m *agentConnectionMonitor) init() {
356 now := dbtime.Now()
357 m.firstConnectedAt = m.workspaceAgent.FirstConnectedAt
358 if !m.firstConnectedAt.Valid {
359 m.firstConnectedAt = sql.NullTime{
360 Time: now,
361 Valid: true,
362 }
363 if m.metrics != nil {
364 duration := now.Sub(m.workspaceAgent.CreatedAt)
365 m.metrics.ObserveAgentFirstConnection(
366 duration,
367 m.workspace.TemplateName,
368 m.workspaceAgent.Name,
369 )
370 }
371 }
372 m.lastConnectedAt = sql.NullTime{
373 Time: now,
374 Valid: true,
375 }
376 m.disconnectedAt = m.workspaceAgent.DisconnectedAt
377 m.lastPing.Store(ptr.Ref(time.Now())) // Since the agent initiated the request, assume it's alive.
378}
379
380func (m *agentConnectionMonitor) start(ctx context.Context) {
381 ctx, m.cancel = context.WithCancel(ctx)

Calls 4

NowFunction · 0.92
RefFunction · 0.92
StoreMethod · 0.45