vbank

package module
v0.0.0-...-dfd9850 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PKTypeInt     = "int"
	PKTypeDecimal = "decimal"
	PKTypeString  = "string"
)

primary key types

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountState

type AccountState struct {
	ID      int
	Balance float64
}

AccountState ...

type BankState

type BankState struct {
	Accounts []AccountState
}

BankState is the state of the test case.

func (*BankState) Clone

func (bs *BankState) Clone() *BankState

Clone clones the state.

func (*BankState) String

func (bs *BankState) String() string

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client implements the core.Client interface.

func (*Client) DumpState

func (c *Client) DumpState(ctx context.Context) (interface{}, error)

DumpState implements the core.Client interface.

func (*Client) Invoke

func (c *Client) Invoke(ctx context.Context, node cluster.ClientNode, r interface{}) core.UnknownResponse

Invoke implements the core.Client interface.

func (*Client) NextRequest

func (c *Client) NextRequest() interface{}

NextRequest implements the core.Client interface.

func (*Client) SetUp

func (c *Client) SetUp(ctx context.Context, _ []cluster.Node, clientNodes []cluster.ClientNode, idx int) error

SetUp implements the core.Client interface.

func (*Client) TearDown

func (c *Client) TearDown(ctx context.Context, nodes []cluster.ClientNode, idx int) error

TearDown implements the core.Client interface.

type ClientCreator

type ClientCreator struct {
	// contains filtered or unexported fields
}

ClientCreator creates a test client.

func NewClientCreator

func NewClientCreator(cfg *Config) *ClientCreator

NewClientCreator creates a new ClientCreator.

func (*ClientCreator) Create

func (cc *ClientCreator) Create(node cluster.ClientNode) core.Client

Create creates a Client.

type Config

type Config struct {
	// PKType
	PKType string
	// When Partition is set to true, we use multiple partition for multiple account instead of multiple table.
	Partition bool
	// When Range is set to true, we use range condition instead of equal condition which
	// leads to coprocessor request instead of point get request.
	Range bool
	// When ReadCommitted is set to true, we use read-committed isolation level for pessimistic transaction.
	ReadCommitted bool
	// When UpdateInPlace is set to true, we update with `set balance = balance - @amount`, otherwise we select for update first,
	// Then update by `set balance = @new_balance`.
	UpdateInPlace bool
	// ConnParams are parameters passed to the mysql-driver, see https://github.com/go-sql-driver/mysql#parameters .
	ConnParams string
}

Config is the config of the test case.

type CreateResult

type CreateResult struct {
	NewID   int
	Balance float64
}

CreateResult ...

func (*CreateResult) String

func (cr *CreateResult) String() string

type DeleteResult

type DeleteResult struct {
	VictimID int
	Balance  float64
	Aborted  bool
}

DeleteResult ...

func (*DeleteResult) String

func (dr *DeleteResult) String() string

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model implements the core.Model interface.

func (*Model) Equal

func (m *Model) Equal(state1, state2 interface{}) bool

Equal implements the core.Model interface.

func (*Model) Init

func (m *Model) Init() interface{}

Init implements the core.Model interface.

func (*Model) Name

func (m *Model) Name() string

Name implements the core.Model interface.

func (*Model) Prepare

func (m *Model) Prepare(state interface{})

Prepare implements the core.Model interface.

func (*Model) Step

func (m *Model) Step(state interface{}, input interface{}, output interface{}) (bool, interface{})

Step implements the core.Model interface.

type Parser

type Parser struct{}

Parser implements the core.Parser interface.

func (Parser) OnNoopResponse

func (p Parser) OnNoopResponse() interface{}

OnNoopResponse implements the core.Parser interface.

func (Parser) OnRequest

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

OnRequest implements the core.Parser interface.

func (Parser) OnResponse

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

OnResponse implements the core.Parser interface.

func (Parser) OnState

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

OnState implements the core.Parser interface.

type Response

type Response struct {
	ReqType        VBReqType
	TS             uint64
	ReadResult     *BankState
	CreateResult   *CreateResult
	DeleteResult   *DeleteResult
	TransferResult *TransferResult
	OK             bool
	Err            string
}

Response ...

func (*Response) IsUnknown

func (r *Response) IsUnknown() bool

IsUnknown implements UnknownResponse interface

func (*Response) String

func (r *Response) String() string

type TransferResult

type TransferResult struct {
	Aborted     bool
	FromID      int
	FromBalance float64
	ToID        int
	ToBalance   float64
	Amount      float64
}

TransferResult ...

func (*TransferResult) String

func (tr *TransferResult) String() string

type VBReqType

type VBReqType int

VBReqType ...

func (VBReqType) String

func (rt VBReqType) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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