app

package
Version: v0.0.0-...-fc1e718 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2017 License: MIT Imports: 6 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

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

func (c *Cache) MarshalJSON() ([]byte, error)

MarshalJSON marshals a cache into bytes default JSON marshalling requires string map keys thus custom function is provided

func (*Cache) UnmarshalJSON

func (c *Cache) UnmarshalJSON(snap []byte) error

UnmarshalJSON unmarshals bytes into a cache

type StateMachine

type StateMachine struct {
	Cache *Cache
	Store services.Service
}

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

Apply request will apply a request (or fetch the result of its application) and return the result

func (*StateMachine) ApplyRead

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

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

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL