Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
G

gotcc

> 编程语言
Open source

基于go实现的tcc分布式事务框架

194 stars0 likes0 views
WebsiteGitHub

About

基于go实现的tcc分布式事务框架

gotcc

gotcc: 纯 golang 实现的 tcc sdk 框架

前言

正所谓“理论先行,实践紧随”. 使用此框架实战前,建议先行梳理 tcc 相关理论知识,做到知行合一、收放自如

sdk 核心能力

实现了 txManager 事务协调器,完成 try-confirm/cancel 二阶段提交流程的组织串联

tcc 技术原理篇与开源实战篇技术博客

理论篇

实战篇

接入 sop

  • 用户需要自行实现事务日志存储模块 TXStore interface,并将其注入到事务协调器 TXManager
…
  • 用户需要自行实现 TCC 组件 TCCComponent,并将其注册到事务协调器 TXManager
go
// tcc 组件
type TCCComponent interface {
	// 返回组件唯一 id
	ID() string
	// 执行第一阶段的 try 操作
	Try(ctx context.Context, req *TCCReq) (*TCCResp, error)
	// 执行第二阶段的 confirm 操作
	Confirm(ctx context.Context, txID string) (*TCCResp, error)
	// 执行第二阶段的 cancel 操作
	Cancel(ctx context.Context, txID string) (*TCCResp, error)
}

使用示例

使用单测示例代码如下. 其中有关于 txStore 模块的实现类示例,同样参见 package example

…

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Go

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言