Documentation ¶
Index ¶
- type Cache
- type StateMachine
- func (s *StateMachine) Apply(req msgs.ClientRequest) msgs.ClientResponse
- func (s *StateMachine) ApplyRead(req msgs.ClientRequest) msgs.ClientResponse
- func (s *StateMachine) ApplyReads(reqs []msgs.ClientRequest) []msgs.ClientResponse
- func (s *StateMachine) Check(req msgs.ClientRequest) (bool, msgs.ClientResponse)
- func (s *StateMachine) MakeSnapshot() ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
Cache provides a simple key value store mapping client ID's to the last request sent to them. It is safe for concurreny access
func (*Cache) MarshalJSON ¶
MarshalJSON marshals a cache into bytes default JSON marshalling requires string map keys thus custom function is provided
func (*Cache) UnmarshalJSON ¶
UnmarshalJSON unmarshals bytes into a cache
type StateMachine ¶
StateMachine abstracts over the services state machine and the cache which ensure exactly-once execution
func New ¶
func New(appConfig string) *StateMachine
New creates a StateMachine with the given service application
func RestoreSnapshot ¶
func RestoreSnapshot(snap []byte, appConfig string) (*StateMachine, error)
RestoreSnapshot deserializes bytes into a state machine
func (*StateMachine) Apply ¶
func (s *StateMachine) Apply(req msgs.ClientRequest) msgs.ClientResponse
Apply request will apply a request (or fetch the result of its application) and return the result
func (*StateMachine) ApplyRead ¶
func (s *StateMachine) ApplyRead(req msgs.ClientRequest) msgs.ClientResponse
ApplyRead request will apply a read request and return the result. It will not cache the result
func (*StateMachine) ApplyReads ¶
func (s *StateMachine) ApplyReads(reqs []msgs.ClientRequest) []msgs.ClientResponse
ApplyReads request will apply a slice of read requests and return the results. It will not cache the results.
func (*StateMachine) Check ¶
func (s *StateMachine) Check(req msgs.ClientRequest) (bool, msgs.ClientResponse)
Check request return true and the result of the request if the request has already been applied to the state machine
func (*StateMachine) MakeSnapshot ¶
func (s *StateMachine) MakeSnapshot() ([]byte, error)
MakeSnapshot serializes a state machine into bytes