a php client for distributed transaction framework dtm. 分布式事务管理器dtm的php客户端

Overview

a client for distributed transaction manager dtm

dtmcli 是分布式事务管理器dtm的客户端sdk

dtm分布式事务管理服务

DTM是一款跨语言的开源分布式事务管理器,优雅的解决了幂等、空补偿、悬挂等分布式事务难题。提供了简单易用、高性能、易水平扩展的分布式事务解决方案。

亮点

  • 极易接入
    • 支持HTTP,提供非常简单的接口,极大降低上手分布式事务的难度,新手也能快速接入
  • 使用简单
    • 开发者不再担心悬挂、空补偿、幂等各类问题,框架层代为处理
  • 跨语言
    • 可适合多语言栈的公司使用。方便go、python、php、nodejs、ruby各类语言使用。
  • 易部署、易扩展
    • 仅依赖mysql,部署简单,易集群化,易水平扩展
  • 多种分布式事务协议支持
    • TCC、SAGA、XA、事务消息

与其他框架对比

目前开源的分布式事务框架,暂未看到非Java语言有成熟的框架。而Java语言的较多,有阿里的SEATA、华为的ServiceComb-Pack,京东的shardingsphere,以及himly,tcc-transaction,ByteTCC等等,其中以seata应用最为广泛。

下面是dtm和seata的主要特性对比:

特性 DTM SEATA 备注
支持语言 Golang、python、php及其他 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,使用子事务屏障技术,简化您的业务编写。

使用示例

composer require yedf/dtmcli-php:dev-main
function FireTcc () {
    $dtm = 'http://192.168.69.128:8080/api/dtmsvr';
    $svc = 'http://192.168.69.128:4005/api';

    Dtmcli\tccGlobalTransaction($dtm, function ($tcc) use ($svc) {
        /** @var Dtmcli\Tcc $tcc */

        $req = ['amount' => 30];
        echo 'calling trans out' . PHP_EOL;
        $tcc->callBranch($req, $svc . '/TransOutTry', $svc . '/TransOutConfirm', $svc . '/TransOutCancel');
        echo 'calling trans in' . PHP_EOL;
        $tcc->callBranch($req, $svc . '/TransInTry', $svc . '/TransInConfirm', $svc . '/TransInCancel');
    });
}

可运行的使用示例

https://github.com/yedf/dtmcli-php-sample

特别说明

使用mix/guzzle为http客户端,支持swoole协程请求

You might also like...
A complete, simple and powerful database framework written in PHP

BaseSQL BaseSQL is a complete database framework written in PHP. It was built to accelerate projects development by handle database connections and qu

The fastest pure PHP database framework with a powerful static code generator, supports horizontal scale up, designed for PHP7
The fastest pure PHP database framework with a powerful static code generator, supports horizontal scale up, designed for PHP7

Maghead 4.0.x IS CURRENTLY UNDER HEAVY DEVELOPMENT, API IS NOT STABLE Maghead is an open-source Object-Relational Mapping (ORM) designed for PHP7. Mag

The Enobrev\ORM library is a small framework of classes meant to be used for simply mapping a mysql database to PHP classes, and for creating simply SQL statements using those classes.

The Enobrev\ORM library is a small framework of classes meant to be used for simply mapping a mysql database to PHP classes, and for creating simply SQL statements using those classes.

[READ ONLY] Subtree split of the Illuminate Database component (see laravel/framework)

Illuminate Database The Illuminate Database component is a full database toolkit for PHP, providing an expressive query builder, ActiveRecord style OR

ATK Data - Data Access Framework for high-latency databases (Cloud SQL/NoSQL).
ATK Data - Data Access Framework for high-latency databases (Cloud SQL/NoSQL).

ATK Data - Data Model Abstraction for Agile Toolkit Agile Toolkit is a Low Code framework written in PHP. Agile UI implement server side rendering eng

Adjacency List’ed Closure Table database design pattern implementation for the Laravel framework.

ClosureTable This is a database manipulation package for the Laravel 5.4+ framework. You may want to use it when you need to store and operate hierarc

Phpstan-dba - database handling related class reflection extension for PHPStan & framework-specific rules

database handling class reflection extension for PHPStan This extension provides following features: PDO-query knows the array shape of the returned

This package provides a framework-agnostic database backup manager for dumping to and restoring databases from S3, Dropbox, FTP, SFTP, and Rackspace Cloud

Database Backup Manager This package provides a framework-agnostic database backup manager for dumping to and restoring databases from S3, Dropbox, FT

Async MySQL Framework for PocketMine-MP
Async MySQL Framework for PocketMine-MP

MyPigSQL Join my discord: https://discord.gg/2QAPHbqrny Async MySQL Framework for PocketMine-MP Known Issues There are some weird behaviors still, do

Comments
  • PHP SDK ParseError: syntax error, unexpected 'IdGenerator'

    PHP SDK ParseError: syntax error, unexpected 'IdGenerator'

    • php version : 7.3
    • repetition frequency : every time
    • error
    • file : \vendor\yedf\dtmcli-php\src\Tcc.php
    • line : 9
    • message:ParseError: syntax error, unexpected 'IdGenerator'

    老哥你用的该不会是PHP方言版的语法糖吧.还是8的?我这版本很高了.你这写法跟强类型的感觉差不多了.

    opened by ssuui 1
Owner
null
a distributed-redis-lock implementation for hyperf2.*

hyperf-redis-lock English | 中文 an easy redis-based distributed-lock implementation for hyperf 2.*。 This extension features distributed-lock includes b

lysice 11 Nov 8, 2022
High performance distributed database for mysql

High performance distributed database for mysql, define shardings by velocity&groovy scripts, can be expanded nodes flexible...

brucexx 33 Dec 13, 2022
A PHP client driver for the RethinkDB query language (ReQL).

PHP-RQL A PHP client driver for the RethinkDB query language (ReQL).

Daniel Mewes 341 Dec 30, 2022
A working Firebase http client

PHP library access Firebase RESTful API Installation $ composer require jaredchu/jc-firebase-php Usage Generate a private key in JSON format. Check Fi

Jared Chu 14 Jul 10, 2022
Async Redis client implementation, built on top of ReactPHP.

clue/reactphp-redis Async Redis client implementation, built on top of ReactPHP. Redis is an open source, advanced, in-memory key-value database. It o

Christian Lück 240 Dec 20, 2022
Tablavel - A simple Database Client for Laravel

Tablavel - A simple Database Client for Laravel Table of Contents About Getting Started Usage Contributing About This solves a simple problem. Know th

null 13 Feb 27, 2022
Async MySQL database client for ReactPHP.

MySQL Async MySQL database client for ReactPHP. This is a MySQL database driver for ReactPHP. It implements the MySQL protocol and allows you to acces

Friends of ReactPHP 302 Dec 11, 2022
The lightweight PHP database framework to accelerate development

The lightweight PHP database framework to accelerate development Features Lightweight - Less than 100 KB, portable with only one file Easy - Extremely

Angel Lai 4.6k Dec 28, 2022
Griffin is a Graph-Oriented Migration Framework for PHP

Griffin is a generic migration framework that uses graph theory to provision anything. It plans execution based on migration dependencies and runs them in the correct order.

Griffin 14 Feb 7, 2022
Ouzo Framework - PHP MVC ORM

Ouzo is a PHP MVC framework with built-in ORM and util libraries. PHP 8.0 or later is required. We believe in clean code and simplicity. We value unit

Ouzo 69 Dec 27, 2022