work

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnCheck

func ConnCheck(db *sql.DB) error

Types

type CompositeWork

type CompositeWork interface {
	// DoNext executes the next sub part of the work. It returns false when all sub parts are done
	DoNext() (hasMore bool, err error)
}

CompositeWork represents a unit work that has multiple sub parts

func NewDeleteRowWork

func NewDeleteRowWork(id int, rp *RunParams, recRange *intgen.Range) CompositeWork

func NewDeleteTxnWork

func NewDeleteTxnWork(id int, rp *RunParams, recRange *intgen.Range) CompositeWork

func NewInsertRowWork

func NewInsertRowWork(id int, rp *RunParams, recRange *intgen.Range) CompositeWork

func NewInsertTxnWork

func NewInsertTxnWork(id int, rp *RunParams, recRange *intgen.Range) CompositeWork

func NewSelectByPkRowWork

func NewSelectByPkRowWork(id int, rp *RunParams, recRange *intgen.Range) CompositeWork

func NewSelectByPkTxnWork

func NewSelectByPkTxnWork(id int, rp *RunParams, recRange *intgen.Range) CompositeWork

func NewSelectByUkRowWork

func NewSelectByUkRowWork(id int, rp *RunParams, recRange *intgen.Range) CompositeWork

func NewSelectByUkTxnWork

func NewSelectByUkTxnWork(id int, rp *RunParams, recRange *intgen.Range) CompositeWork

func NewUpdateRowWork

func NewUpdateRowWork(id int, rp *RunParams, recRange *intgen.Range) CompositeWork

func NewUpdateTxnWork

func NewUpdateTxnWork(id int, rp *RunParams, recRange *intgen.Range) CompositeWork

type CompositeWorkFactory

type CompositeWorkFactory func(id int, rp *RunParams, recRange *intgen.Range) CompositeWork

type DeleteRowWork

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

DeleteRowWork is a CompositeWork that deletes one row each time DoNext is called

Since the same record cannot be deleted twice, the DeleteRowWork takes a slice of row indexes which has the indexes of the rows (as per the DataGen) that this instance should delete. The creator of DeleteRowWork must ensure that it is giving mutually exclusive sets of row indexes to the different DeleteRowWork instances.

This class is Thread Safe. DoNext can be invoked from multiple threads

func (*DeleteRowWork) DoNext

func (w *DeleteRowWork) DoNext() (bool, error)

DoNext deletes a single record, directly without transactions Returns true as long as there are more rows to be deleteed Returns false (indicating done) once delete has been attempted for all the rows that this DeleteRowWork has been assigned

type DeleteTxnWork

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

DeleteTxnWork is a CompositeWork that deletes one botch of rows using a transaction each time DoNext is called

Since the same record cannot be deleteed twice, the DeleteRowWork takes a slice of row indexes which has the indexes of the rows (as per the DataGen) that this instance should delete. The creator of DeleteRowWork must ensure that it is giving mutually exclusive sets of row indexes to the different DeleteRowWork instances.

This class is Thread Safe. DoNext can be invoked from multiple threads

func (*DeleteTxnWork) DoNext

func (w *DeleteTxnWork) DoNext() (bool, error)

DoNext deletes a batch of records with transaction Returns true as long as there are more rows to be deleted Returns false (indicating done) once delete has been attempted for all the rows that this DeleteRowWork has been assigned

type InsertRowWork

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

InsertRowWork is a CompositeWork that inserts one row each time DoNext is called

Since the same record cannot be inserted twice, the InsertRowWork takes a slice of row indexes which has the indexes of the rows (as per the DataGen) that this instance should insert. The creator of InsertRowWork must ensure that it is giving mutually exclusive sets of row indexes to the different InsertRowWork instances.

This class is Thread Safe. DoNext can be invoked from multiple threads

func (*InsertRowWork) DoNext

func (w *InsertRowWork) DoNext() (bool, error)

DoNext inserts a single record, directly without transactions Returns true as long as there are more rows to be inserted Returns false (indicating done) once insert has been attempted for all the rows that this InsertRowWork has been assigned

type InsertTxnWork

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

InsertTxnWork is a CompositeWork that inserts one botch of rows using a transaction each time DoNext is called

Since the same record cannot be inserted twice, the InsertRowWork takes a slice of row indexes which has the indexes of the rows (as per the DataGen) that this instance should insert. The creator of InsertRowWork must ensure that it is giving mutually exclusive sets of row indexes to the different InsertRowWork instances.

This class is Thread Safe. DoNext can be invoked from multiple threads

func (*InsertTxnWork) DoNext

func (w *InsertTxnWork) DoNext() (bool, error)

