Documentation
¶
Index ¶
- Constants
- func RegisterDB(db DB)
- func RegisterNemesis(n Nemesis)
- type Checker
- type Client
- type ClientCreator
- type DB
- type Model
- type Nemesis
- type NemesisGenerator
- type NemesisOperation
- type NoopChecker
- type NoopClientCreator
- type NoopDB
- func (NoopDB) IsRunning(ctx context.Context, node string) bool
- func (NoopDB) Kill(ctx context.Context, node string) error
- func (NoopDB) Name() string
- func (NoopDB) SetUp(ctx context.Context, nodes []string, node string) error
- func (NoopDB) Start(ctx context.Context, node string) error
- func (NoopDB) Stop(ctx context.Context, node string) error
- func (NoopDB) TearDown(ctx context.Context, nodes []string, node string) error
- type NoopModel
- type NoopNemesis
- type NoopNemesisGenerator
- type Operation
- type UnknownResponse
Constants ¶
const ( InvokeOperation = "call" ReturnOperation = "return" )
Operation action
Variables ¶
This section is empty.
Functions ¶
func RegisterNemesis ¶
func RegisterNemesis(n Nemesis)
RegisterNemesis registers nemesis. Not thread-safe.
Types ¶
type Checker ¶
type Checker interface { // Check a series of operations with the given model. // Return false or error if operations do not satisfy the model. Check(m Model, ops []Operation) (bool, error) // Name returns the unique name for the checker. Name() string }
Checker checks a history of operations.
type Client ¶
type Client interface { // SetUp sets up the client. SetUp(ctx context.Context, nodes []string, node string) error // TearDown tears down the client. TearDown(ctx context.Context, nodes []string, node string) error // Invoke invokes a request to the database. // Mostly, the return Response should implement UnknownResponse interface Invoke(ctx context.Context, node string, r interface{}) interface{} // NextRequest generates a request for latter Invoke. NextRequest() interface{} // DumpState the database state(also the model's state) DumpState(ctx context.Context) (interface{}, error) }
Client applies the request to the database. Client is used in contorl. You should define your own client for your database.
type ClientCreator ¶
ClientCreator creates a client. The control will create one client for one node.
type DB ¶
type DB interface { // SetUp initializes the database. SetUp(ctx context.Context, nodes []string, node string) error // TearDown tears down the database. TearDown(ctx context.Context, nodes []string, node string) error // Start starts the database Start(ctx context.Context, node string) error // Stop stops the database Stop(ctx context.Context, node string) error // Kill kills the database Kill(ctx context.Context, node string) error // IsRunning checks whether the database is running or not IsRunning(ctx context.Context, node string) bool // Name returns the unique name for the database Name() string }
DB allows Chaos to set up and tear down database.
type Model ¶
type Model interface { // Prepare the initial state of the data object. Prepare(state interface{}) // Initial state of the data object. Init() interface{} // Step function for the data object. Returns whether or not the system // could take this step with the given inputs and outputs and also // returns the new state. This should not mutate the existing state. // // state must support encoding to and decoding from json. Step(state interface{}, input interface{}, output interface{}) (bool, interface{}) // Equality on states. Equal(state1, state2 interface{}) bool // Name returns the unique name for the model. Name() string }
Model specifies the behavior of a data object.
type Nemesis ¶
type Nemesis interface { // Invoke executes the nemesis Invoke(ctx context.Context, node string, args ...string) error // Recover recovers the nemesis Recover(ctx context.Context, node string, args ...string) error // Name returns the unique name for the nemesis Name() string }
Nemesis injects failure and disturbs the database.
type NemesisGenerator ¶
type NemesisGenerator interface { // Generate generates the nemesis operation for all nodes. // Every node will be assigned a nemesis operation. Generate(nodes []string) []*NemesisOperation Name() string }
NemesisGenerator is used in control, it will generate a nemesis operation and then the control can use it to disturb the cluster.
type NemesisOperation ¶
type NemesisOperation struct { // Nemesis name Name string // Nemesis invoke args InvokeArgs []string // Nemesis recover args RecoverArgs []string // Nemesis execute time RunTime time.Duration }
NemesisOperation is nemesis operation used in control.
type NoopChecker ¶
type NoopChecker struct{}
NoopChecker is a noop checker.
type NoopClientCreator ¶
type NoopClientCreator struct { }
NoopClientCreator creates a noop client.
func (NoopClientCreator) Create ¶
func (NoopClientCreator) Create(node string) Client
Create creates the client.
type NoopDB ¶
type NoopDB struct { }
NoopDB is a DB but does nothing
type NoopModel ¶
type NoopModel struct {
// contains filtered or unexported fields
}
NoopModel is noop model.
func (*NoopModel) Init ¶
func (n *NoopModel) Init() interface{}
Init initials state of the data object.
type NoopNemesis ¶
type NoopNemesis struct { }
NoopNemesis is a nemesis but does nothing
func (NoopNemesis) Name ¶
func (NoopNemesis) Name() string
Name returns the unique name for the nemesis
type NoopNemesisGenerator ¶
type NoopNemesisGenerator struct { }
NoopNemesisGenerator generates
func (NoopNemesisGenerator) Generate ¶
func (NoopNemesisGenerator) Generate(nodes []string) []*NemesisOperation
Generate generates the nemesis operation for the nodes.
type Operation ¶
type Operation struct { Action string `json:"action"` Proc int64 `json:"proc"` Data interface{} `json:"data"` }
Operation of a data object.
type UnknownResponse ¶
type UnknownResponse interface {
IsUnknown() bool
}
UnknownResponse means we don't know wether this operation succeeds or not.