server

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2020 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RPC_REQUEST_TIMEOUT   = 30 * time.Second
	ALWAYS_RETRY_BOUNDARY = 0
)
View Source
const (
	ClientIdSplitChar = ":"
	DbkeysSplitChar   = ","
)
View Source
const IpPortSplitChar = ":"

Variables

This section is empty.

Functions

func SetServerGrpool

func SetServerGrpool()

Types

type ATCore

type ATCore struct {
	AbstractCore
}

func (*ATCore) LockQuery

func (core *ATCore) LockQuery(branchType meta.BranchType,
	resourceId string,
	xid string,
	lockKeys string) bool

type AbstractCore

type AbstractCore struct {
	MessageSender ServerMessageSender
}

type DefaultCoordinator

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

func NewDefaultCoordinator

func NewDefaultCoordinator(conf config.ServerConfig) *DefaultCoordinator

func (*DefaultCoordinator) OnCheckMessage

func (coordinator *DefaultCoordinator) OnCheckMessage(rpcMessage protocal.RpcMessage, session getty.Session)

func (*DefaultCoordinator) OnClose

func (coordinator *DefaultCoordinator) OnClose(session getty.Session)

func (*DefaultCoordinator) OnCron

func (coordinator *DefaultCoordinator) OnCron(session getty.Session)

func (*DefaultCoordinator) OnError

func (coordinator *DefaultCoordinator) OnError(session getty.Session, err error)

func (*DefaultCoordinator) OnMessage

func (coordinator *DefaultCoordinator) OnMessage(session getty.Session, pkg interface{})

func (*DefaultCoordinator) OnOpen

func (coordinator *DefaultCoordinator) OnOpen(session getty.Session) error

///////////////////////////////////////////////// EventListener /////////////////////////////////////////////////

func (*DefaultCoordinator) OnRegRmMessage

func (coordinator *DefaultCoordinator) OnRegRmMessage(rpcMessage protocal.RpcMessage, session getty.Session)

func (*DefaultCoordinator) OnRegTmMessage

func (coordinator *DefaultCoordinator) OnRegTmMessage(rpcMessage protocal.RpcMessage, session getty.Session)

func (*DefaultCoordinator) OnTrxMessage

func (coordinator *DefaultCoordinator) OnTrxMessage(rpcMessage protocal.RpcMessage, session getty.Session)

/////////////////////////////////////////////////////////// ServerMessageListener ///////////////////////////////////////////////////////////

func (*DefaultCoordinator) SendASyncRequest

func (coordinator *DefaultCoordinator) SendASyncRequest(session getty.Session, message interface{}) error

func (*DefaultCoordinator) SendResponse

func (coordinator *DefaultCoordinator) SendResponse(request protocal.RpcMessage, session getty.Session, msg interface{})

/////////////////////////////////////////////////////////// ServerMessageSender ///////////////////////////////////////////////////////////

func (*DefaultCoordinator) SendSyncRequest

func (coordinator *DefaultCoordinator) SendSyncRequest(resourceId string, clientId string, message interface{}) (interface{}, error)

func (*DefaultCoordinator) SendSyncRequestByGetty

func (coordinator *DefaultCoordinator) SendSyncRequestByGetty(session getty.Session, message interface{}) (interface{}, error)

func (*DefaultCoordinator) SendSyncRequestByGettyWithTimeout

func (coordinator *DefaultCoordinator) SendSyncRequestByGettyWithTimeout(session getty.Session, message interface{}, timeout time.Duration) (interface{}, error)

func (*DefaultCoordinator) SendSyncRequestWithTimeout

func (coordinator *DefaultCoordinator) SendSyncRequestWithTimeout(resourceId string, clientId string, message interface{}, timeout time.Duration) (interface{}, error)

func (*DefaultCoordinator) Stop

func (coordinator *DefaultCoordinator) Stop()

type DefaultCore

type DefaultCore struct {
	AbstractCore
	ATCore
	SAGACore
	// contains filtered or unexported fields
}

func (*DefaultCore) Begin

func (core *DefaultCore) Begin(applicationId string, transactionServiceGroup string, name string, timeout int32) (string, error)

func (*DefaultCore) BranchRegister

func (core *DefaultCore) BranchRegister(branchType meta.BranchType,
	resourceId string,
	clientId string,
	xid string,
	applicationData []byte,
	lockKeys string) (int64, error)

func (*DefaultCore) BranchReport

func (core *DefaultCore) BranchReport(branchType meta.BranchType,
	xid string,
	branchId int64,
	status meta.BranchStatus,
	applicationData []byte) error

func (*DefaultCore) Commit

func (core *DefaultCore) Commit(xid string) (meta.GlobalStatus, error)

func (*DefaultCore) GetStatus

func (core *DefaultCore) GetStatus(xid string) (meta.GlobalStatus, error)

func (*DefaultCore) GlobalReport

func (core *DefaultCore) GlobalReport(xid string, globalStatus meta.GlobalStatus) (meta.GlobalStatus, error)

func (*DefaultCore) LockQuery

