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

Add endpoint to receive updates for tables #262

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

somtochiama
Copy link
Contributor

@somtochiama somtochiama commented Oct 22, 2024

This pull request adds a HTTP endpoint /updates/:table that sends future updates about the primary keys of rows have been updated or deleted.

$ curl -X POST http://localhost:8081/v1/updates/todos
{"notify":["upsert",["some-id-82"]]}
{"notify":["upsert",["1"]]}
{"notify":["delete",["1"]

@somtochiama somtochiama changed the title Add endpoint to receive updates for public keys Add endpoint to receive updates for tables Oct 22, 2024
crates/corro-types/src/updates.rs Outdated Show resolved Hide resolved
crates/corro-api-types/src/lib.rs Outdated Show resolved Hide resolved
crates/corro-types/src/pubsub.rs Outdated Show resolved Hide resolved
crates/corro-types/src/pubsub.rs Outdated Show resolved Hide resolved
crates/corro-types/src/updates.rs Outdated Show resolved Hide resolved
crates/corro-types/src/updates.rs Outdated Show resolved Hide resolved
crates/corro-types/src/updates.rs Show resolved Hide resolved
crates/corro-types/src/updates.rs Outdated Show resolved Hide resolved
@somtochiama somtochiama marked this pull request as ready for review October 29, 2024 10:34
Copy link
Member

@jeromegn jeromegn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outlined a few changes that can help reduce complexity and make it more efficient. It's looking pretty good though!

crates/corro-agent/src/api/public/update.rs Outdated Show resolved Hide resolved
crates/corro-types/src/updates.rs Outdated Show resolved Hide resolved
crates/corro-types/src/updates.rs Outdated Show resolved Hide resolved
crates/corro-types/src/updates.rs Outdated Show resolved Hide resolved
It's required by the handler but not getting passed to Axum's middleware
stack.
As the client doesn't import "big" corro-types, move public facing
types to the dedicated crate.
The client is much simpler than the existing subscription client:
 - it doesn't handle I/O error and simply bubble it up (as the user
   still need to handle it)
 - the only possible errors are I/O and deserialization as the /updates
   stream doesn't have a "change id" concept
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.

3 participants