Documentation ¶
Index ¶
- type CommandFactory
- func (f *CommandFactory) CreateCompareAndSwapCommand(key string, value string, prevValue string, prevIndex uint64, ...) raft.Command
- func (f *CommandFactory) CreateCreateCommand(key string, value string, expireTime time.Time, unique bool) raft.Command
- func (f *CommandFactory) CreateDeleteCommand(key string, recursive bool) raft.Command
- func (f *CommandFactory) CreateSetCommand(key string, value string, expireTime time.Time) raft.Command
- func (f *CommandFactory) CreateSyncCommand(now time.Time) raft.Command
- func (f *CommandFactory) CreateUpdateCommand(key string, value string, expireTime time.Time) raft.Command
- func (f *CommandFactory) CreateUpgradeCommand() raft.Command
- func (f *CommandFactory) Version() int
- type CompareAndSwapCommand
- type CreateCommand
- type DeleteCommand
- type SetCommand
- type SyncCommand
- type UpdateCommand
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandFactory ¶
type CommandFactory struct { }
CommandFactory provides a pluggable way to create version 2 commands.
func (*CommandFactory) CreateCompareAndSwapCommand ¶
func (f *CommandFactory) CreateCompareAndSwapCommand(key string, value string, prevValue string, prevIndex uint64, expireTime time.Time) raft.Command
CreateCompareAndSwapCommand creates a version 2 command to conditionally set a key in the store.
func (*CommandFactory) CreateCreateCommand ¶
func (f *CommandFactory) CreateCreateCommand(key string, value string, expireTime time.Time, unique bool) raft.Command
CreateCreateCommand creates a version 2 command to create a new key in the store.
func (*CommandFactory) CreateDeleteCommand ¶
func (f *CommandFactory) CreateDeleteCommand(key string, recursive bool) raft.Command
CreateDeleteCommand creates a version 2 command to delete a key from the store.
func (*CommandFactory) CreateSetCommand ¶
func (f *CommandFactory) CreateSetCommand(key string, value string, expireTime time.Time) raft.Command
CreateSetCommand creates a version 2 command to set a key to a given value in the store.
func (*CommandFactory) CreateSyncCommand ¶
func (f *CommandFactory) CreateSyncCommand(now time.Time) raft.Command
func (*CommandFactory) CreateUpdateCommand ¶
func (f *CommandFactory) CreateUpdateCommand(key string, value string, expireTime time.Time) raft.Command
CreateUpdateCommand creates a version 2 command to update a key to a given value in the store.
func (*CommandFactory) CreateUpgradeCommand ¶
func (f *CommandFactory) CreateUpgradeCommand() raft.Command
CreateUpgradeCommand is a no-op since version 2 is the first version to support store versioning.
func (*CommandFactory) Version ¶
func (f *CommandFactory) Version() int
Version returns the version of this factory.
type CompareAndSwapCommand ¶
type CompareAndSwapCommand struct { Key string `json:"key"` Value string `json:"value"` ExpireTime time.Time `json:"expireTime"` PrevValue string `json:"prevValue"` PrevIndex uint64 `json:"prevIndex"` }
The CompareAndSwap performs a conditional update on a key in the store.
func (*CompareAndSwapCommand) Apply ¶
func (c *CompareAndSwapCommand) Apply(server raft.Server) (interface{}, error)
Set the key-value pair if the current value of the key equals to the given prevValue
func (*CompareAndSwapCommand) CommandName ¶
func (c *CompareAndSwapCommand) CommandName() string
The name of the testAndSet command in the log
type CreateCommand ¶
type CreateCommand struct { Key string `json:"key"` Value string `json:"value"` ExpireTime time.Time `json:"expireTime"` Unique bool `json:"unique"` }
Create command
func (*CreateCommand) Apply ¶
func (c *CreateCommand) Apply(server raft.Server) (interface{}, error)
Create node
func (*CreateCommand) CommandName ¶
func (c *CreateCommand) CommandName() string
The name of the create command in the log
type DeleteCommand ¶
The DeleteCommand removes a key from the Store.
func (*DeleteCommand) Apply ¶
func (c *DeleteCommand) Apply(server raft.Server) (interface{}, error)
Delete the key
func (*DeleteCommand) CommandName ¶
func (c *DeleteCommand) CommandName() string
The name of the delete command in the log
type SetCommand ¶
type SetCommand struct { Key string `json:"key"` Value string `json:"value"` ExpireTime time.Time `json:"expireTime"` }
Create command
func (*SetCommand) Apply ¶
func (c *SetCommand) Apply(server raft.Server) (interface{}, error)
Create node
func (*SetCommand) CommandName ¶
func (c *SetCommand) CommandName() string
The name of the create command in the log
type SyncCommand ¶
func (SyncCommand) Apply ¶
func (c SyncCommand) Apply(server raft.Server) (interface{}, error)
func (SyncCommand) CommandName ¶
func (c SyncCommand) CommandName() string
The name of the Sync command in the log
type UpdateCommand ¶
type UpdateCommand struct { Key string `json:"key"` Value string `json:"value"` ExpireTime time.Time `json:"expireTime"` }
Update command
func (*UpdateCommand) Apply ¶
func (c *UpdateCommand) Apply(server raft.Server) (interface{}, error)
Create node
func (*UpdateCommand) CommandName ¶
func (c *UpdateCommand) CommandName() string
The name of the update command in the log