Documentation ¶
Index ¶
- Constants
- type ATCore
- type AbstractCore
- type DefaultCoordinator
- func (coordinator *DefaultCoordinator) OnCheckMessage(rpcMessage protocal.RpcMessage, session getty.Session)
- func (coordinator *DefaultCoordinator) OnClose(session getty.Session)
- func (coordinator *DefaultCoordinator) OnCron(session getty.Session)
- func (coordinator *DefaultCoordinator) OnError(session getty.Session, err error)
- func (coordinator *DefaultCoordinator) OnMessage(session getty.Session, pkg interface{})
- func (coordinator *DefaultCoordinator) OnOpen(session getty.Session) error
- func (coordinator *DefaultCoordinator) OnRegRmMessage(rpcMessage protocal.RpcMessage, session getty.Session)
- func (coordinator *DefaultCoordinator) OnRegTmMessage(rpcMessage protocal.RpcMessage, session getty.Session)
- func (coordinator *DefaultCoordinator) OnTrxMessage(rpcMessage protocal.RpcMessage, session getty.Session)
- func (coordinator *DefaultCoordinator) SendASyncRequest(session getty.Session, message interface{}) error
- func (coordinator *DefaultCoordinator) SendResponse(request protocal.RpcMessage, session getty.Session, msg interface{})
- func (coordinator *DefaultCoordinator) SendSyncRequest(resourceID string, clientID string, message interface{}) (interface{}, error)
- func (coordinator *DefaultCoordinator) SendSyncRequestByGetty(session getty.Session, message interface{}) (interface{}, error)
- func (coordinator *DefaultCoordinator) SendSyncRequestByGettyWithTimeout(session getty.Session, message interface{}, timeout time.Duration) (interface{}, error)
- func (coordinator *DefaultCoordinator) SendSyncRequestWithTimeout(resourceID string, clientID string, message interface{}, timeout time.Duration) (interface{}, error)
- func (coordinator *DefaultCoordinator) Stop()
- type DefaultCore
- func (core *DefaultCore) Begin(applicationID string, transactionServiceGroup string, name string, ...) (string, error)
- func (core *DefaultCore) BranchRegister(branchType meta.BranchType, resourceID string, clientID string, xid string, ...) (int64, error)
- func (core *DefaultCore) BranchReport(branchType meta.BranchType, xid string, branchID int64, ...) error
- func (core *DefaultCore) Commit(xid string) (meta.GlobalStatus, error)
- func (core *DefaultCore) GetStatus(xid string) (meta.GlobalStatus, error)
- func (core *DefaultCore) GlobalReport(xid string, globalStatus meta.GlobalStatus) (meta.GlobalStatus, error)
- func (core *DefaultCore) LockQuery(branchType meta.BranchType, resourceID string, xid string, lockKeys string) (bool, error)
- func (core *DefaultCore) Rollback(xid string) (meta.GlobalStatus, error)
- type GettySessionManager
- func (manager *GettySessionManager) GetContextFromIdentified(session getty.Session) *RpcContext
- func (manager *GettySessionManager) GetGettySession(resourceID string, clientID string) (getty.Session, error)
- func (manager *GettySessionManager) GetRmSessions() map[string]getty.Session
- func (manager *GettySessionManager) GetRoleFromGettySession(session getty.Session) meta.TransactionRole
- func (manager *GettySessionManager) GetSameClientGettySession(session getty.Session) getty.Session
- func (manager *GettySessionManager) IsRegistered(session getty.Session) bool
- func (manager *GettySessionManager) RegisterRmGettySession(request protocal.RegisterRMRequest, session getty.Session)
- func (manager *GettySessionManager) RegisterTmGettySession(request protocal.RegisterTMRequest, session getty.Session)
- func (manager *GettySessionManager) ReleaseGettySession(session getty.Session)
- type RpcContext
- type RpcContextOption
- func WithRpcContextApplicationID(applicationID string) RpcContextOption
- func WithRpcContextClientID(clientID string) RpcContextOption
- func WithRpcContextClientRole(clientRole meta.TransactionRole) RpcContextOption
- func WithRpcContextResourceSet(resourceSet *model.Set) RpcContextOption
- func WithRpcContextSession(session getty.Session) RpcContextOption
- func WithRpcContextTxServiceGroup(txServiceGroup string) RpcContextOption
- func WithRpcContextVersion(version string) RpcContextOption
- type SAGACore
- type Server
- type ServerMessageListener
- type ServerMessageSender
- type TCInboundHandler
- type TransactionCoordinator
- type TransactionCoordinatorInbound
- type TransactionCoordinatorOutbound
Constants ¶
View Source
const ( RpcRequestTimeout = 30 * time.Second AlwaysRetryBoundary = 0 )
View Source
const ( ClientIDSplitChar = ":" DbkeysSplitChar = "," )
View Source
const (
CronPeriod = 20e9
)
View Source
const IpPortSplitChar = ":"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ATCore ¶
type ATCore struct {
AbstractCore
}
type AbstractCore ¶
type AbstractCore struct {
MessageSender ServerMessageSender
}
*
- +--------------------+-----------------------+--------------------+
- | TC |Method(InBound) |Method(OutBound) |
- +--------------------+-----------------------+--------------------+
- | |Begin | |
- | |BranchRegister | |
- | AT&TCC |BranchReport |branchCommit |
- | (DefaultCore) |Commit |branchRollback |
- | |Rollback | |
- | |GetStatus | |
- +--------------------+-----------------------+--------------------+
- | AT |LockQuery | |
- +--------------------+-----------------------+--------------------+
- | |(GlobalReport) | |
- | |doGlobalCommit | |
- | SAGA |doGlobalRollBack | |
- | |doGlobalReport | |
- +--------------------+-----------------------+--------------------+ *
- 参考 [effective go 之 Embedding](#https://my.oschina.net/pengfeix/blog/109967)
- Go does not provide the typical, type-driven notion of subclassing,
- but it does have the ability to “borrow” pieces of an implementation
- by embedding types within a struct or interface.
- Go 没有像其它面向对象语言中的类继承概念,但是,它可以通过在结构体或者接口中嵌入
- 其它的类型,来使用被嵌入类型的功能。 *
- 原本 JAVA 版 Seata Sever 设计了 Core 接口,AbstractCore 实现该接口,ATCore、
- TccCore、SagaCore 都继承 AbstractCore。使 ATCore、TccCore、SagaCore 每一
- 个类单独拿出来都是 Core 接口的实现。但 Go 版的 Seata 我不打算这样设计。我们将
- Core 接口里定义的接口方法拿出来,如上面的表格所示,一个全局事务的周期分别对应 Begin、
- BranchRegister、BranchReport、Commit、Rollback 接口方法,这些接口方法适用于
- AT 模式和 TCC 模式(SAGA 模式暂不了解,先不考虑)。AT 模式会多一个 LockQuery
- 的接口。另外 OutBound 方向上有两个接口 branchCommit、branchRollback。JAVA 版
- 的设计中 doGlobalCommit、doGlobalRollBack、doGlobalReport 其实是私有方法,
- 这里用首字母小些开头的方法区分。那么 Go 版本的 DefaultCore 设计就出来了(暂不考虑 SAGA),
- DefaultCore 内嵌入 ATCore。 *
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
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)
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{})
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 (*DefaultCoordinator) SendSyncRequestWithTimeout ¶
func (*DefaultCoordinator) Stop ¶
func (coordinator *DefaultCoordinator) Stop()
type DefaultCore ¶
type DefaultCore struct { AbstractCore ATCore SAGACore // contains filtered or unexported fields }
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 ¶
var SessionManager GettySessionManager
func (*GettySessionManager) GetContextFromIdentified ¶
func (manager *GettySessionManager) GetContextFromIdentified(session getty.Session) *RpcContext
func (*GettySessionManager) GetGettySession ¶
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 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 }
func NewCore ¶
func NewCore(sender ServerMessageSender) TransactionCoordinator
type TransactionCoordinatorInbound ¶
type TransactionCoordinatorInbound interface { tm.TransactionManager rm.ResourceManagerOutbound }
type TransactionCoordinatorOutbound ¶
type TransactionCoordinatorOutbound interface {
// contains filtered or unexported methods
}
Source Files ¶
- default_coordinator.go
- default_coordinator_event_listener.go
- default_coordinator_server_message_listener.go
- default_coordinator_server_message_sender.go
- default_coordinator_tc_inbound_handler.go
- default_core.go
- getty_session_manager.go
- rpc_context.go
- server.go
- server_message_listener.go
- server_message_sender.go
- tc_inbound_handler.go
- transaction_coordinator.go
Click to show internal directories.
Click to hide internal directories.