a lightweight distributed transaction management service, support xa tcc saga

Overview

license Build Status Coverage Status Go Report Card Go Reference

English

GO语言分布式事务管理服务

DTM是首款golang的开源分布式事务管理器,优雅的解决了幂等、空补偿、悬挂等分布式事务难题。在微服务架构中,提供了高性能和简单易用的分布式事务解决方案。

受邀参加中国数据库大会分享多语言环境下分布式事务实践

亮点

  • 稳定可靠
    • 经过生产环境考验,单元测试覆盖率90%以上
  • 使用简单
    • 接口简单,开发者不再担心悬挂、空补偿、幂等各类问题,框架层代为处理
  • 跨语言
    • 可适合多语言栈的公司使用。协议支持http。方便go、python、php、nodejs、ruby各类语言使用。
  • 社区活跃
    • 任何问题都快速响应
  • 易部署、易扩展
    • 仅依赖mysql,部署简单,易集群化,易水平扩展
  • 多种分布式事务协议支持
    • TCC: Try-Confirm-Cancel
    • SAGA:
    • 可靠消息
    • XA

文档与介绍(更新中)

与其他框架对比

目前开源的分布式事务框架,有阿里的SEATA、华为的ServiceComb-Pack,京东的shardingsphere,以及himly,tcc-transaction,ByteTCC等等,其中以seata应用最为广泛。

这些框架基本都是Java语言,非Java语言的,暂未看到有成熟的框架。

下面将dtm和seata的主要特性做一下对比:

特性 DTM SEATA 备注
支持语言 Golang、python、node及其他 Java dtm可轻松接入一门新语言
异常处理 子事务屏障技术 手动处理 dtm解决了幂等、悬挂、空补偿
TCC事务
XA事务
AT事务 AT事务与XA事务类似
SAGA事务 简单模式 状态机复杂模式 dtm的状态机模式在规划中
事务消息 dtm提供类似rocketmq的事务消息
通信协议 HTTP dubbo等协议,无HTTP dtm后续将支持grpc类协议
star数量 github stars github stars dtm从20210604发布0.1,发展快

从上面对比的特性来看,如果您的语言栈包含了Java之外的语言,那么dtm是您的首选。如果您的语言栈是Java,您也可以选择接入dtm,使用子事务屏障技术,简化您的业务编写。

快速开始

安装

git clone github.com/yedf/dtm

dtm依赖于mysql

配置mysql:

cp conf.sample.yml conf.yml # 修改conf.yml

启动并运行saga示例

go run app/main.go saga

开始使用

使用

  // 具体业务微服务地址
  const qsBusi = "http://localhost:8081/api/busi_saga"
	req := &gin.H{"amount": 30} // 微服务的载荷
	// DtmServer为DTM服务的地址,是一个url
	saga := dtmcli.NewSaga("http://localhost:8080/api/dtmsvr").
		// 添加一个TransOut的子事务,正向操作为url: qsBusi+"/TransOut", 补偿操作为url: qsBusi+"/TransOutCompensate"
		Add(qsBusi+"/TransOut", qsBusi+"/TransOutCompensate", req).
		// 添加一个TransIn的子事务,正向操作为url: qsBusi+"/TransOut", 补偿操作为url: qsBusi+"/TransInCompensate"
		Add(qsBusi+"/TransIn", qsBusi+"/TransInCompensate", req)
	// 提交saga事务,dtm会完成所有的子事务/回滚所有的子事务
  err := saga.Submit()

完整示例

参考examples/quick_start.go

交流群

请加 yedf2008 好友或者扫码加好友,验证回复 dtm 按照指引进群

yedf2008

如果您觉得此项目不错,或者对您有帮助,请赏颗星吧!

其他语言客户端

python

客户端sdk(当前只支持TCC): https://github.com/yedf/dtmcli-python

示例: https://github.com/yedf/dtmcli-python-sample

node

客户端sdk(当前只支持TCC): https://github.com/yedf/dtmcli-node

示例: https://github.com/yedf/dtmcli-node-sample

谁在使用

