Actyx / Actyx/machines

[Brain Dump] Event-As-Destination-State

オープン
#66 コメント 7 件 リアクション 0 件 担当者 0 名 GitHub で見る
enhancement wontfix
主要言語
TypeScript
スター
8
フォーク
2
PR マージ指標
30日以内にマージされた PR はありません

説明

In a swarm protocol:
- Transition map one-to-one to a guard event
- Transition map one-to-one to a combination of role, source state, and target state
- There does not seem to be a need for ordered-multi-events transition.

With those properties (and hopefully no need for another compiliation step) swarm protocol and role protocol can be defined this way:

```typescript
const swarmProtocol = Swarm.createProtocol()
.state(["A", "B", "C1", "C2", "D"])
.role("taxi", "passenger")
.transition("passenger", "A", "B").withPayload() // creates event type "passenger-A-to-B"
.transition("taxi", "B", "B").withPayload() // creates event type "taxi-B-to-B" (Loop)
.transition("taxi", "B", "C1").withPayload() // creates event type "taxi-B-to-C1"
.transition("passenger", "B", "C2").withPayload() // creates event type "passenger-B-to-C2"
.transition("passenger", "C1", "D").withPayload() // creates event type "passenger-B-to-C2"
.transition("taxi", "C2", "D").withPayload() // creates event type "taxi-B-to-C2"
.transition("passenger", "C2", "D", (ctx, payload) => ctx.additionalTag(`sometag:${payload.numprop}`)).withPayload() // creates event type "passenger-B-to-C2"
.finish() // builds the swarm protocol complete with the graph

// payload-less machine-runner
// only give payload-less states, but leave commands intact
const machineRunner = createMachineRunner(actyx, tags, swarmProtocol.buildMachineFor("passenger"));

// in default machine
state.commands?.["A-to-B"](theEventPayload);

// custom machines uses old syntax
const taxiMachineProtocol = swarmProtocol.buildMachineCustomRole("taxi");

const A = taxiMachineProtocol
.designState("A")
.withPayload()
.commands("A-to-B", (ctx, value) => [{ ...payloadOfAToB, value }])
.finish()

const B = taxiMachineProtocol
.designState("B")
.withPayload()
.finish()

// custom machines need to be run with `checkProjection`

checkProjection(swarmProtocol, taxiMachineProtocol)
```

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

Start by tracing the entry points shown in the proposal: Swarm.createProtocol, buildMachineFor, buildMachineCustomRole, createMachineRunner, and checkProjection. Done would require an agreed event/state-transition design and implementation criteria; the issue names no files or tests and does not define a bounded deliverable.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
distributed-systems
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。