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

Remove adapter-specific message types from automerge-repo #214

Merged
merged 4 commits into from
Oct 31, 2023

Conversation

HerbCaudill
Copy link
Collaborator

@HerbCaudill HerbCaudill commented Oct 29, 2023

automerge-repo currently exposes two union types for messages:

  • RepoMessage includes all message types that a network adapter emits to the Repo.
  • Message includes all of these plus ArriveMessage and WelcomeMessage, which are message types used by some network adapters but not others.

In anticipation of the AuthProvider work, I'm introducing an AuthMessage type, which doesn't fit into either of these categories: It's not Message, because all network adapters need to be able to handle it, not just the ones that have arrive and welcome; and it's not a RepoMessage because it's not surfaced to the Repo.

The abstract NetworkAdapter needs a message type that automerge-repo expects every adapter implementation to accept, and that should be Message.

This PR removes arrive and welcome messages from automerge-repo, leaving it entirely up to each network adapter what kind of internal messages to use. That means that we have some duplicate type definitions between MessageChannelNetworkAdapter and BroadcastChannelNetworkAdapter but that's OK.

Message is redefined as RepoMessage | AuthMessage, and each adapter extends that type with its own internal message types.

@HerbCaudill HerbCaudill force-pushed the remove-adapter-specific-message-types branch from 1eced64 to 0eab10f Compare October 30, 2023 12:01
@HerbCaudill HerbCaudill requested review from pvh and alexjg and removed request for acurrieclark October 31, 2023 15:26
@HerbCaudill HerbCaudill force-pushed the remove-adapter-specific-message-types branch from 0eab10f to abe5e11 Compare October 31, 2023 15:28
@HerbCaudill HerbCaudill merged commit db156e8 into main Oct 31, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant