Skip to content

Latest commit

 

History

History
125 lines (86 loc) · 7.92 KB

README-en.md

File metadata and controls

125 lines (86 loc) · 7.92 KB

license Build Status Coverage Status Go Report Card Go Reference Mentioned in Awesome Go

A Cross Language Transaction Manager

Who's using DTM

Ivydad

Eglass

Jiou

GoldenData

What is DTM

DTM is the first distributed transaction management framework in Golang. Unlike other frameworks, DTM provides extremely easy access interfaces of HTTP and gRPC, supports multiple language bindings, and handles tricky problems of unordered sub-transactions at the framework level.

Features

  • Extremely easy to adapt

    • Support HTTP and gRPC, provide easy-to-use programming interfaces, lower substantially the barrier of getting started with distributed transactions. Newcomers can adapt quickly.
  • Easy to use

    • Relieving developers from worrying about suspension, null compensation, idempotent transaction, and other tricky problems, the framework layer handles them all.
  • Language-agnostic

    • Suit for companies with multiple-language stacks. Easy to write bindings for Go, Python, PHP, Node.js, Ruby, and other languages.
  • Easy to deploy, easy to extend

    • DTM depends only on MySQL, easy to deploy, cluster, and scale horizontally.
  • Support for multiple distributed transaction protocol

    • TCC, SAGA, XA, Transactional messages.

DTM vs. others

There is no mature open-source distributed transaction framework for non-Java languages. Mature open-source distributed transaction frameworks for Java language include Ali's Seata, Huawei's ServiceComb-Pack, Jingdong's shardingsphere, himly, tcc-transaction, ByteTCC, and so on, of which Seata is most widely used.

The following is a comparison of the main features of dtm and Seata.

Features DTM Seata Remarks
Supported languages Golang, Python, PHP, and others Java dtm allows easy access from a new language
Exception handling Sub-transaction barrier manual dtm solves idempotent transaction, hanging, null compensation
TCC
XA
AT AT is similar to XA with better performance but with dirty rollback
SAGA Simple mode complicated state-machine mode dtm's state-machine mode is being planned
Transactional Messaging dtm provides Transactional Messaging similar to RocketMQ
Multiple DBs in a service
Communication protocols HTTP, gRPC Dubbo, no HTTP
Star count github stars github stars dtm 0.1 is released from 20210604 and under fast development

From the features' comparison above, if your language stack includes languages other than Java, then dtm is the one for you. If your language stack is Java, you can also choose to access dtm and use sub-transaction barrier technology to simplify your business development.

Quick start

Install

git clone https://github.com/yedf/dtm

Configure Mysql

cp conf.sample.yml conf.yml # Modify conf.yml

Start the example

go run app/main.go

Code

Use

  // business micro-service address
  const qsBusi = "http://localhost:8081/api/busi_saga"
  // The address where DtmServer serves DTM, which is a url
  DtmServer := "http://localhost:8080/api/dtmsvr"
  req := &gin.H{"amount": 30} // micro-service payload
	// DtmServer is the address of DTM micro-service
	saga := dtmcli.NewSaga(DtmServer, dtmcli.MustGenGid(DtmServer)).
		// add a TransOut subtraction,forward operation with url: qsBusi+"/TransOut", reverse compensation operation with url: qsBusi+"/TransOutCompensate"
		Add(qsBusi+"/TransOut", qsBusi+"/TransOutCompensate", req).
		// add a TransIn subtraction, forward operation with url: qsBusi+"/TransIn", reverse compensation operation with url: qsBusi+"/TransInCompensate"
		Add(qsBusi+"/TransIn", qsBusi+"/TransInCompensate", req)
	// submit the created saga transaction,dtm ensures all subtractions either complete or get revoked
	err := saga.Submit()

Complete example

Refer to examples/quick_start.go.

Slack

You can join the DTM slack channel here.

Wechat

Add wechat friend with id yedf2008, or scan the OR code. Fill in dtm as verification.

yedf2008

Give a star! ⭐

If you think this project is good, or helpful to you, please give a star!

Who is using

Ivydad Eglass Jiou GoldenData