Files
moby/vendor/github.com/docker/swarmkit/manager/watchapi/server.go
Liron Levin 3b8d36d064 plugable secret backend - update vendor.conf
Updating swarmkit dependencies.

Add more parameters for the secret driver API.

Signed-off-by: Liron Levin <liron@twistlock.com>
2017-08-18 21:52:26 +03:00

57 lines
984 B
Go

package watchapi
import (
"errors"
"sync"
"github.com/docker/swarmkit/manager/state/store"
"golang.org/x/net/context"
)
var (
errAlreadyRunning = errors.New("broker is already running")
errNotRunning = errors.New("broker is not running")
)
// Server is the store API gRPC server.
type Server struct {
store *store.MemoryStore
mu sync.Mutex
pctx context.Context
cancelAll func()
}
// NewServer creates a store API server.
func NewServer(store *store.MemoryStore) *Server {
return &Server{
store: store,
}
}
// Start starts the watch server.
func (s *Server) Start(ctx context.Context) error {
s.mu.Lock()
defer s.mu.Unlock()
if s.cancelAll != nil {
return errAlreadyRunning
}
s.pctx, s.cancelAll = context.WithCancel(ctx)
return nil
}
// Stop stops the watch server.
func (s *Server) Stop() error {
s.mu.Lock()
defer s.mu.Unlock()
if s.cancelAll == nil {
return errNotRunning
}
s.cancelAll()
s.cancelAll = nil
return nil
}