transaction

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2018 License: Apache-2.0 Imports: 7 Imported by: 27

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrResourceNotFound = errors.New("resource not found")

ErrResourceNotFound is error message for missing resource

Functions

This section is empty.

Types

type Filter

type Filter map[string]interface{}

Filter represents db filter

func IDFilter

func IDFilter(ID interface{}) Filter

IDFilter create filter for specific ID

type FuzzyTransaction

type FuzzyTransaction struct {
	Tx Transaction
}

FuzzyTransaction is a fuzzer (a decorator) which returns either the underlying value or a deadlock

func (*FuzzyTransaction) Close

func (ft *FuzzyTransaction) Close() error

Close closes the transaction

func (*FuzzyTransaction) Closed

func (ft *FuzzyTransaction) Closed() bool

Closed returns whether the transaction is closec

func (*FuzzyTransaction) Commit

func (ft *FuzzyTransaction) Commit() error

Commit commits the transaction

func (*FuzzyTransaction) CountContext

func (ft *FuzzyTransaction) CountContext(ctx context.Context, s *schema.Schema, filter Filter) (uint64, error)

func (*FuzzyTransaction) Create

func (ft *FuzzyTransaction) Create(resource *schema.Resource) error

Create creates a new resource

func (*FuzzyTransaction) CreateContext

func (ft *FuzzyTransaction) CreateContext(_ context.Context, resource *schema.Resource) error

func (*FuzzyTransaction) Delete

func (ft *FuzzyTransaction) Delete(s *schema.Schema, resourceID interface{}) error

Delete deletes a resource

func (*FuzzyTransaction) DeleteContext

func (ft *FuzzyTransaction) DeleteContext(_ context.Context, s *schema.Schema, resourceID interface{}) error

func (*FuzzyTransaction) Exec

func (ft *FuzzyTransaction) Exec(query string, args ...interface{}) error

Exec executes a query

func (*FuzzyTransaction) ExecContext

func (ft *FuzzyTransaction) ExecContext(_ context.Context, sql string, args ...interface{}) error

func (*FuzzyTransaction) Fetch

func (ft *FuzzyTransaction) Fetch(s *schema.Schema, filter Filter, options *ViewOptions) (*schema.Resource, error)

Fetch fetches a resource

func (*FuzzyTransaction) FetchContext

func (ft *FuzzyTransaction) FetchContext(_ context.Context, s *schema.Schema, filter Filter, options *ViewOptions) (*schema.Resource, error)

func (*FuzzyTransaction) GetIsolationLevel

func (ft *FuzzyTransaction) GetIsolationLevel() Type

GetIsolationLevel returns the current isolation level

func (*FuzzyTransaction) List

func (ft *FuzzyTransaction) List(s *schema.Schema, filter Filter, options *ViewOptions, pagination *pagination.Paginator) ([]*schema.Resource, uint64, error)

List lists resources

func (*FuzzyTransaction) ListContext

func (ft *FuzzyTransaction) ListContext(_ context.Context, s *schema.Schema, filter Filter, options *ViewOptions, pg *pagination.Paginator) (list []*schema.Resource, total uint64, err error)

func (*FuzzyTransaction) LockFetch

func (ft *FuzzyTransaction) LockFetch(s *schema.Schema, filter Filter, lockPolicy schema.LockPolicy, options *ViewOptions) (*schema.Resource, error)

LockFetch locks and fetches a resource

func (*FuzzyTransaction) LockFetchContext

func (ft *FuzzyTransaction) LockFetchContext(_ context.Context, s *schema.Schema, filter Filter, policy schema.LockPolicy, options *ViewOptions) (*schema.Resource, error)

func (*FuzzyTransaction) LockList

func (ft *FuzzyTransaction) LockList(s *schema.Schema, filter Filter, options *ViewOptions, pagination *pagination.Paginator, lockPolicy schema.LockPolicy) ([]*schema.Resource, uint64, error)

LockList locks and lists resources

func (*FuzzyTransaction) LockListContext

func (ft *FuzzyTransaction) LockListContext(_ context.Context, s *schema.Schema, filter Filter, options *ViewOptions, pg *pagination.Paginator, policy schema.LockPolicy) (list []*schema.Resource, total uint64, err error)

func (*FuzzyTransaction) Query

func (ft *FuzzyTransaction) Query(s *schema.Schema, query string, arguments []interface{}) (list []*schema.Resource, err error)

Query executes a query for a schema

func (*FuzzyTransaction) QueryContext

func (ft *FuzzyTransaction) QueryContext(_ context.Context, s *schema.Schema, query string, arguments []interface{}) (list []*schema.Resource, err error)

func (*FuzzyTransaction) RawTransaction

func (ft *FuzzyTransaction) RawTransaction() *sqlx.Tx

RawTransaction returns a raw sqlx transaction

func (*FuzzyTransaction) StateFetch

func (ft *FuzzyTransaction) StateFetch(s *schema.Schema, filter Filter) (ResourceState, error)

StateFetch fetches a state

func (*FuzzyTransaction) StateFetchContext

func (ft *FuzzyTransaction) StateFetchContext(_ context.Context, s *schema.Schema, filter Filter) (state ResourceState, err error)

func (*FuzzyTransaction) StateUpdate

func (ft *FuzzyTransaction) StateUpdate(resource *schema.Resource, state *ResourceState) error

StateUpdate updates a state

func (*FuzzyTransaction) StateUpdateContext

func (ft *FuzzyTransaction) StateUpdateContext(_ context.Context, resource *schema.Resource, state *ResourceState) error

func (*FuzzyTransaction) Update

func (ft *FuzzyTransaction) Update(resource *schema.Resource) error

Update updates an existing resource

func (*FuzzyTransaction) UpdateContext

func (ft *FuzzyTransaction) UpdateContext(_ context.Context, resource *schema.Resource) error

type ResourceState

type ResourceState struct {
	ConfigVersion int64
	StateVersion  int64
	Error         string
	State         string
	Monitoring    string
}

ResourceState represents the state of a resource

type Transaction

type Transaction interface {
	Create(*schema.Resource) error
	Update(*schema.Resource) error
	StateUpdate(*schema.Resource, *ResourceState) error
	Delete(*schema.Schema, interface{}) error
	Fetch(*schema.Schema, Filter, *ViewOptions) (*schema.Resource, error)
	LockFetch(*schema.Schema, Filter, schema.LockPolicy, *ViewOptions) (*schema.Resource, error)
	StateFetch(*schema.Schema, Filter) (ResourceState, error)
	List(*schema.Schema, Filter, *ViewOptions, *pagination.Paginator) ([]*schema.Resource, uint64, error)
	LockList(*schema.Schema, Filter, *ViewOptions, *pagination.Paginator, schema.LockPolicy) ([]*schema.Resource, uint64, error)
	RawTransaction() *sqlx.Tx
	Query(*schema.Schema, string, []interface{}) (list []*schema.Resource, err error)
	Commit() error
	Exec(query string, args ...interface{}) error
	Close() error
	Closed() bool
	GetIsolationLevel() Type

	CreateContext(context.Context, *schema.Resource) error
	UpdateContext(context.Context, *schema.Resource) error
	StateUpdateContext(context.Context, *schema.Resource, *ResourceState) error
	DeleteContext(context.Context, *schema.Schema, interface{}) error
	FetchContext(context.Context, *schema.Schema, Filter, *ViewOptions) (*schema.Resource, error)
	LockFetchContext(context.Context, *schema.Schema, Filter, schema.LockPolicy, *ViewOptions) (*schema.Resource, error)
	StateFetchContext(context.Context, *schema.Schema, Filter) (ResourceState, error)
	ListContext(context.Context, *schema.Schema, Filter, *ViewOptions, *pagination.Paginator) ([]*schema.Resource, uint64, error)
	LockListContext(context.Context, *schema.Schema, Filter, *ViewOptions, *pagination.Paginator, schema.LockPolicy) ([]*schema.Resource, uint64, error)
	CountContext(context.Context, *schema.Schema, Filter) (uint64, error)
	QueryContext(context.Context, *schema.Schema, string, []interface{}) (list []*schema.Resource, err error)
	ExecContext(ctx context.Context, query string, args ...interface{}) error
}

Transaction is common interface for handling transaction

type TxOptions

type TxOptions struct {
	IsolationLevel Type
}

TxOptions represents transaction options

type Type

type Type string

Type represents transaction types

const (
	//ReadUncommitted is transaction type for READ UNCOMMITTED
	//You don't need to use this for most case
	ReadUncommitted Type = "READ UNCOMMITTED"
	//ReadCommited is transaction type for READ COMMITTED
	//You don't need to use this for most case
	ReadCommited Type = "READ COMMITTED"
	//RepeatableRead is transaction type for REPEATABLE READ
	//This is default value for read request
	RepeatableRead Type = "REPEATABLE READ"
	//Serializable is transaction type for Serializable
	Serializable Type = "SERIALIZABLE"
)

func GetIsolationLevel

func GetIsolationLevel(s *schema.Schema, action string) Type

GetIsolationLevel returns isolation level for an action

type ViewOptions

type ViewOptions struct {
	// Details specifies if all the underlying structures should be
	// returned.
	Details bool
	// Fields limits list output to only showing selected fields.
	Fields []string
}

ViewOptions specifies additional options.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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