{"id":29127741,"url":"https://github.com/yedf/dtm","last_synced_at":"2025-06-30T01:01:58.554Z","repository":{"id":36954444,"uuid":"367758176","full_name":"dtm-labs/dtm","owner":"dtm-labs","description":"A distributed transaction framework, supports workflow, saga, tcc, xa, 2-phase message, outbox patterns, supports many languages.","archived":false,"fork":false,"pushed_at":"2025-05-04T14:31:41.000Z","size":3649,"stargazers_count":10542,"open_issues_count":75,"forks_count":986,"subscribers_count":102,"default_branch":"main","last_synced_at":"2025-06-19T20:14:16.227Z","etag":null,"topics":["cadence","csharp","database","distributed","distributed-transactions","dtm","go","golang","java","microservice","outbox","saga","seata","tcc","transaction","transactions","workflow-engine","xa"],"latest_commit_sha":null,"homepage":"http://d.dtm.pub","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dtm-labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-05-16T00:56:28.000Z","updated_at":"2025-06-19T05:38:47.000Z","dependencies_parsed_at":"2023-01-17T08:16:55.931Z","dependency_job_id":"9f27057c-135d-40f2-9e6e-71d0d324d081","html_url":"https://github.com/dtm-labs/dtm","commit_stats":{"total_commits":1221,"total_committers":78,"mean_commits":"15.653846153846153","dds":0.3906633906633906,"last_synced_commit":"e70f28f230b48cd86801859124062d64cbe7d0a0"},"previous_names":["yedf/dtm"],"tags_count":83,"template":false,"template_full_name":null,"purl":"pkg:github/dtm-labs/dtm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtm-labs%2Fdtm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtm-labs%2Fdtm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtm-labs%2Fdtm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtm-labs%2Fdtm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dtm-labs","download_url":"https://codeload.github.com/dtm-labs/dtm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtm-labs%2Fdtm/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262690385,"owners_count":23349168,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cadence","csharp","database","distributed","distributed-transactions","dtm","go","golang","java","microservice","outbox","saga","seata","tcc","transaction","transactions","workflow-engine","xa"],"created_at":"2025-06-30T01:01:42.938Z","updated_at":"2025-06-30T01:01:58.499Z","avatar_url":"https://github.com/dtm-labs.png","language":"Go","readme":"![license](https://img.shields.io/github/license/dtm-labs/dtm)\n![Build Status](https://github.com/dtm-labs/dtm/actions/workflows/tests.yml/badge.svg?branch=main)\n[![codecov](https://codecov.io/gh/dtm-labs/dtm/branch/main/graph/badge.svg?token=UKKEYQLP3F)](https://codecov.io/gh/dtm-labs/dtm)\n[![Go Report Card](https://goreportcard.com/badge/github.com/dtm-labs/dtm)](https://goreportcard.com/report/github.com/dtm-labs/dtm)\n[![Go Reference](https://pkg.go.dev/badge/github.com/dtm-labs/dtm.svg)](https://pkg.go.dev/github.com/dtm-labs/dtm)\n[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge-flat.svg)](https://github.com/avelino/awesome-go#database)\n\nEnglish | [简体中文](https://github.com/dtm-labs/dtm/blob/main/helper/README-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://en.dtm.pub/assets/function.7d5618f8.png\" height=250 /\u003e\n\n## Who's using DTM (partial)\n\n[Tencent](https://en.dtm.pub/other/using.html#tencent)\n\n[Bytedance](https://en.dtm.pub/other/using.html#bytedance)\n\n[Ivydad](https://en.dtm.pub/other/using.html#ivydad)\n\n[More](https://en.dtm.pub/other/using.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/MariaDB, Redis, MongoDB, Postgres, TDSQL, etc.\n* Support for multiple storage engines: MySQL/MariaDB (common), Redis (high performance), BoltDB (dev\u0026test), MongoDB (under planning)\n* Support for multiple microservices architectures: [go-zero](https://github.com/zeromicro/go-zero), go-kratos/kratos, polarismesh/polaris\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://en.dtm.pub/app/cache.html): thoroughly guarantee the cache final consistency and strong consistency\n* [flash-sales to deduct inventory](https://en.dtm.pub/app/flash.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://en.dtm.pub/app/order.html): Dramatically simplifies the architecture\n* [Event publishing/subscription](https://en.dtm.pub/practice/msg.html): better outbox pattern\n\n## [Cook Book](https://en.dtm.pub)\n\n## Quick start\n\n### run dtm\n\n``` bash\ngit clone https://github.com/dtm-labs/dtm \u0026\u0026 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://github.com/dtm-labs/quick-start-sample.git \u0026\u0026 cd quick-start-sample/workflow-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  // ...\n  // Define a transaction branch for TransOut\n  wf.NewBranch().OnRollback(func(bb *dtmcli.BranchBarrier) error {\n    // compensation for TransOut\n    _, err := busiCli.TransOutRevert(wf.Context, \u0026req)\n    return err\n  })\n  _, err = busiCli.TransOut(wf.Context, \u0026req)\n  // check error\n\n  // Define another transaction branch for TransIn\n  wf.NewBranch().OnRollback(func(bb *dtmcli.BranchBarrier) error {\n    _, err := busiCli.TransInRevert(wf.Context, \u0026req)\n    return err\n  })\n  _, err = busiCli.TransIn(wf.Context, \u0026req)\n  return err\n}\n\n// ...\nreq := busi.BusiReq{Amount: 30, TransInResult: \"\"}\ndata, err := proto.Marshal(\u0026req)\n\n// 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// 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/quick-start-sample](https://github.com/dtm-labs/quick-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://github.com/dtm-labs/dtm-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","funding_links":[],"categories":["开源类库","Go","语言资源库","Open source library","Database","Uncategorized"],"sub_categories":["数据库","go","Database","Advanced Console UIs"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyedf%2Fdtm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyedf%2Fdtm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyedf%2Fdtm/lists"}