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

UpdateMessage type is problematic #2760

Open
jonathonherbert opened this issue Feb 6, 2020 · 0 comments
Open

UpdateMessage type is problematic #2760

jonathonherbert opened this issue Feb 6, 2020 · 0 comments
Labels
To Review PRs that need to be reviewed

Comments

@jonathonherbert
Copy link
Contributor

jonathonherbert commented Feb 6, 2020

Short description

The UpdateMessage type contains every possible field an incoming message can have. Because not every message will have every field, each field is an option type. This is less than ideal –

  • To understand what messages it's possible to send, you must inspect the message switch code.
  • To understand the correct combination of fields for a message, you must understand the implementation of each the message handler.
  • It's possible to construct badly formed messages at the point of serialisation.
  • To handle this proliferation of possible message shapes, each handler must contain code to extract the appropriate fields, making handlers more verbose than necessary.

We should use a sum type, and parse, rather than validating.

This PR details a possible solution.

@sihil sihil added the To Review PRs that need to be reviewed label Sep 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
To Review PRs that need to be reviewed
Projects
None yet
Development

No branches or pull requests

2 participants