Documentation ¶
Index ¶
- Constants
- Variables
- func BaseAddRoute(app *gin.Engine)
- func BaseAppStartup() *gin.Engine
- func GetBalanceByUID(uid int, store string) int
- func GetRedisAccountKey(uid int) string
- func GrpcStartup() *grpc.Server
- func MongoGet() *mongo.Client
- func MustBarrierFromGin(c *gin.Context) *dtmcli.BranchBarrier
- func MustBarrierFromGrpc(ctx context.Context) *dtmcli.BranchBarrier
- func PopulateDB(skipDrop bool)
- func QsFireRequest() string
- func QsMain()
- func QsStartSvr()
- func RedisGet() *redis.Client
- func RegisterBusiServer(s grpc.ServiceRegistrar, srv BusiServer)
- func ResetXaData()
- func RunGrpc(server *grpc.Server)
- func RunHTTP(app *gin.Engine)
- func SagaAdjustBalance(db dtmcli.DB, uid int, amount int, result string) error
- func SagaMongoAdjustBalance(ctx context.Context, mc *mongo.Client, uid int, amount int, result string) error
- func SetGrpcHeaderForHeadersYes(ctx context.Context, method string, req, reply interface{}, ...) error
- func SetHTTPHeaderForHeadersYes(c *resty.Client, r *resty.Request) error
- func SetMongoBothAccount(amountA int, amountB int)
- func SetRedisBothAccount(amountA int, ammountB int)
- func SetSleepCancelHandler(handler SleepCancelHandler)
- func SetupMongoBarrierAndBusi()
- func Startup() (*gin.Engine, *grpc.Server)
- func TccBarrierTransOutCancel(c *gin.Context) interface{}
- type AutoEmptyString
- type BusiClient
- type BusiReply
- type BusiServer
- type ReqGrpc
- func (*ReqGrpc) Descriptor() ([]byte, []int)deprecated
- func (x *ReqGrpc) GetAmount() int64
- func (x *ReqGrpc) GetTransInResult() string
- func (x *ReqGrpc) GetTransOutResult() string
- func (*ReqGrpc) ProtoMessage()
- func (x *ReqGrpc) ProtoReflect() protoreflect.Message
- func (x *ReqGrpc) Reset()
- func (x *ReqGrpc) String() string
- type ReqHTTP
- type SleepCancelHandler
- type UnimplementedBusiServer
- func (UnimplementedBusiServer) QueryPrepared(context.Context, *ReqGrpc) (*BusiReply, error)
- func (UnimplementedBusiServer) QueryPreparedB(context.Context, *ReqGrpc) (*emptypb.Empty, error)
- func (UnimplementedBusiServer) QueryPreparedRedis(context.Context, *ReqGrpc) (*emptypb.Empty, error)
- func (UnimplementedBusiServer) TransIn(context.Context, *ReqGrpc) (*emptypb.Empty, error)
- func (UnimplementedBusiServer) TransInBSaga(context.Context, *ReqGrpc) (*emptypb.Empty, error)
- func (UnimplementedBusiServer) TransInConfirm(context.Context, *ReqGrpc) (*emptypb.Empty, error)
- func (UnimplementedBusiServer) TransInRedis(context.Context, *ReqGrpc) (*emptypb.Empty, error)
- func (UnimplementedBusiServer) TransInRevert(context.Context, *ReqGrpc) (*emptypb.Empty, error)
- func (UnimplementedBusiServer) TransInRevertBSaga(context.Context, *ReqGrpc) (*emptypb.Empty, error)
- func (UnimplementedBusiServer) TransInRevertRedis(context.Context, *ReqGrpc) (*emptypb.Empty, error)
- func (UnimplementedBusiServer) TransInTcc(context.Context, *ReqGrpc) (*emptypb.Empty, error)
- func (UnimplementedBusiServer) TransInTccNested(context.Context, *ReqGrpc) (*emptypb.Empty, error)
- func (UnimplementedBusiServer) TransInXa(context.Context, *ReqGrpc) (*emptypb.Empty, error)
- func (UnimplementedBusiServer) TransOut(context.Context, *ReqGrpc) (*emptypb.Empty, error)
- func (UnimplementedBusiServer) TransOutBSaga(context.Context, *ReqGrpc) (*emptypb.Empty, error)
- func (UnimplementedBusiServer) TransOutConfirm(context.Context, *ReqGrpc) (*emptypb.Empty, error)
- func (UnimplementedBusiServer) TransOutHeaderNo(context.Context, *ReqGrpc) (*emptypb.Empty, error)
- func (UnimplementedBusiServer) TransOutHeaderYes(context.Context, *ReqGrpc) (*emptypb.Empty, error)
- func (UnimplementedBusiServer) TransOutRedis(context.Context, *ReqGrpc) (*emptypb.Empty, error)
- func (UnimplementedBusiServer) TransOutRevert(context.Context, *ReqGrpc) (*emptypb.Empty, error)
- func (UnimplementedBusiServer) TransOutRevertBSaga(context.Context, *ReqGrpc) (*emptypb.Empty, error)
- func (UnimplementedBusiServer) TransOutRevertRedis(context.Context, *ReqGrpc) (*emptypb.Empty, error)
- func (UnimplementedBusiServer) TransOutTcc(context.Context, *ReqGrpc) (*emptypb.Empty, error)
- func (UnimplementedBusiServer) TransOutXa(context.Context, *ReqGrpc) (*emptypb.Empty, error)
- func (UnimplementedBusiServer) XaNotify(context.Context, *emptypb.Empty) (*emptypb.Empty, error)
- type UnsafeBusiServer
- type UserAccount
Constants ¶
const ( // BusiAPI busi api prefix BusiAPI = "/api/busi" // BusiPort busi server port BusiPort = 8081 // BusiGrpcPort busi server port BusiGrpcPort = 58081 )
const Mongo = "mongo"
Mongo 1
const Redis = "redis"
Redis 1
const TransInUID = 2
TransInUID 2
const TransOutUID = 1
TransOutUID 1
Variables ¶
var Busi = fmt.Sprintf("http://localhost:%d%s", BusiPort, BusiAPI)
Busi busi service url prefix
var BusiConf = dtmcli.DBConf{ Driver: "mysql", Host: StoreHost, Port: 3306, User: "root", }
BusiConf 1
var BusiGrpc = fmt.Sprintf("localhost:%d", BusiGrpcPort)
BusiGrpc busi service grpc address
var BusiJrpcURL = fmt.Sprintf("http://localhost:%d/api/json-rpc?method=", BusiPort)
BusiJrpcURL url prefix for busi
var Busi_ServiceDesc = grpc.ServiceDesc{ ServiceName: "busi.Busi", HandlerType: (*BusiServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "TransIn", Handler: _Busi_TransIn_Handler, }, { MethodName: "TransOut", Handler: _Busi_TransOut_Handler, }, { MethodName: "TransInRevert", Handler: _Busi_TransInRevert_Handler, }, { MethodName: "TransOutRevert", Handler: _Busi_TransOutRevert_Handler, }, { MethodName: "TransInConfirm", Handler: _Busi_TransInConfirm_Handler, }, { MethodName: "TransOutConfirm", Handler: _Busi_TransOutConfirm_Handler, }, { MethodName: "XaNotify", Handler: _Busi_XaNotify_Handler, }, { MethodName: "TransInXa", Handler: _Busi_TransInXa_Handler, }, { MethodName: "TransOutXa", Handler: _Busi_TransOutXa_Handler, }, { MethodName: "TransInTcc", Handler: _Busi_TransInTcc_Handler, }, { MethodName: "TransOutTcc", Handler: _Busi_TransOutTcc_Handler, }, { MethodName: "TransInTccNested", Handler: _Busi_TransInTccNested_Handler, }, { MethodName: "TransInBSaga", Handler: _Busi_TransInBSaga_Handler, }, { MethodName: "TransOutBSaga", Handler: _Busi_TransOutBSaga_Handler, }, { MethodName: "TransInRevertBSaga", Handler: _Busi_TransInRevertBSaga_Handler, }, { MethodName: "TransOutRevertBSaga", Handler: _Busi_TransOutRevertBSaga_Handler, }, { MethodName: "TransOutHeaderYes", Handler: _Busi_TransOutHeaderYes_Handler, }, { MethodName: "TransOutHeaderNo", Handler: _Busi_TransOutHeaderNo_Handler, }, { MethodName: "TransInRedis", Handler: _Busi_TransInRedis_Handler, }, { MethodName: "TransOutRedis", Handler: _Busi_TransOutRedis_Handler, }, { MethodName: "TransInRevertRedis", Handler: _Busi_TransInRevertRedis_Handler, }, { MethodName: "TransOutRevertRedis", Handler: _Busi_TransOutRevertRedis_Handler, }, { MethodName: "QueryPrepared", Handler: _Busi_QueryPrepared_Handler, }, { MethodName: "QueryPreparedB", Handler: _Busi_QueryPreparedB_Handler, }, { MethodName: "QueryPreparedRedis", Handler: _Busi_QueryPreparedRedis_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "test/busi/busi.proto", }
Busi_ServiceDesc is the grpc.ServiceDesc for Busi service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
var DtmClient dtmgpb.DtmClient
DtmClient grpc client for dtm
var File_test_busi_busi_proto protoreflect.FileDescriptor
var MainSwitch mainSwitchType
MainSwitch controls busi success or fail
var StoreHost = "localhost"
StoreHost examples will connect to dtm.pub; tests will connect to localhost
var WebHookResult gin.H
WebHookResult 1
Functions ¶
func GetRedisAccountKey ¶
GetRedisAccountKey return redis key for uid
func MustBarrierFromGin ¶
func MustBarrierFromGin(c *gin.Context) *dtmcli.BranchBarrier
MustBarrierFromGin 1
func MustBarrierFromGrpc ¶
func MustBarrierFromGrpc(ctx context.Context) *dtmcli.BranchBarrier
MustBarrierFromGrpc 1
func RegisterBusiServer ¶
func RegisterBusiServer(s grpc.ServiceRegistrar, srv BusiServer)
func SagaAdjustBalance ¶
SagaAdjustBalance 1
func SagaMongoAdjustBalance ¶
func SagaMongoAdjustBalance(ctx context.Context, mc *mongo.Client, uid int, amount int, result string) error
SagaMongoAdjustBalance 1
func SetGrpcHeaderForHeadersYes ¶
func SetGrpcHeaderForHeadersYes(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error
SetGrpcHeaderForHeadersYes interceptor to set head for HeadersYes
func SetHTTPHeaderForHeadersYes ¶
func SetHTTPHeaderForHeadersYes(c *resty.Client, r *resty.Request) error
SetHTTPHeaderForHeadersYes interceptor to set head for HeadersYes
func SetRedisBothAccount ¶
SetRedisBothAccount 1
func SetSleepCancelHandler ¶
func SetSleepCancelHandler(handler SleepCancelHandler)
SetSleepCancelHandler 1
func TccBarrierTransOutCancel ¶
TccBarrierTransOutCancel will be use in test
Types ¶
type AutoEmptyString ¶
type AutoEmptyString struct {
// contains filtered or unexported fields
}
AutoEmptyString auto reset to empty when used once
func (*AutoEmptyString) Fetch ¶
func (s *AutoEmptyString) Fetch() string
Fetch fetch the stored value, then reset the value to empty
func (*AutoEmptyString) SetOnce ¶
func (s *AutoEmptyString) SetOnce(v string)
SetOnce set a value once
type BusiClient ¶
type BusiClient interface { TransIn(ctx context.Context, in *ReqGrpc, opts ...grpc.CallOption) (*emptypb.Empty, error) TransOut(ctx context.Context, in *ReqGrpc, opts ...grpc.CallOption) (*emptypb.Empty, error) TransInRevert(ctx context.Context, in *ReqGrpc, opts ...grpc.CallOption) (*emptypb.Empty, error) TransOutRevert(ctx context.Context, in *ReqGrpc, opts ...grpc.CallOption) (*emptypb.Empty, error) TransInConfirm(ctx context.Context, in *ReqGrpc, opts ...grpc.CallOption) (*emptypb.Empty, error) TransOutConfirm(ctx context.Context, in *ReqGrpc, opts ...grpc.CallOption) (*emptypb.Empty, error) XaNotify(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) TransInXa(ctx context.Context, in *ReqGrpc, opts ...grpc.CallOption) (*emptypb.Empty, error) TransOutXa(ctx context.Context, in *ReqGrpc, opts ...grpc.CallOption) (*emptypb.Empty, error) TransInTcc(ctx context.Context, in *ReqGrpc, opts ...grpc.CallOption) (*emptypb.Empty, error) TransOutTcc(ctx context.Context, in *ReqGrpc, opts ...grpc.CallOption) (*emptypb.Empty, error) TransInTccNested(ctx context.Context, in *ReqGrpc, opts ...grpc.CallOption) (*emptypb.Empty, error) TransInBSaga(ctx context.Context, in *ReqGrpc, opts ...grpc.CallOption) (*emptypb.Empty, error) TransOutBSaga(ctx context.Context, in *ReqGrpc, opts ...grpc.CallOption) (*emptypb.Empty, error) TransInRevertBSaga(ctx context.Context, in *ReqGrpc, opts ...grpc.CallOption) (*emptypb.Empty, error) TransOutRevertBSaga(ctx context.Context, in *ReqGrpc, opts ...grpc.CallOption) (*emptypb.Empty, error) TransOutHeaderYes(ctx context.Context, in *ReqGrpc, opts ...grpc.CallOption) (*emptypb.Empty, error) TransOutHeaderNo(ctx context.Context, in *ReqGrpc, opts ...grpc.CallOption) (*emptypb.Empty, error) TransInRedis(ctx context.Context, in *ReqGrpc, opts ...grpc.CallOption) (*emptypb.Empty, error) TransOutRedis(ctx context.Context, in *ReqGrpc, opts ...grpc.CallOption) (*emptypb.Empty, error) TransInRevertRedis(ctx context.Context, in *ReqGrpc, opts ...grpc.CallOption) (*emptypb.Empty, error) TransOutRevertRedis(ctx context.Context, in *ReqGrpc, opts ...grpc.CallOption) (*emptypb.Empty, error) QueryPrepared(ctx context.Context, in *ReqGrpc, opts ...grpc.CallOption) (*BusiReply, error) QueryPreparedB(ctx context.Context, in *ReqGrpc, opts ...grpc.CallOption) (*emptypb.Empty, error) QueryPreparedRedis(ctx context.Context, in *ReqGrpc, opts ...grpc.CallOption) (*emptypb.Empty, error) }
BusiClient is the client API for Busi service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
var BusiCli BusiClient
BusiCli grpc client for busi
func NewBusiClient ¶
func NewBusiClient(cc grpc.ClientConnInterface) BusiClient
type BusiReply ¶
type BusiReply struct { Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` // contains filtered or unexported fields }
func (*BusiReply) Descriptor
deprecated
func (*BusiReply) GetMessage ¶
func (*BusiReply) ProtoMessage ¶
func (*BusiReply) ProtoMessage()
func (*BusiReply) ProtoReflect ¶
func (x *BusiReply) ProtoReflect() protoreflect.Message
type BusiServer ¶
type BusiServer interface { TransIn(context.Context, *ReqGrpc) (*emptypb.Empty, error) TransOut(context.Context, *ReqGrpc) (*emptypb.Empty, error) TransInRevert(context.Context, *ReqGrpc) (*emptypb.Empty, error) TransOutRevert(context.Context, *ReqGrpc) (*emptypb.Empty, error) TransInConfirm(context.Context, *ReqGrpc) (*emptypb.Empty, error) TransOutConfirm(context.Context, *ReqGrpc) (*emptypb.Empty, error) XaNotify(context.Context, *emptypb.Empty) (*emptypb.Empty, error) TransInXa(context.Context, *ReqGrpc) (*emptypb.Empty, error) TransOutXa(context.Context, *ReqGrpc) (*emptypb.Empty, error) TransInTcc(context.Context, *ReqGrpc) (*emptypb.Empty, error) TransOutTcc(context.Context, *ReqGrpc) (*emptypb.Empty, error) TransInTccNested(context.Context, *ReqGrpc) (*emptypb.Empty, error) TransInBSaga(context.Context, *ReqGrpc) (*emptypb.Empty, error) TransOutBSaga(context.Context, *ReqGrpc) (*emptypb.Empty, error) TransInRevertBSaga(context.Context, *ReqGrpc) (*emptypb.Empty, error) TransOutRevertBSaga(context.Context, *ReqGrpc) (*emptypb.Empty, error) TransOutHeaderYes(context.Context, *ReqGrpc) (*emptypb.Empty, error) TransOutHeaderNo(context.Context, *ReqGrpc) (*emptypb.Empty, error) TransInRedis(context.Context, *ReqGrpc) (*emptypb.Empty, error) TransOutRedis(context.Context, *ReqGrpc) (*emptypb.Empty, error) TransInRevertRedis(context.Context, *ReqGrpc) (*emptypb.Empty, error) TransOutRevertRedis(context.Context, *ReqGrpc) (*emptypb.Empty, error) QueryPrepared(context.Context, *ReqGrpc) (*BusiReply, error) QueryPreparedB(context.Context, *ReqGrpc) (*emptypb.Empty, error) QueryPreparedRedis(context.Context, *ReqGrpc) (*emptypb.Empty, error) // contains filtered or unexported methods }
BusiServer is the server API for Busi service. All implementations must embed UnimplementedBusiServer for forward compatibility
type ReqGrpc ¶
type ReqGrpc struct { Amount int64 `protobuf:"varint,1,opt,name=Amount,proto3" json:"Amount,omitempty"` TransOutResult string `protobuf:"bytes,2,opt,name=TransOutResult,proto3" json:"TransOutResult,omitempty"` TransInResult string `protobuf:"bytes,3,opt,name=TransInResult,proto3" json:"TransInResult,omitempty"` // contains filtered or unexported fields }
DtmRequest request sent to dtm server
func (*ReqGrpc) Descriptor
deprecated
func (*ReqGrpc) GetTransInResult ¶
func (*ReqGrpc) GetTransOutResult ¶
func (*ReqGrpc) ProtoMessage ¶
func (*ReqGrpc) ProtoMessage()
func (*ReqGrpc) ProtoReflect ¶
func (x *ReqGrpc) ProtoReflect() protoreflect.Message
type ReqHTTP ¶
type ReqHTTP struct { Amount int `json:"amount"` TransInResult string `json:"trans_in_result"` TransOutResult string `json:"trans_out_Result"` Store string `json:"store"` // default mysql, value can be mysql|redis }
ReqHTTP transaction request payload
type SleepCancelHandler ¶
SleepCancelHandler 1
type UnimplementedBusiServer ¶
type UnimplementedBusiServer struct { }
UnimplementedBusiServer must be embedded to have forward compatible implementations.
func (UnimplementedBusiServer) QueryPrepared ¶
func (UnimplementedBusiServer) QueryPreparedB ¶
func (UnimplementedBusiServer) QueryPreparedRedis ¶
func (UnimplementedBusiServer) TransInBSaga ¶
func (UnimplementedBusiServer) TransInConfirm ¶
func (UnimplementedBusiServer) TransInRedis ¶
func (UnimplementedBusiServer) TransInRevert ¶
func (UnimplementedBusiServer) TransInRevertBSaga ¶
func (UnimplementedBusiServer) TransInRevertRedis ¶
func (UnimplementedBusiServer) TransInTcc ¶
func (UnimplementedBusiServer) TransInTccNested ¶
func (UnimplementedBusiServer) TransOutBSaga ¶
func (UnimplementedBusiServer) TransOutConfirm ¶
func (UnimplementedBusiServer) TransOutHeaderNo ¶
func (UnimplementedBusiServer) TransOutHeaderYes ¶
func (UnimplementedBusiServer) TransOutRedis ¶
func (UnimplementedBusiServer) TransOutRevert ¶
func (UnimplementedBusiServer) TransOutRevertBSaga ¶
func (UnimplementedBusiServer) TransOutRevertRedis ¶
func (UnimplementedBusiServer) TransOutTcc ¶
func (UnimplementedBusiServer) TransOutXa ¶
type UnsafeBusiServer ¶
type UnsafeBusiServer interface {
// contains filtered or unexported methods
}
UnsafeBusiServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to BusiServer will result in compilation errors.
type UserAccount ¶
UserAccount 1