dtmgrpc

package module
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2022 License: BSD-3-Clause Imports: 14 Imported by: 3

README

English | 简体中文

dtmgrpc

dtmgrpc is the http client sdk for dtm, a distributed transaction framework.

The code of this library is fully synchronised with the dtmgrpc directory under dtm. There will be very few dependencies associated with the current dtmgrpc and smaller size for the final binary file.

For detailed documentation and usage, please refer to dtm

a complete sample

dtmgrpc-go-sample

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddUnaryInterceptor added in v1.8.2

func AddUnaryInterceptor(interceptor grpc.UnaryClientInterceptor)

AddUnaryInterceptor adds grpc.UnaryClientInterceptor

func BarrierFromGrpc

func BarrierFromGrpc(ctx context.Context) (*dtmcli.BranchBarrier, error)

BarrierFromGrpc generate a Barrier from grpc context

func DtmError2GrpcError added in v1.10.0

func DtmError2GrpcError(res interface{}) error

DtmError2GrpcError translate dtm error to grpc error

func GrpcError2DtmError added in v1.11.1

func GrpcError2DtmError(err error) error

GrpcError2DtmError translate grpc error to dtm error

func MustGenGid

func MustGenGid(grpcServer string) string

MustGenGid must gen a gid from grpcServer

func TccGlobalTransaction

func TccGlobalTransaction(dtm string, gid string, tccFunc TccGlobalFunc) (rerr error)

TccGlobalTransaction begin a tcc global transaction dtm dtm server url gid global transaction id tccFunc tcc busi func, define the transaction logic

func TccGlobalTransaction2 added in v1.8.4

func TccGlobalTransaction2(dtm string, gid string, custom func(*TccGrpc), tccFunc TccGlobalFunc) (rerr error)

TccGlobalTransaction2 new version of TccGlobalTransaction

func UseDriver

func UseDriver(driverName string) error

UseDriver use the specified driver to handle grpc urls

func XaGlobalTransaction added in v1.13.0

func XaGlobalTransaction(server string, gid string, xaFunc XaGrpcGlobalFunc) error

XaGlobalTransaction start a xa global transaction

func XaGlobalTransaction2 added in v1.13.0

func XaGlobalTransaction2(server string, gid string, custom func(*XaGrpc), xaFunc XaGrpcGlobalFunc) error

XaGlobalTransaction2 new version of XaGlobalTransaction. support custom

func XaLocalTransaction added in v1.13.0

func XaLocalTransaction(ctx context.Context, dbConf dtmcli.DBConf, xaFunc XaGrpcLocalFunc) error

XaLocalTransaction start a xa local transaction

Types

type MsgGrpc

type MsgGrpc struct {
	dtmcli.Msg
}

MsgGrpc reliable msg type

func NewMsgGrpc

func NewMsgGrpc(server string, gid string) *MsgGrpc

NewMsgGrpc create new msg

func (*MsgGrpc) Add

func (s *MsgGrpc) Add(action string, msg proto.Message) *MsgGrpc

Add add a new step

func (*MsgGrpc) DoAndSubmit added in v1.11.1

func (s *MsgGrpc) DoAndSubmit(queryPrepared string, busiCall func(bb *dtmcli.BranchBarrier) error) error

DoAndSubmit one method for the entire prepare->busi->submit the error returned by busiCall will be returned if busiCall return ErrFailure, then abort is called directly if busiCall return not nil error other than ErrFailure, then DoAndSubmit will call queryPrepared to get the result

func (*MsgGrpc) DoAndSubmitDB added in v1.11.1

func (s *MsgGrpc) DoAndSubmitDB(queryPrepared string, db *sql.DB, busiCall dtmcli.BarrierBusiFunc) error

DoAndSubmitDB short method for Do on db type. please see DoAndSubmit

func (*MsgGrpc) Prepare

func (s *MsgGrpc) Prepare(queryPrepared string) error

Prepare prepare the msg, msg will later be submitted

func (*MsgGrpc) SetDelay added in v1.13.0

func (s *MsgGrpc) SetDelay(delay uint64) *MsgGrpc

SetDelay delay call branch, unit second

func (*MsgGrpc) Submit

func (s *MsgGrpc) Submit() error

Submit submit the msg

type SagaGrpc

type SagaGrpc struct {
	dtmcli.Saga
}

SagaGrpc struct of saga

func NewSagaGrpc

func NewSagaGrpc(server string, gid string) *SagaGrpc

NewSagaGrpc create a saga

func (*SagaGrpc) Add

func (s *SagaGrpc) Add(action string, compensate string, payload proto.Message) *SagaGrpc

Add add a saga step

func (*SagaGrpc) AddBranchOrder

func (s *SagaGrpc) AddBranchOrder(branch int, preBranches []int) *SagaGrpc

AddBranchOrder specify that branch should be after preBranches. branch should is larger than all the element in preBranches

func (*SagaGrpc) EnableConcurrent

func (s *SagaGrpc) EnableConcurrent() *SagaGrpc

EnableConcurrent enable the concurrent exec of sub trans

func (*SagaGrpc) Submit

func (s *SagaGrpc) Submit() error

Submit submit the saga trans

type TccGlobalFunc

type TccGlobalFunc func(tcc *TccGrpc) error

TccGlobalFunc type of global tcc call

type TccGrpc

type TccGrpc struct {
	dtmimp.TransBase
}

TccGrpc struct of tcc

func TccFromGrpc

func TccFromGrpc(ctx context.Context) (*TccGrpc, error)

TccFromGrpc tcc from request info

func (*TccGrpc) CallBranch

func (t *TccGrpc) CallBranch(busiMsg proto.Message, tryURL string, confirmURL string, cancelURL string, reply interface{}) error

CallBranch call a tcc branch

type XaGrpc

type XaGrpc struct {
	dtmimp.TransBase
	Phase2URL string
}

XaGrpc xa transaction

func XaGrpcFromRequest

func XaGrpcFromRequest(ctx context.Context) (*XaGrpc, error)

XaGrpcFromRequest construct xa info from request

func (*XaGrpc) CallBranch

func (x *XaGrpc) CallBranch(msg proto.Message, url string, reply interface{}) error

CallBranch call a xa branch

type XaGrpcGlobalFunc

type XaGrpcGlobalFunc func(xa *XaGrpc) error

XaGrpcGlobalFunc type of xa global function

type XaGrpcLocalFunc

type XaGrpcLocalFunc func(db *sql.DB, xa *XaGrpc) error

XaGrpcLocalFunc type of xa local function

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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