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

Method start

coderd/workspaceupdates.go:98–116  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

96}
97
98func (s *sub) start(ctx context.Context) (err error) {
99 rows, err := s.db.GetWorkspacesAndAgentsByOwnerID(ctx, s.userID)
100 if err != nil {
101 return xerrors.Errorf("get workspaces and agents by owner ID: %w", err)
102 }
103
104 latest := convertRows(rows)
105 initUpdate, _ := produceUpdate(workspacesByID{}, latest)
106 s.ch <- initUpdate
107 s.prev = latest
108
109 cancel, err := s.ps.SubscribeWithErr(wspubsub.WorkspaceEventChannel(s.userID), wspubsub.HandleWorkspaceEvent(s.handleEvent))
110 if err != nil {
111 return xerrors.Errorf("subscribe to workspace event channel: %w", err)
112 }
113
114 s.psCancelFn = cancel
115 return nil
116}
117
118func (s *sub) Close() error {
119 s.cancelFn()

Callers 1

SubscribeMethod · 0.95

Calls 7

WorkspaceEventChannelFunction · 0.92
HandleWorkspaceEventFunction · 0.92
convertRowsFunction · 0.85
produceUpdateFunction · 0.85
SubscribeWithErrMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected