SyncWant declares a dependency between units.
(_ context.Context, req *proto.SyncWantRequest)
| 82 | |
| 83 | // SyncWant declares a dependency between units. |
| 84 | func (s *DRPCAgentSocketService) SyncWant(_ context.Context, req *proto.SyncWantRequest) (*proto.SyncWantResponse, error) { |
| 85 | if s.unitManager == nil { |
| 86 | return nil, xerrors.Errorf("cannot add dependency: %w", ErrUnitManagerNotAvailable) |
| 87 | } |
| 88 | |
| 89 | unitID := unit.ID(req.Unit) |
| 90 | dependsOnID := unit.ID(req.DependsOn) |
| 91 | |
| 92 | if err := s.unitManager.Register(unitID); err != nil && !errors.Is(err, unit.ErrUnitAlreadyRegistered) { |
| 93 | return nil, xerrors.Errorf("cannot add dependency: %w", err) |
| 94 | } |
| 95 | |
| 96 | if err := s.unitManager.AddDependency(unitID, dependsOnID, unit.StatusComplete); err != nil { |
| 97 | return nil, xerrors.Errorf("cannot add dependency: %w", err) |
| 98 | } |
| 99 | |
| 100 | return &proto.SyncWantResponse{}, nil |
| 101 | } |
| 102 | |
| 103 | // SyncComplete marks a unit as complete in the dependency graph. |
| 104 | func (s *DRPCAgentSocketService) SyncComplete(_ context.Context, req *proto.SyncCompleteRequest) (*proto.SyncCompleteResponse, error) { |
nothing calls this directly
no test coverage detected