github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/swarmkit/manager/state/proposer.go (about)

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