rm

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: Apache-2.0 Imports: 12 Imported by: 9

Documentation

Index

Constants

View Source
const (
	TwoPhaseActionTag            = "seataTwoPhaseAction"
	TwoPhaseActionNameTag        = "seataTwoPhaseServiceName"
	TwoPhaseActionPrepareTagVal  = "prepare"
	TwoPhaseActionCommitTagVal   = "commit"
	TwoPhaseActionRollbackTagVal = "rollback"
)

Variables

View Source
var ErrBranchReportResponseFault = errors.New("branch report response fault")
View Source
var (
	TypBusinessContextInterface = reflect.Zero(reflect.TypeOf((*tm.BusinessActionContext)(nil))).Type()
)

Functions

func InitRm

func InitRm(cfg RmConfig)

InitRmClient init seata rm client

func IsTwoPhaseAction

func IsTwoPhaseAction(v interface{}) bool

Types

type BranchRegisterParam

type BranchRegisterParam struct {
	BranchType      branch.BranchType
	ResourceId      string
	ClientId        string
	Xid             string
	ApplicationData string
	LockKeys        string
}

BranchRegisterParam Branch register function param for ResourceManager

type BranchReportParam

type BranchReportParam struct {
	BranchType      branch.BranchType
	Xid             string
	BranchId        int64
	Status          branch.BranchStatus
	ApplicationData string
}

BranchReportParam Branch report function param for ResourceManager

type BranchResource

type BranchResource struct {
	BranchType      branch.BranchType
	Xid             string
	BranchId        int64
	ResourceId      string
	ApplicationData []byte
}

BranchResource contains branch to commit or rollback

type Config

type Config struct {
	AsyncCommitBufferLimit          int        `yaml:"async-commit-buffer-limit" json:"async-commit-buffer-limit,omitempty" koanf:"async-commit-buffer-limit"`
	ReportRetryCount                int        `yaml:"report-retry-count" json:"report-retry-count,omitempty" koanf:"report-retry-count"`
	TableMetaCheckEnable            bool       `yaml:"table-meta-check-enable" json:"table-meta-check-enable" koanf:"table-meta-check-enable"`
	ReportSuccessEnable             bool       `yaml:"report-success-enable" json:"report-success-enable,omitempty" koanf:"report-success-enable"`
	SagaBranchRegisterEnable        bool       `yaml:"saga-branch-register-enable" json:"saga-branch-register-enable,omitempty" koanf:"saga-branch-register-enable"`
	SagaJsonParser                  string     `yaml:"saga-json-parser" json:"saga-json-parser,omitempty" koanf:"saga-json-parser"`
	SagaRetryPersistModeUpdate      bool       `yaml:"saga-retry-persist-mode-update" json:"saga-retry-persist-mode-update,omitempty" koanf:"saga-retry-persist-mode-update"`
	SagaCompensatePersistModeUpdate bool       `` /* 139-byte string literal not displayed */
	TccActionInterceptorOrder       int        `yaml:"tcc-action-interceptor-order" json:"tcc-action-interceptor-order,omitempty" koanf:"tcc-action-interceptor-order"`
	SqlParserType                   string     `yaml:"sql-parser-type" json:"sql-parser-type,omitempty" koanf:"sql-parser-type"`
	LockConfig                      LockConfig `yaml:"lock" json:"lock,omitempty" koanf:"lock"`
}

func (*Config) RegisterFlagsWithPrefix

func (cfg *Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet)

type LockConfig

type LockConfig struct {
	RetryInterval                       time.Duration `yaml:"retry-interval" json:"retry-interval,omitempty" koanf:"retry-interval"`
	RetryTimes                          int           `yaml:"retry-times" json:"retry-times,omitempty" koanf:"retry-times"`
	RetryPolicyBranchRollbackOnConflict bool          `` /* 154-byte string literal not displayed */
}

func (*LockConfig) RegisterFlagsWithPrefix

func (cfg *LockConfig) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet)

type LockQueryParam

type LockQueryParam struct {
	BranchType branch.BranchType
	ResourceId string
	Xid        string
	LockKeys   string
}

LockQueryParam Lock query function param for ResourceManager

type RMRemoting

type RMRemoting struct{}

func GetRMRemotingInstance

func GetRMRemotingInstance() *RMRemoting

func (*RMRemoting) BranchRegister

func (r *RMRemoting) BranchRegister(param BranchRegisterParam) (int64, error)

BranchRegister Register branch of global transaction

func (*RMRemoting) BranchReport