常青藤爸爸 镜小二
Issues
  • 考虑支持postgresql?

    考虑支持postgresql?

    相比mysql, postgresql在很多方面有着更大的优势

    opened by sb-child 1
  • 有php客户端吗?

    有php客户端吗?

    如题

    opened by onlyshow 1
  • FAQ

    FAQ

    目前可以用于生产环境吗?

    版本v 0.5 以后即可

    支持高可用吗?

    支持,DTM可以部署多个无状态的应用节点,连接到数据库,只要数据库是高可用的,那么整个DTM就是高可用的

    opened by yedf2 0
Releases(v0.6)
Owner
null
Universal command-line interface for SQL databases

usql A universal command-line interface for PostgreSQL, MySQL, Oracle Database, SQLite3, Microsoft SQL Server, and many other databases including NoSQ

XO 6.6k Jul 25, 2021
Zero boilerplate database operations for Go

(Now compatible with MySQL and PostgreSQL!) Everyone knows that performing simple DATABASE queries in Go takes numerous lines of code that is often re

null 304 Jul 19, 2021
OctoSQL is a query tool that allows you to join, analyse and transform data from multiple databases and file formats using SQL.

OctoSQL OctoSQL is a query tool that allows you to join, analyse and transform data from multiple databases, streaming sources and file formats using

Jacob Martin 2.5k Jul 21, 2021
Podman based development-only dependency manager for Linux.

Tent is a CLI tool for running development dependencies such as MySQL, Mongo, ElasticSearch etc inside pre-configured containers using simple one

Farhan Hasin Chowdhury 88 Jul 11, 2021
Goose database migration tool - fork of https://bitbucket.org/liamstask/goose

goose Goose is a database migration tool. Manage your database schema by creating incremental SQL changes or Go functions. Goals of this fork github.c

Pressly Inc. 1.8k Jul 23, 2021
pg_timetable: Advanced scheduling for PostgreSQL

pg_timetable: Advanced scheduling for PostgreSQL pg_timetable is an advanced job scheduler for PostgreSQL, offering many advantages over traditional s

CYBERTEC PostgreSQL International GmbH 426 Jul 20, 2021
go mysql driver, support distributed transaction

Go-MySQL-Driver A MySQL-Driver for Go's database/sql package Features Requirements Installation Usage DSN (Data Source Name) Password Protocol Address

Open Transaction 22 Jul 19, 2021
Enhanced PostgreSQL logical replication

pgcat - Enhanced postgresql logical replication Why pgcat? Architecture Build from source Install Run Conflict handling Table mapping Replication iden

jinhua luo 342 Jun 23, 2021
A fully-featured AWS Athena database driver (+ athenareader https://github.com/uber/athenadriver/tree/master/athenareader)

?? athenadriver - A fully-featured AWS Athena database driver for Go ?? athenareader - A moneywise command line utililty to query athena in command li

Uber Open Source 76 Jul 16, 2021
ClickHouse http proxy and load balancer

chproxy English | 简体中文 Chproxy, is an http proxy and load balancer for ClickHouse database. It provides the following features: May proxy requests to

Vertamedia 647 Jul 16, 2021
🏋️ dbbench is a simple database benchmarking tool which supports several databases and own scripts

dbbench Table of Contents Description Example Installation Supported Databases Usage Custom Scripts Troubeshooting Development Acknowledgements Descri

Simon Jürgensmeyer 59 Jul 8, 2021
A high-performance MySQL proxy

kingshard 中文主页 Overview kingshard is a high-performance proxy for MySQL powered by Go. Just like other mysql proxies, you can use it to split the read

Fei Chen 5.7k Jul 18, 2021
The MongoDB driver for Go

The MongoDB driver for Go This fork has had a few improvements by ourselves as well as several PR's merged from the original mgo repo that are current

GlobalSign 1.9k Jul 20, 2021
A Go SQL query builder and struct mapper.

godb - a Go query builder and struct mapper godb is a simple Go query builder and struct mapper, not a full-featured ORM. godb does not manage relatio

Samuel GAY 657 Jul 13, 2021