DoNext inserts a batch of records with transaction Returns true as long as there are more rows to be inserted Returns false (indicating done) once insert has been attempted for all the rows that this InsertRowWork has been assigned

type RunParams

type RunParams struct {
	DB          *sql.DB
	DataGen     *datagen.DataGen
	Metrics     *metrics.DiligentMetrics
	Table       string
	Concurrency int
	EnableTxn   bool
	BatchSize   int
	DurationSec int
}

type SelectByPkRowWork

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

SelectByPkRowWork is a CompositeWork that selects one row by primary key each time DoNext is called This class is Thread Safe. DoNext can be invoked from multiple threads

func (*SelectByPkRowWork) DoNext

func (w *SelectByPkRowWork) DoNext() (bool, error)

DoNext inserts a single record, directly without transactions This DoNext method never returns false (done) as records can be selected forever

type SelectByPkTxnWork

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

func (*SelectByPkTxnWork) DoNext

func (w *SelectByPkTxnWork) DoNext() (bool, error)

DoNext selects a batch of records with transaction

type SelectByUkRowWork

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

SelectByUkRowWork is a CompositeWork that selects one row by unique key each time DoNext is called This class is Thread Safe. DoNext can be invoked from multiple threads

func (*SelectByUkRowWork) DoNext

func (w *SelectByUkRowWork) DoNext() (bool, error)

DoNext inserts a single record, directly without transactions This DoNext method never returns false (done) as records can be selected forever

type SelectByUkTxnWork

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

func (*SelectByUkTxnWork) DoNext

func (w *SelectByUkTxnWork) DoNext() (bool, error)

DoNext selects a batch of records with transaction

type UpdateRowWork

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

UpdateRowWork is a CompositeWork that updates one row each time DoNext is called This class is Thread Safe. DoNext can be invoked from multiple threads

func (*UpdateRowWork) DoNext

func (w *UpdateRowWork) DoNext() (bool, error)

DoNext updates a single record, directly without transactions This DoNext method never returns false (done) as records can be updated forever

type UpdateTxnWork

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

func (*UpdateTxnWork) DoNext

func (w *UpdateTxnWork) DoNext() (bool, error)

DoNext updates a batch of records with transaction This DoNext method never returns false (done) as records can be updated forever

type WorkAllocationStrategy

type WorkAllocationStrategy int
const (
	Partitioned WorkAllocationStrategy = iota
	Shared
)

type Worker

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

func NewWorker

func NewWorker(id int, rp *RunParams, work CompositeWork) *Worker

func (*Worker) Run

func (w *Worker) Run(ctx context.Context, ch chan *WorkerResult)

type WorkerResult added in v0.2.0

type WorkerResult struct {
	FatalError     bool
	NonFatalErrors int
}

type Workload

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

func NewDeleteRowWorkload

func NewDeleteRowWorkload(assignedRange *intgen.Range, rp *RunParams) *Workload

func NewDeleteTxnWorkload

func NewDeleteTxnWorkload(assignedRange *intgen.Range, rp *RunParams) *Workload

func NewInsertRowWorkload

func NewInsertRowWorkload(assignedRange *intgen.Range, rp *RunParams) *Workload

func NewInsertTxnWorkload

func NewInsertTxnWorkload(assignedRange *intgen.Range, rp *RunParams) *Workload

func NewSelectByPkRowWorkload

func NewSelectByPkRowWorkload(assignedRange *intgen.Range, rp *RunParams) *Workload

func NewSelectByPkTxnWorkload

func NewSelectByPkTxnWorkload(assignedRange *intgen.Range, rp *RunParams) *Workload

func NewSelectByUkRowWorkload

func NewSelectByUkRowWorkload(assignedRange *intgen.Range, rp *RunParams) *Workload

func NewSelectByUkTxnWorkload

func NewSelectByUkTxnWorkload(assignedRange *intgen.Range, rp *RunParams) *Workload

func NewUpdateRowWorkload

func NewUpdateRowWorkload(assignedRange *intgen.Range, rp *RunParams) *Workload

func NewUpdateTxnWorkload

func NewUpdateTxnWorkload(assignedRange *intgen.Range, rp *RunParams) *Workload

func NewWorkload

func NewWorkload(name string, rp *RunParams) *Workload

func (*Workload) Abort added in v0.2.0

func (wl *Workload) Abort()

func (*Workload) CreateWorkerWithWork

func (wl *Workload) CreateWorkerWithWork(work CompositeWork)

func (*Workload) Start

func (wl *Workload) Start(duration time.Duration, ch chan *WorkloadResult)

type WorkloadResult added in v0.2.0

type WorkloadResult struct {
	IsAborted      bool
	FatalErrors    int
	NonFatalErrors int
}

Jump to

Keyboard shortcuts

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