func (r *RMRemoting) BranchReport(param BranchReportParam) error

BranchReport Report status of transaction branch

func (*RMRemoting) LockQuery

func (r *RMRemoting) LockQuery(param LockQueryParam) (bool, error)

LockQuery Query lock status of transaction branch

func (*RMRemoting) RegisterResource

func (r *RMRemoting) RegisterResource(resource Resource) error

type Resource

type Resource interface {
	GetResourceGroupId() string
	GetResourceId() string
	GetBranchType() branch.BranchType
}

Resource that can be managed by Resource Manager and involved into global transaction

type ResourceManager

type ResourceManager interface {
	ResourceManagerInbound
	ResourceManagerOutbound

	// RegisterResource register a resource to be managed by resource manager
	RegisterResource(resource Resource) error
	// UnregisterResource unregister a resource from the Resource Manager
	UnregisterResource(resource Resource) error
	// GetCachedResources get all resources managed by this manager
	GetCachedResources() *sync.Map
	// GetBranchType get the branch type
	GetBranchType() branch.BranchType
}

ResourceManager Resource Manager: common behaviors

type ResourceManagerCache

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

func GetRmCacheInstance

func GetRmCacheInstance() *ResourceManagerCache

func (*ResourceManagerCache) GetResourceManager

func (d *ResourceManagerCache) GetResourceManager(branchType branch.BranchType) ResourceManager

func (*ResourceManagerCache) RegisterResourceManager

func (d *ResourceManagerCache) RegisterResourceManager(resourceManager ResourceManager)

type ResourceManagerGetter

type ResourceManagerGetter interface {
	GetResourceManager(branchType branch.BranchType) ResourceManager
}

type ResourceManagerInbound

type ResourceManagerInbound interface {
	// BranchCommit commit a branch transaction
	BranchCommit(ctx context.Context, resource BranchResource) (branch.BranchStatus, error)
	// BranchRollback rollback a branch transaction
	BranchRollback(ctx context.Context, resource BranchResource) (branch.BranchStatus, error)
}

ResourceManagerInbound Control a branch transaction commit or rollback

type ResourceManagerOutbound

type ResourceManagerOutbound interface {
	// BranchRegister rm register the branch transaction
	BranchRegister(ctx context.Context, param BranchRegisterParam) (int64, error)
	// BranchReport branch transaction report the status
	BranchReport(ctx context.Context, param BranchReportParam) error
	// LockQuery lock query boolean
	LockQuery(ctx context.Context, param LockQueryParam) (bool, error)
}

ResourceManagerOutbound Resource Manager: send outbound request to TC

type RmConfig

type RmConfig struct {
	Config

	ApplicationID  string
	TxServiceGroup string
}

type TwoPhaseAction

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

func ParseTwoPhaseAction

func ParseTwoPhaseAction(v interface{}) (*TwoPhaseAction, error)

func ParseTwoPhaseActionByInterface

func ParseTwoPhaseActionByInterface(v interface{}) (*TwoPhaseAction, error)

func (*TwoPhaseAction) Commit

func (t *TwoPhaseAction) Commit(ctx context.Context, businessActionContext *tm.BusinessActionContext) (bool, error)

func (*TwoPhaseAction) GetActionName

func (t *TwoPhaseAction) GetActionName() string

func (*TwoPhaseAction) GetCommitMethodName

func (t *TwoPhaseAction) GetCommitMethodName() string

func (*TwoPhaseAction) GetPrepareMethodName

func (t *TwoPhaseAction) GetPrepareMethodName() string

func (*TwoPhaseAction) GetRollbackMethodName

func (t *TwoPhaseAction) GetRollbackMethodName() string

func (*TwoPhaseAction) GetTwoPhaseService

func (t *TwoPhaseAction) GetTwoPhaseService() interface{}

func (*TwoPhaseAction) Prepare

func (t *TwoPhaseAction) Prepare(ctx context.Context, params interface{}) (bool, error)

func (*TwoPhaseAction) Rollback

func (t *TwoPhaseAction) Rollback(ctx context.Context, businessActionContext *tm.BusinessActionContext) (bool, error)

type TwoPhaseInterface

type TwoPhaseInterface interface {
	Prepare(ctx context.Context, params interface{}) (bool, error)
	Commit(ctx context.Context, businessActionContext *tm.BusinessActionContext) (bool, error)
	Rollback(ctx context.Context, businessActionContext *tm.BusinessActionContext) (bool, error)
	GetActionName() string
}

Jump to

Keyboard shortcuts

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