Documentation ¶
Index ¶
- Variables
- func Match(r1, r2 EtcdNonDeterministicResponse) bool
- func ValidateOperationHistoryAndReturnVisualize(t *testing.T, lg *zap.Logger, operations []porcupine.Operation) (visualize func(basepath string))
- type AppendableHistory
- func (h *AppendableHistory) AppendDefragment(start, end time.Duration, resp *clientv3.DefragmentResponse, err error)
- func (h *AppendableHistory) AppendDelete(key string, start, end time.Duration, resp *clientv3.DeleteResponse, err error)
- func (h *AppendableHistory) AppendLeaseGrant(start, end time.Duration, resp *clientv3.LeaseGrantResponse, err error)
- func (h *AppendableHistory) AppendLeaseRevoke(id int64, start, end time.Duration, resp *clientv3.LeaseRevokeResponse, ...)
- func (h *AppendableHistory) AppendPut(key, value string, start, end time.Duration, resp *clientv3.PutResponse, ...)
- func (h *AppendableHistory) AppendPutWithLease(key, value string, leaseID int64, start, end time.Duration, ...)
- func (h *AppendableHistory) AppendRange(key string, withPrefix bool, start, end time.Duration, ...)
- func (h *AppendableHistory) AppendTxn(cmp []clientv3.Cmp, clientOnSuccessOps, clientOnFailure []clientv3.Op, ...)
- type DefragmentRequest
- type DefragmentResponse
- type EtcdCondition
- type EtcdLease
- type EtcdNonDeterministicResponse
- type EtcdOperation
- type EtcdOperationResult
- type EtcdRequest
- type EtcdResponse
- type History
- type KeyValue
- type LeaseGrantReponse
- type LeaseGrantRequest
- type LeaseRevokeRequest
- type LeaseRevokeResponse
- type OperationType
- type RequestType
- type TxnRequest
- type TxnResponse
- type ValueOrHash
- type ValueRevision
Constants ¶
This section is empty.
Variables ¶
var DeterministicModel = porcupine.Model{ Init: func() interface{} { var s etcdState data, err := json.Marshal(s) if err != nil { panic(err) } return string(data) }, Step: func(st interface{}, in interface{}, out interface{}) (bool, interface{}) { var s etcdState err := json.Unmarshal([]byte(st.(string)), &s) if err != nil { panic(err) } ok, s := s.Step(in.(EtcdRequest), out.(EtcdResponse)) data, err := json.Marshal(s) if err != nil { panic(err) } return ok, string(data) }, DescribeOperation: func(in, out interface{}) string { return fmt.Sprintf("%s -> %s", describeEtcdRequest(in.(EtcdRequest)), describeEtcdResponse(in.(EtcdRequest), out.(EtcdResponse))) }, }
DeterministicModel assumes that all requests succeed and have a correct response.
var NonDeterministicModel = porcupine.Model{ Init: func() interface{} { var states nonDeterministicState data, err := json.Marshal(states) if err != nil { panic(err) } return string(data) }, Step: func(st interface{}, in interface{}, out interface{}) (bool, interface{}) { var states nonDeterministicState err := json.Unmarshal([]byte(st.(string)), &states) if err != nil { panic(err) } ok, states := states.Step(in.(EtcdRequest), out.(EtcdNonDeterministicResponse)) data, err := json.Marshal(states) if err != nil { panic(err) } return ok, string(data) }, DescribeOperation: func(in, out interface{}) string { return fmt.Sprintf("%s -> %s", describeEtcdRequest(in.(EtcdRequest)), describeEtcdNonDeterministicResponse(in.(EtcdRequest), out.(EtcdNonDeterministicResponse))) }, }
NonDeterministicModel extends DeterministicModel to handle requests that have unknown or error response. Unknown/error response doesn't inform whether request was persisted or not, so model considers both cases. This is represented as multiple equally possible deterministic states. Failed requests fork the possible states, while successful requests merge and filter them.
Functions ¶
func Match ¶
func Match(r1, r2 EtcdNonDeterministicResponse) bool
func ValidateOperationHistoryAndReturnVisualize ¶
func ValidateOperationHistoryAndReturnVisualize(t *testing.T, lg *zap.Logger, operations []porcupine.Operation) (visualize func(basepath string))
ValidateOperationHistoryAndReturnVisualize return visualize as porcupine.linearizationInfo used to generate visualization is private.
Types ¶
type AppendableHistory ¶
type AppendableHistory struct { History // contains filtered or unexported fields }
AppendableHistory allows to collect history of sequential operations.
Ensures that operation history is compatible with porcupine library, by preventing concurrent requests sharing the same stream id. For failed requests, we don't know their return time, so generate new stream id.
Appending needs to be done in order of operation execution time (start, end time). Operations time should be calculated as time.Since common base time to ensure that Go monotonic time is used. More in https://github.com/golang/go/blob/96add980ad27faed627f26ef1ab09e8fe45d6bd1/src/time/time.go#L10.
func NewAppendableHistory ¶
func NewAppendableHistory(ids identity.Provider) *AppendableHistory
func (*AppendableHistory) AppendDefragment ¶
func (h *AppendableHistory) AppendDefragment(start, end time.Duration, resp *clientv3.DefragmentResponse, err error)
func (*AppendableHistory) AppendDelete ¶
func (h *AppendableHistory) AppendDelete(key string, start, end time.Duration, resp *clientv3.DeleteResponse, err error)
func (*AppendableHistory) AppendLeaseGrant ¶
func (h *AppendableHistory) AppendLeaseGrant(start, end time.Duration, resp *clientv3.LeaseGrantResponse, err error)
func (*AppendableHistory) AppendLeaseRevoke ¶
func (h *AppendableHistory) AppendLeaseRevoke(id int64, start, end time.Duration, resp *clientv3.LeaseRevokeResponse, err error)
func (*AppendableHistory) AppendPut ¶
func (h *AppendableHistory) AppendPut(key, value string, start, end time.Duration, resp *clientv3.PutResponse, err error)
func (*AppendableHistory) AppendPutWithLease ¶
func (h *AppendableHistory) AppendPutWithLease(key, value string, leaseID int64, start, end time.Duration, resp *clientv3.PutResponse, err error)
func (*AppendableHistory) AppendRange ¶
func (h *AppendableHistory) AppendRange(key string, withPrefix bool, start, end time.Duration, resp *clientv3.GetResponse)
type DefragmentRequest ¶
type DefragmentRequest struct{}
type DefragmentResponse ¶
type DefragmentResponse struct{}
type EtcdCondition ¶
type EtcdNonDeterministicResponse ¶
type EtcdNonDeterministicResponse struct { EtcdResponse Err error ResultUnknown bool }
type EtcdOperation ¶
type EtcdOperation struct { Type OperationType Key string WithPrefix bool Limit int64 Value ValueOrHash LeaseID int64 }
type EtcdOperationResult ¶
type EtcdRequest ¶
type EtcdRequest struct { Type RequestType LeaseGrant *LeaseGrantRequest LeaseRevoke *LeaseRevokeRequest Txn *TxnRequest Defragment *DefragmentRequest }
type EtcdResponse ¶
type EtcdResponse struct { Revision int64 Txn *TxnResponse LeaseGrant *LeaseGrantReponse LeaseRevoke *LeaseRevokeResponse Defragment *DefragmentResponse }
type History ¶
type History struct {
// contains filtered or unexported fields
}
func (History) MaxRevision ¶
func (History) Operations ¶
type KeyValue ¶
type KeyValue struct { Key string ValueRevision }
type LeaseGrantReponse ¶
type LeaseGrantReponse struct {
LeaseID int64
}
type LeaseGrantRequest ¶
type LeaseGrantRequest struct {
LeaseID int64
}
type LeaseRevokeRequest ¶
type LeaseRevokeRequest struct {
LeaseID int64
}
type LeaseRevokeResponse ¶
type LeaseRevokeResponse struct{}
type OperationType ¶
type OperationType string
const ( Range OperationType = "range" Put OperationType = "put" Delete OperationType = "delete" )
type RequestType ¶
type RequestType string
const ( Txn RequestType = "txn" LeaseGrant RequestType = "leaseGrant" LeaseRevoke RequestType = "leaseRevoke" Defragment RequestType = "defragment" )
type TxnRequest ¶
type TxnRequest struct { Conditions []EtcdCondition OperationsOnSuccess []EtcdOperation OperationsOnFailure []EtcdOperation }
type TxnResponse ¶
type TxnResponse struct { Failure bool Results []EtcdOperationResult }
type ValueOrHash ¶
func ToValueOrHash ¶
func ToValueOrHash(value string) ValueOrHash
type ValueRevision ¶
type ValueRevision struct { Value ValueOrHash ModRevision int64 }