Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better stateful API #61

Merged
merged 5 commits into from
Sep 26, 2024
Merged

Better stateful API #61

merged 5 commits into from
Sep 26, 2024

Conversation

coot
Copy link
Collaborator

@coot coot commented Sep 24, 2024

Fixes #59

  • typed-protocols-stateful: pass initial state through Yield
  • typed-protocols-codec: changed how AnyMessageAndAgency is exported
  • typed-protocols-0.3.0.0: bumped versions

This removes the need to pass it in messages, like we used to in
`MsgResp` in `typed-protocols-examples`.

The `Driver` and `Codec` were modified:
* `encode` and `sendMessage` receive the initial state of the protocol
  state transition imposed by a message, which is dual to
* `decode` and `recvMessage` receive the final state of the protocol
  state transition imposed by a message

This is seems more natural than always passing the final state.

The drawback of this systemic approach is that every `Yield` needs
access to both initial and final state of a transition.  In previous
approach one had more control over which messages require access to the
initial state (e.g. `MsgRecv` in `Stateful.ReqResp`) - although it was
looking more like a hack since that part of a message wasn't sent over
the wire.
Also done for typed-protocols-stateful-codec.
@coot coot self-assigned this Sep 24, 2024
@coot coot added the stateful-api issues / PRs related to the stateful API label Sep 24, 2024
@coot coot added this pull request to the merge queue Sep 26, 2024
Merged via the queue into main with commit d127d3e Sep 26, 2024
16 checks passed
@coot coot deleted the coot/stateful branch September 26, 2024 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stateful-api issues / PRs related to the stateful API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend stateful API
2 participants