Skip to content

Distributed transaction TCC transaction model

Notifications You must be signed in to change notification settings

typeservice/tcc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@typeservice/tcc

codecov

TCC (Try-Ack-Cancel) is called a two-stage compensation transaction. The first phase attempts to reserve resources. The second phase must clearly tell the service provider whether this resource is needed or not. Cancel, used to clear the impact of the first phase, so called compensation transactions.

Installing

For the latest stable version:

$ npm install @typeservice/tcc

Usage

import * as Tcc from '@typeservice/tcc';
app.use(Tcc.Middleware());

It has 4 events:

  • start 开始事件
  • commit 成功提交事件
  • rollback 回滚事件
  • error 出错事件
  • stop 结束事件
ctx.tcc.on('start', async () => {});
ctx.tcc.on('commit', async () => {});
ctx.tcc.on('rollback', async () => {});
ctx.tcc.on('error', async (e: Error) => {});
ctx.tcc.on('stop', async () => {});

License

MIT

Copyright (c) 2019-present, yunjie (Evio) shen

About

Distributed transaction TCC transaction model

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published