Actyx / Actyx/machines

[Brain Dump] Event-As-Destination-State

Ouverte
#66 7 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
enhancement wontfix
Langage dominant
TypeScript
Étoiles
8
Forks
2
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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)
```

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
typescript
Domaine
distributed-systems
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.