storage

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 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 added in v1.16.4

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 added in v1.16.4

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, condition TransGlobalScanCondition) []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)
	ResetTransGlobalCronTime(global *TransGlobalStore) 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 added in v1.8.2

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

TransGlobalExt defines Header info

type TransGlobalScanCondition added in v1.17.4

type TransGlobalScanCondition struct {
	Status          string
	TransType       string
	CreateTimeStart time.Time
	CreateTimeEnd   time.Time
}

TransGlobalScanCondition contains filter options to scan global trans.

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 added in v1.14.4

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
package boltdb implement the storage for boltdb
package boltdb implement the storage for boltdb
package reds implement the storage for reds
package reds implement the storage for reds
package boltdb implement the storage for sql database
package boltdb implement the storage for sql database

Jump to

Keyboard shortcuts

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