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

Method SyncStart

agent/agentsocket/service.go:54–81  ·  view source on GitHub ↗

SyncStart starts a unit in the dependency graph.

(_ context.Context, req *proto.SyncStartRequest)

Source from the content-addressed store, hash-verified

52
53// SyncStart starts a unit in the dependency graph.
54func (s *DRPCAgentSocketService) SyncStart(_ context.Context, req *proto.SyncStartRequest) (*proto.SyncStartResponse, error) {
55 if s.unitManager == nil {
56 return nil, xerrors.Errorf("SyncStart: %w", ErrUnitManagerNotAvailable)
57 }
58
59 unitID := unit.ID(req.Unit)
60
61 if err := s.unitManager.Register(unitID); err != nil {
62 if !errors.Is(err, unit.ErrUnitAlreadyRegistered) {
63 return nil, xerrors.Errorf("SyncStart: %w", err)
64 }
65 }
66
67 isReady, err := s.unitManager.IsReady(unitID)
68 if err != nil {
69 return nil, xerrors.Errorf("cannot check readiness: %w", err)
70 }
71 if !isReady {
72 return nil, xerrors.Errorf("cannot start unit %q: unit not ready", req.Unit)
73 }
74
75 err = s.unitManager.UpdateStatus(unitID, unit.StatusStarted)
76 if err != nil {
77 return nil, xerrors.Errorf("cannot start unit %q: %w", req.Unit, err)
78 }
79
80 return &proto.SyncStartResponse{}, nil
81}
82
83// SyncWant declares a dependency between units.
84func (s *DRPCAgentSocketService) SyncWant(_ context.Context, req *proto.SyncWantRequest) (*proto.SyncWantResponse, error) {

Callers

nothing calls this directly

Calls 6

IDTypeAlias · 0.92
IsReadyMethod · 0.80
UpdateStatusMethod · 0.65
ErrorfMethod · 0.45
RegisterMethod · 0.45
IsMethod · 0.45

Tested by

no test coverage detected