core

package
v0.0.0-...-14ddd16 Latest Latest
Warning

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

Go to latest
Published: May 9, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ManualAPI

type ManualAPI interface {
	// Commit commit global transaction
	Commit(fid, gid uint64) error

	// Rollback rollback global transaction
	Rollback(fid, gid uint64) error
}

ManualAPI manual api

func NewcellManualAPI

func NewcellManualAPI(opts ...cedis.Option) ManualAPI

NewcellManualAPI returns query API

type Option

type Option func(*options)

Option option

func WithACKTimeout

func WithACKTimeout(value time.Duration) Option

WithACKTimeout set ackTimeout times

func WithCell

func WithCell(value *cedis.Cedis) Option

WithCell set cell options

func WithCommitIfAllBranchSucceedInPhaseOne

func WithCommitIfAllBranchSucceedInPhaseOne(value bool) Option

WithCommitIfAllBranchSucceedInPhaseOne set commitIfAllBranchSucceedInPhaseOne

func WithConcurrency

func WithConcurrency(concurrency int) Option

WithConcurrency set concurrcy

func WithElector

func WithElector(value election.Elector) Option

WithElector set elector

func WithElectorOptions

func WithElectorOptions(value ...election.Option) Option

WithElectorOptions set leader elector options

func WithIDGenerator

func WithIDGenerator(value id.Generator) Option

WithIDGenerator set id generator

func WithResourceLock

func WithResourceLock(lock lock.ResourceLock) Option

WithResourceLock set resource lock value

func WithRetries

func WithRetries(value int) Option

WithRetries set retries times

func WithStatusChangeAware

func WithStatusChangeAware(becomeLeader, becomeFollower func()) Option

WithStatusChangeAware set leader follow handler

func WithTransactionTimeout

func WithTransactionTimeout(value time.Duration) Option

WithTransactionTimeout set transaction timeout

type QueryAPI

type QueryAPI interface {
	// CountTransactions returns transaction count
	CountTransactions(fid uint64) (uint64, error)

	// Transactions returns a transaction list
	Transactions(fid uint64, query meta.Query) ([]meta.GlobalTransaction, error)

	// Transaction returns the spec transaction
	Transaction(fid uint64, gid uint64) (*meta.GlobalTransaction, error)
}

QueryAPI query api

func NewCellQueryAPI

func NewCellQueryAPI(opts ...cedis.Option) QueryAPI

NewCellQueryAPI returns query API

type TransactionCoordinator

type TransactionCoordinator interface {
	// Stop stop tc
	Stop()

	// ActiveGCount returns number of the actived global transaction
	ActiveGCount() int

	// IsLeader returns true if current node is leader
	IsLeader() bool

	// ChangeLeaderTo change leader to the spec peer
	ChangeLeaderTo(id uint64)

	// CurrentLeader returns the current leader
	CurrentLeader() (uint64, error)

	// RegistryGlobalTransaction registry a global transaction
	RegistryGlobalTransaction(value meta.CreateGlobalTransaction, cb func(uint64, error))

	// RegistryBranchTransaction registry a branch transaction
	RegistryBranchTransaction(value meta.CreateBranchTransaction, cb func(uint64, error))

	// ReportBranchTransactionStatus report branch transaction status, phase one
	ReportBranchTransactionStatus(value meta.ReportBranchStatus, cb func(error))

	// GlobalTransactionStatus return global status
	GlobalTransactionStatus(gid uint64, cb func(meta.GlobalStatus, error))

	// CommitGlobalTransaction commit global
	CommitGlobalTransaction(gid uint64, who string, cb func(meta.GlobalStatus, error))

	// RollbackGlobalTransaction rollback global
	RollbackGlobalTransaction(gid uint64, who string, cb func(meta.GlobalStatus, error))

	// BranchTransactionNotifyACK branch transaction commit/rollback result ack
	BranchTransactionNotifyACK(ack meta.NotifyACK)

	// Lockable returns true if can be locked
	Lockable(resource string, gid uint64, lockKeys []meta.LockKey, cb func(bool, error))
}

TransactionCoordinator Taas transaction manager

func NewCellTransactionCoordinator

func NewCellTransactionCoordinator(id, peerID uint64, trans transport.Transport, opts ...Option) (TransactionCoordinator, error)

NewCellTransactionCoordinator create a transaction coordinator used Elasticell with meta storage

Jump to

Keyboard shortcuts

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