func (w *Watcher) watchDeployments(ctx context.Context) {
	dindex := uint64(1)
	for {
		// Block getting all deployments using the last deployment index.
		resp, err := w.getDeploys(ctx, dindex)
		if err != nil {
			if err == context.Canceled || ctx.Err() == context.Canceled {
				return
			}

			w.logger.Printf("[ERR] nomad.deployments_watcher: failed to retrieve deploylements: %v", err)
		}

		// Guard against npe
		if resp == nil {
			continue
		}

		// Ensure we are tracking the things we should and not tracking what we
		// shouldn't be
		for _, d := range resp.Deployments {
			if d.Active() {
				if err := w.add(d); err != nil {
					w.logger.Printf("[ERR] nomad.deployments_watcher: failed to track deployment %q: %v", d.ID, err)
				}
			} else {
				w.remove(d)
			}
		}

		// Update the latest index
		dindex = resp.Index
	}
}
// watchDeployments is the long lived go-routine that watches for deployments to
// add and remove watchers on.
watchDeployments is the long lived go-routine that watches for deployments to
add and remove watchers on.
// watchDeployments is the long lived go - routine that watches for deployments to // add and remove watchers on .
func (w *Watcher) watchDeployments(ctx context.Context) {
	dindex := uint64(1)
	for {
		resp, err := w.getDeploys(ctx, dindex)
		if err != nil {
			if err == context.Canceled || ctx.Err() == context.Canceled {
				return
			}
			w.logger.Printf("[ERR] nomad.deployments_watcher: failed to retrieve deploylements: %v", err)
		}
		if resp == nil {
			continue
		}
		for _, d := range resp.Deployments {
			if d.Active() {
				if err := w.add(d); err != nil {
					w.logger.Printf("[ERR] nomad.deployments_watcher: failed to track deployment %q: %v", d.ID, err)
				}
			} else {
				w.remove(d)
			}
		}
		dindex = resp.Index
	}
}
func ( w * Watcher ) watchDeployments ( ctx context . Context ) { dindex := uint64 ( 1 ) for { resp , err := w . getDeploys ( ctx , dindex ) if err != nil { if err == context . Canceled || ctx . Err ( ) == context . Canceled { return } w . logger . Printf ( " " , err ) } if resp == nil { continue } for _ , d := range resp . Deployments { if d . Active ( ) { if err := w . add ( d ) ; err != nil { w . logger . Printf ( " " , d . ID , err ) } } else { w . remove ( d ) } } dindex = resp . Index } }
watchDeployments is the long lived go-routine that watches for deployments to
add and remove watchers on.
watchDeployments is the long lived go - routine that watches for deployments to add and remove watchers on .
// Block getting all deployments using the last deployment index. // Guard against npe // Ensure we are tracking the things we should and not tracking what we // shouldn't be // Update the latest index