[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-5019":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":18,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":24,"hasPages":22,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":43,"readmeContent":44,"aiSummary":45,"trendingCount":16,"starSnapshotCount":16,"syncStatus":46,"lastSyncTime":47,"discoverSource":48},5019,"dtm","dtm-labs\u002Fdtm","dtm-labs","A distributed transaction framework, supports workflow, saga, tcc, xa, 2-phase message, outbox patterns, supports many languages.","http:\u002F\u002Fd.dtm.pub",null,"Go",10881,1001,100,76,0,1,4,18,44,"BSD 3-Clause \"New\" or \"Revised\" License",false,"main",true,[26,27,28,29,30,5,31,32,33,34,35,36,37,38,39,40,41,42],"cadence","csharp","database","distributed","distributed-transactions","go","golang","java","microservice","outbox","saga","seata","tcc","transaction","transactions","workflow-engine","xa","2026-06-12 02:01:07","![license](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Flicense\u002Fdtm-labs\u002Fdtm)\n![Build Status](https:\u002F\u002Fgithub.com\u002Fdtm-labs\u002Fdtm\u002Factions\u002Fworkflows\u002Ftests.yml\u002Fbadge.svg?branch=main)\n[![codecov](https:\u002F\u002Fcodecov.io\u002Fgh\u002Fdtm-labs\u002Fdtm\u002Fbranch\u002Fmain\u002Fgraph\u002Fbadge.svg?token=UKKEYQLP3F)](https:\u002F\u002Fcodecov.io\u002Fgh\u002Fdtm-labs\u002Fdtm)\n[![Go Report Card](https:\u002F\u002Fgoreportcard.com\u002Fbadge\u002Fgithub.com\u002Fdtm-labs\u002Fdtm)](https:\u002F\u002Fgoreportcard.com\u002Freport\u002Fgithub.com\u002Fdtm-labs\u002Fdtm)\n[![Go Reference](https:\u002F\u002Fpkg.go.dev\u002Fbadge\u002Fgithub.com\u002Fdtm-labs\u002Fdtm.svg)](https:\u002F\u002Fpkg.go.dev\u002Fgithub.com\u002Fdtm-labs\u002Fdtm)\n[![Mentioned in Awesome Go](https:\u002F\u002Fawesome.re\u002Fmentioned-badge-flat.svg)](https:\u002F\u002Fgithub.com\u002Favelino\u002Fawesome-go#database)\n\nEnglish | [简体中文](https:\u002F\u002Fgithub.com\u002Fdtm-labs\u002Fdtm\u002Fblob\u002Fmain\u002Fhelper\u002FREADME-cn.md)\n\n# Distributed Transactions Manager\n\n## What is DTM\n\nDTM is a distributed transaction framework which provides cross-service eventual data consistency. It provides saga, tcc, xa, 2-phase message, outbox, workflow patterns for a variety of application scenarios. It also supports multiple languages and multiple store engine to form up a transaction as following:\n\n\u003Cimg alt=\"function-picture\" src=\"https:\u002F\u002Fen.dtm.pub\u002Fassets\u002Ffunction.7d5618f8.png\" height=250 \u002F>\n\n## Who's using DTM (partial)\n\n[Tencent](https:\u002F\u002Fen.dtm.pub\u002Fother\u002Fusing.html#tencent)\n\n[Bytedance](https:\u002F\u002Fen.dtm.pub\u002Fother\u002Fusing.html#bytedance)\n\n[Ivydad](https:\u002F\u002Fen.dtm.pub\u002Fother\u002Fusing.html#ivydad)\n\n[More](https:\u002F\u002Fen.dtm.pub\u002Fother\u002Fusing.html)\n\n## Features\n* Support for multiple transaction modes: SAGA, TCC, XA, Workflow, Outbox\n* Multiple languages support: SDK for Go, Java, PHP, C#, Python, Nodejs\n* Better Outbox: 2-phase messages, a more elegant solution than Outbox, support multi-databases\n* Multiple database transaction support: MySQL\u002FMariaDB, Redis, MongoDB, Postgres, TDSQL, etc.\n* Support for multiple storage engines: MySQL\u002FMariaDB (common), Redis (high performance), BoltDB (dev&test), MongoDB (under planning)\n* Support for multiple microservices architectures: [go-zero](https:\u002F\u002Fgithub.com\u002Fzeromicro\u002Fgo-zero), go-kratos\u002Fkratos, polarismesh\u002Fpolaris\n* Support for high availability and easy horizontal scaling\n\n## Application scenarios.\nDTM can be applied to data consistency issues in a large number of scenarios, here are a few common ones\n* [cache management](https:\u002F\u002Fen.dtm.pub\u002Fapp\u002Fcache.html): thoroughly guarantee the cache final consistency and strong consistency\n* [flash-sales to deduct inventory](https:\u002F\u002Fen.dtm.pub\u002Fapp\u002Fflash.html): in extreme cases, it is also possible to ensure that the precise inventory in Redis is exactly the same as the final order created, without the need for manual adjustment\n* [Non-monolithic order system](https:\u002F\u002Fen.dtm.pub\u002Fapp\u002Forder.html): Dramatically simplifies the architecture\n* [Event publishing\u002Fsubscription](https:\u002F\u002Fen.dtm.pub\u002Fpractice\u002Fmsg.html): better outbox pattern\n\n## [Cook Book](https:\u002F\u002Fen.dtm.pub)\n\n## Quick start\n\n### run dtm\n\n``` bash\ngit clone https:\u002F\u002Fgithub.com\u002Fdtm-labs\u002Fdtm && cd dtm\ngo run main.go\n```\n\n### Start an example\nSuppose we want to perform an inter-bank transfer. The operations of transfer out (TransOut) and transfer in (TransIn) are coded in separate micro-services.\n\nHere is an example to illustrate a solution of dtm to this problem:\n\n``` bash\ngit clone https:\u002F\u002Fgithub.com\u002Fdtm-labs\u002Fquick-start-sample.git && cd quick-start-sample\u002Fworkflow-grpc\ngo run main.go\n```\n\n## Code\n\n### Usage\n``` go\nwfName := \"workflow-grpc\"\nerr = workflow.Register(wfName, func(wf *workflow.Workflow, data []byte) error {\n  \u002F\u002F ...\n  \u002F\u002F Define a transaction branch for TransOut\n  wf.NewBranch().OnRollback(func(bb *dtmcli.BranchBarrier) error {\n    \u002F\u002F compensation for TransOut\n    _, err := busiCli.TransOutRevert(wf.Context, &req)\n    return err\n  })\n  _, err = busiCli.TransOut(wf.Context, &req)\n  \u002F\u002F check error\n\n  \u002F\u002F Define another transaction branch for TransIn\n  wf.NewBranch().OnRollback(func(bb *dtmcli.BranchBarrier) error {\n    _, err := busiCli.TransInRevert(wf.Context, &req)\n    return err\n  })\n  _, err = busiCli.TransIn(wf.Context, &req)\n  return err\n}\n\n\u002F\u002F ...\nreq := busi.BusiReq{Amount: 30, TransInResult: \"\"}\ndata, err := proto.Marshal(&req)\n\n\u002F\u002F Execute workflow\n_, err = workflow.ExecuteCtx(wfName, shortuuid.New(), data)\nlogger.Infof(\"result of workflow.Execute is: %v\", err)\n\n```\n\nWhen the above code runs, we can see in the console that services `TransOut`, `TransIn` has been called.\n\n#### Rollback upon failure\nIf any forward operation fails, DTM invokes the corresponding compensating operation of each sub-transaction to roll back, after which the  transaction is successfully rolled back.\n\nLet's purposely trigger the failure of the second sub-transaction and watch what happens\n\n``` go\n\u002F\u002F req := busi.BusiReq{Amount: 30, TransInResult: \"\"}\nreq := busi.BusiReq{Amount: 30, TransInResult: \"FAILURE\"}\n})\n```\n\nwe can see in the console that services `TransOut`, `TransIn`, `TransOutRevert` has been called\n\n## More examples\nIf you want more quick start examples, please refer to [dtm-labs\u002Fquick-start-sample](https:\u002F\u002Fgithub.com\u002Fdtm-labs\u002Fquick-start-sample)\n\nThe above example mainly demonstrates the flow of a distributed transaction. More on this, including practical examples of how to interact with an actual database, how to do compensation, how to do rollback, etc. please refer to [dtm-examples](https:\u002F\u002Fgithub.com\u002Fdtm-labs\u002Fdtm-examples) for more examples.\n\n## Give a star! ⭐\n\nIf you think this project is interesting, or helpful to you, please give a star!\n","DTM 是一个分布式事务框架，支持多种模式如工作流、Saga、TCC、XA、两阶段消息和Outbox模式，适用于跨服务的最终数据一致性问题。它提供了丰富的事务处理模式，支持Go、Java、PHP、C#、Python、Nodejs等多种语言，并且能够与MySQL\u002FMariaDB、Redis、MongoDB、Postgres等多类型数据库进行集成。该框架还具备高可用性和易于横向扩展的特点，适用于需要保证数据一致性的各种场景，例如缓存管理、秒杀库存扣减、非单体订单系统以及事件发布\u002F订阅等。通过使用DTM，开发者可以简化架构设计，提高系统的稳定性和可维护性。",2,"2026-06-11 03:02:04","top_language"]