func (core *DefaultCore) LockQuery(branchType meta.BranchType, resourceId string, xid string, lockKeys string) (bool, error)

func (*DefaultCore) Rollback

func (core *DefaultCore) Rollback(xid string) (meta.GlobalStatus, error)

type GettySessionManager

type GettySessionManager struct {
	TransactionServiceGroup string
	Version                 string
}
var SessionManager GettySessionManager

func (*GettySessionManager) GetContextFromIdentified

func (manager *GettySessionManager) GetContextFromIdentified(session getty.Session) *RpcContext

func (*GettySessionManager) GetGettySession

func (manager *GettySessionManager) GetGettySession(resourceId string, clientId string) (getty.Session, error)

func (*GettySessionManager) GetRmSessions

func (manager *GettySessionManager) GetRmSessions() map[string]getty.Session

func (*GettySessionManager) GetRoleFromGettySession

func (manager *GettySessionManager) GetRoleFromGettySession(session getty.Session) meta.TransactionRole

func (*GettySessionManager) GetSameClientGettySession

func (manager *GettySessionManager) GetSameClientGettySession(session getty.Session) getty.Session

func (*GettySessionManager) IsRegistered

func (manager *GettySessionManager) IsRegistered(session getty.Session) bool

func (*GettySessionManager) RegisterRmGettySession

func (manager *GettySessionManager) RegisterRmGettySession(request protocal.RegisterRMRequest, session getty.Session)

func (*GettySessionManager) RegisterTmGettySession

func (manager *GettySessionManager) RegisterTmGettySession(request protocal.RegisterTMRequest, session getty.Session)

func (*GettySessionManager) ReleaseGettySession

func (manager *GettySessionManager) ReleaseGettySession(session getty.Session)

type RpcContext

type RpcContext struct {
	Version                 string
	TransactionServiceGroup string
	ClientRole              meta.TransactionRole
	ApplicationId           string
	ClientId                string
	ResourceSets            *model.Set
	Session                 getty.Session
}

func NewRpcContext

func NewRpcContext(opts ...RpcContextOption) *RpcContext

func (*RpcContext) AddResource

func (context *RpcContext) AddResource(resource string)

func (*RpcContext) AddResources

func (context *RpcContext) AddResources(resources *model.Set)

type RpcContextOption

type RpcContextOption func(ctx *RpcContext)

func WithRpcContextApplicationId

func WithRpcContextApplicationId(applicationId string) RpcContextOption

func WithRpcContextClientId

func WithRpcContextClientId(clientId string) RpcContextOption

func WithRpcContextClientRole

func WithRpcContextClientRole(clientRole meta.TransactionRole) RpcContextOption

func WithRpcContextResourceSet

func WithRpcContextResourceSet(resourceSet *model.Set) RpcContextOption

func WithRpcContextSession

func WithRpcContextSession(session getty.Session) RpcContextOption

func WithRpcContextTxServiceGroup

func WithRpcContextTxServiceGroup(txServiceGroup string) RpcContextOption

func WithRpcContextVersion

func WithRpcContextVersion(version string) RpcContextOption

type SAGACore

type SAGACore struct {
	AbstractCore
}

type Server

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

func NewServer

func NewServer() *Server

func (*Server) Start

func (s *Server) Start(addr string)

func (*Server) Stop

func (s *Server) Stop()

type ServerMessageListener

type ServerMessageListener interface {
	OnTrxMessage(rpcMessage protocal.RpcMessage, session getty.Session)

	OnRegRmMessage(request protocal.RpcMessage, session getty.Session)

	OnRegTmMessage(request protocal.RpcMessage, session getty.Session)

	OnCheckMessage(request protocal.RpcMessage, session getty.Session)
}

type ServerMessageSender

type ServerMessageSender interface {

	// Send response.
	SendResponse(request protocal.RpcMessage, session getty.Session, msg interface{})

	// Sync call to RM
	SendSyncRequest(resourceId string, clientId string, message interface{}) (interface{}, error)

	// Sync call to RM with timeout.
	SendSyncRequestWithTimeout(resourceId string, clientId string, message interface{}, timeout time.Duration) (interface{}, error)

	// Send request with response object.
	SendSyncRequestByGetty(session getty.Session, message interface{}) (interface{}, error)

	// Send request with response object.
	SendSyncRequestByGettyWithTimeout(session getty.Session, message interface{}, timeout time.Duration) (interface{}, error)

	// ASync call to RM
	SendASyncRequest(session getty.Session, message interface{}) error
}

type TCInboundHandler

type TCInboundHandler interface {
	// contains filtered or unexported methods
}

type TransactionCoordinator

type TransactionCoordinator interface {
	TransactionCoordinatorInbound
	TransactionCoordinatorOutbound
	// contains filtered or unexported methods
}

type TransactionCoordinatorInbound

type TransactionCoordinatorInbound interface {
	tm.TransactionManager
	rm.ResourceManagerOutbound
}

type TransactionCoordinatorOutbound

type TransactionCoordinatorOutbound interface {
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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