history

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2020 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompleteOperations

func CompleteOperations(ops []core.Operation, p RecordParser) ([]core.Operation, error)

CompleteOperations completes the history of operation.

func ReadHistory

func ReadHistory(historyFile string, p RecordParser) ([]core.Operation, interface{}, error)

ReadHistory reads operations and a model state from a history file.

Types

type NoopParser

type NoopParser struct {
	State int
}

NoopParser is a noop parser.

func (NoopParser) OnNoopResponse

func (p NoopParser) OnNoopResponse() interface{}

OnNoopResponse impls RecordParser.

func (NoopParser) OnRequest

func (p NoopParser) OnRequest(data json.RawMessage) (interface{}, error)

OnRequest impls RecordParser.

func (NoopParser) OnResponse

func (p NoopParser) OnResponse(data json.RawMessage) (interface{}, error)

OnResponse impls RecordParser.

func (NoopParser) OnState

func (p NoopParser) OnState(state json.RawMessage) (interface{}, error)

OnState impls RecordParser.

type NoopRequest

type NoopRequest struct {
	// 0 for read, 1 for write
	Op    int
	Value int
}

NoopRequest is a noop request.

type NoopResponse

type NoopResponse struct {
	Value   int
	Ok      bool
	Unknown bool
}

NoopResponse is a noop response.

func (NoopResponse) IsUnknown

func (n NoopResponse) IsUnknown() bool

IsUnknown implements UnknownResponse interface

type RecordParser

type RecordParser interface {
	// OnRequest parses an operation data to model's input.
	OnRequest(data json.RawMessage) (interface{}, error)
	// OnResponse parses an operation data to model's output.
	OnResponse(data json.RawMessage) (interface{}, error)
	// If we have some infinite operations, we should return a
	// noop response to complete the operation.
	OnNoopResponse() interface{}
	// OnState parses model state json data to model's state
	OnState(state json.RawMessage) (interface{}, error)
}

RecordParser is to parses the operation data. It must be thread-safe.

type Recorder

type Recorder struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Recorder records operation history.

func NewRecorder

func NewRecorder(name string) (*Recorder, error)

NewRecorder creates a recorder to log the history to the file.

func (*Recorder) Close

func (r *Recorder) Close()

Close closes the recorder.

func (*Recorder) RecordInvokeNemesis

func (r *Recorder) RecordInvokeNemesis(nemesisRecord core.NemesisGeneratorRecord) error

RecordInvokeNemesis records nemesis invocation events on history file

func (*Recorder) RecordRecoverNemesis

func (r *Recorder) RecordRecoverNemesis(op string) error

RecordRecoverNemesis records nemesis recovery events on history file

func (*Recorder) RecordRequest

func (r *Recorder) RecordRequest(proc int64, op interface{}) error

RecordRequest records the request.

func (*Recorder) RecordResponse

func (r *Recorder) RecordResponse(proc int64, op interface{}) error

RecordResponse records the response.

func (*Recorder) RecordState

func (r *Recorder) RecordState(state interface{}) error

RecordState records the request.

Jump to

Keyboard shortcuts

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