proposer.go 1.1 KB

123456789101112131415161718192021222324252627282930
  1. package state
  2. import (
  3. "github.com/docker/swarmkit/api"
  4. "golang.org/x/net/context"
  5. )
  6. // A Change includes a version number and a set of store actions from a
  7. // particular log entry.
  8. type Change struct {
  9. StoreActions []api.StoreAction
  10. Version api.Version
  11. }
  12. // A Proposer can propose actions to a cluster.
  13. type Proposer interface {
  14. // ProposeValue adds storeAction to the distributed log. If this
  15. // completes successfully, ProposeValue calls cb to commit the
  16. // proposed changes. The callback is necessary for the Proposer to make
  17. // sure that the changes are committed before it interacts further
  18. // with the store.
  19. ProposeValue(ctx context.Context, storeAction []api.StoreAction, cb func()) error
  20. // GetVersion returns the monotonic index of the most recent item in
  21. // the distributed log.
  22. GetVersion() *api.Version
  23. // ChangesBetween returns the changes starting after "from", up to and
  24. // including "to". If these changes are not available because the log
  25. // has been compacted, an error will be returned.
  26. ChangesBetween(from, to api.Version) ([]Change, error)
  27. }