Skip to content

Commit

Permalink
fix: remove IsActive
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Hare committed May 21, 2024
1 parent 9a46a18 commit 79f621f
Showing 1 changed file with 2 additions and 40 deletions.
42 changes: 2 additions & 40 deletions manifest/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ type StatusClient interface {
//go:generate mockery --name Client
type Client interface {
Submit(context.Context, dtypes.DeploymentID, manifest.Manifest) error
IsActive(context.Context, dtypes.DeploymentID) (bool, error)
}

// Service is the interface that includes StatusClient and Handler interfaces. It also wraps Done method
Expand All @@ -82,7 +81,6 @@ func NewService(ctx context.Context, session session.Session, bus pubsub.Bus, ho
sub: sub,
statusch: make(chan chan<- *Status),
mreqch: make(chan manifestRequest),
activeCheckCh: make(chan isActiveCheck),
managers: make(map[string]*manager),
managerch: make(chan *manager),
lc: lifecycle.New(),
Expand All @@ -107,9 +105,8 @@ type service struct {
sub pubsub.Subscriber
lc lifecycle.Lifecycle

statusch chan chan<- *Status
mreqch chan manifestRequest
activeCheckCh chan isActiveCheck
statusch chan chan<- *Status
mreqch chan manifestRequest

managers map[string]*manager
managerch chan *manager
Expand All @@ -131,38 +128,6 @@ func (s *service) updateGauges() {
manifestWatchdogGauge.Set(float64(len(s.managers)))
}

type isActiveCheck struct {
ch chan<- bool
Deployment dtypes.DeploymentID
}

func (s *service) IsActive(ctx context.Context, dID dtypes.DeploymentID) (bool, error) {
ch := make(chan bool, 1)
req := isActiveCheck{
Deployment: dID,
ch: ch,
}

select {
case <-ctx.Done():
return false, ctx.Err()
case s.activeCheckCh <- req:
case <-s.lc.ShuttingDown():
return false, ErrNotRunning
case <-s.lc.Done():
return false, ErrNotRunning
}

select {
case <-ctx.Done():
return false, ctx.Err()
case <-s.lc.Done():
return false, ErrNotRunning
case result := <-ch:
return result, nil
}
}

// Submit incoming manifest request.
func (s *service) Submit(ctx context.Context, did dtypes.DeploymentID, mani manifest.Manifest) error {
// This needs to be buffered because the goroutine writing to this may get the result
Expand Down Expand Up @@ -287,9 +252,6 @@ loop:
manager.removeLease(ev.ID)
}
}
case check := <-s.activeCheckCh:
_, ok := s.managers[dquery.DeploymentPath(check.Deployment)]
check.ch <- ok
case req := <-s.mreqch:
// Cancel the watchdog (if it exists), since a manifest has been received
s.maybeRemoveWatchdog(req.value.Deployment)
Expand Down

0 comments on commit 79f621f

Please sign in to comment.