storage

package
v0.0.0-...-431ae09 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("storage: NotFound")

ErrNotFound defines the query item is not found in storage implement.

View Source
var ErrUniqueConflict = errors.New("storage: UniqueKeyConflict")

ErrUniqueConflict defines the item is conflict with unique key in storage implement.

Functions

This section is empty.

Types

type KVStore

type KVStore struct {
	dtmutil.ModelBase
	Cat     string `json:"cat"`
	K       string `json:"k"`
	V       string `json:"v"`
	Version uint64 `json:"version"`
}

KVStore defines Key-Value storage info

func (*KVStore) TableName

func (k *KVStore) TableName() string

TableName TableName

type Store

type Store interface {
	Ping() error
	PopulateData(skipDrop bool)
	FindTransGlobalStore(gid string) *TransGlobalStore
	ScanTransGlobalStores(position *string, limit int64) []TransGlobalStore
	FindBranches(gid string) []TransBranchStore
	UpdateBranches(branches []TransBranchStore, updates []string) (int, error)
	LockGlobalSaveBranches(gid string, status string, branches []TransBranchStore, branchStart int)
	MaySaveNewTrans(global *TransGlobalStore, branches []TransBranchStore) error
	ChangeGlobalStatus(global *TransGlobalStore, newStatus string, updates []string, finished bool)
	TouchCronTime(global *TransGlobalStore, nextCronInterval int64, nextCronTime *time.Time)
	LockOneGlobalTrans(expireIn time.Duration) *TransGlobalStore
	ResetCronTime(after time.Duration, limit int64) (succeedCount int64, hasRemaining bool, err error)
	ScanKV(cat string, position *string, limit int64) []KVStore
	FindKV(cat, key string) []KVStore
	UpdateKV(kv *KVStore) error
	DeleteKV(cat, key string) error
	CreateKV(cat, key, value string) error
}

Store defines storage relevant interface

type TransBranchStore

type TransBranchStore struct {
	dtmutil.ModelBase
	Gid          string     `json:"gid,omitempty"`
	URL          string     `json:"url,omitempty"`
	BinData      []byte     `json:"bin_data,omitempty"`
	BranchID     string     `json:"branch_id,omitempty"`
	Op           string     `json:"op,omitempty"`
	Status       string     `json:"status,omitempty"`
	FinishTime   *time.Time `json:"finish_time,omitempty"`
	RollbackTime *time.Time `json:"rollback_time,omitempty"`
	Error        error      `json:"-" gorm:"-"`
}

TransBranchStore branch transaction

func (*TransBranchStore) String

func (b *TransBranchStore) String() string

func (*TransBranchStore) TableName

func (b *TransBranchStore) TableName() string

TableName TableName

type TransGlobalExt

type TransGlobalExt struct {
	Headers map[string]string `json:"headers,omitempty" gorm:"-"`
}

TransGlobalExt defines Header info

type TransGlobalStore

type TransGlobalStore struct {
	dtmutil.ModelBase
	Gid              string              `json:"gid,omitempty"`
	TransType        string              `json:"trans_type,omitempty"`
	Steps            []map[string]string `json:"steps,omitempty" gorm:"-"`
	Payloads         []string            `json:"payloads,omitempty" gorm:"-"`
	BinPayloads      [][]byte            `json:"-" gorm:"-"`
	Status           string              `json:"status,omitempty"`
	QueryPrepared    string              `json:"query_prepared,omitempty"`
	Protocol         string              `json:"protocol,omitempty"`
	FinishTime       *time.Time          `json:"finish_time,omitempty"`
	RollbackTime     *time.Time          `json:"rollback_time,omitempty"`
	Result           string              `json:"result,omitempty"`
	RollbackReason   string              `json:"rollback_reason,omitempty"`
	Options          string              `json:"options,omitempty"`
	CustomData       string              `json:"custom_data,omitempty"`
	NextCronInterval int64               `json:"next_cron_interval,omitempty"`
	NextCronTime     *time.Time          `json:"next_cron_time,omitempty"`
	Owner            string              `json:"owner,omitempty"`
	Ext              TransGlobalExt      `json:"-" gorm:"-"`
	ExtData          string              `json:"ext_data,omitempty"` // storage of ext. a db field to store many values. like Options
	dtmcli.TransOptions
}

TransGlobalStore defines GlobalStore storage info

func (*TransGlobalStore) IsFinished

func (g *TransGlobalStore) IsFinished() bool

IsFinished return true if status == "failed" || status == "succeed"

func (*TransGlobalStore) String

func (g *TransGlobalStore) String() string

func (*TransGlobalStore) TableName

func (g *TransGlobalStore) TableName() string

TableName TableName

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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