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

REPLACE endpoint for more reliably replacing events #115

Open
johan-bjareholt opened this issue Apr 5, 2020 · 1 comment
Open

REPLACE endpoint for more reliably replacing events #115

johan-bjareholt opened this issue Apr 5, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@johan-bjareholt
Copy link
Member

So it's already possible to replace events by setting the "id" property in the /insert endpoint.

So why would you want to have a separate /replace endpoint?

  • Because /insert does not fail if the "id" does not exist, it creates a new event
  • If one out of many replaces in /insert fails we have no idea what actually happened, we need to do fetch the events after to be certain which should be unnecessary
  • Any other reasons, put a comment below and I'll add it to this list

I don't think this is a high priority task right now, might be in the future if we get a use-case which replaces a lot of events.

Resources:

@leoschwarz
Copy link

My main reason for the linked PR was that I think at that time there was no event updating endpoint, but since it's possible I don't see a stringent need for it anymore. Also maybe it should be named update if it were to be added.

If one out of many replaces in /insert fails we have no idea what actually happened, we need to do fetch the events after to be certain which should be unnecessary

One could change

Ok(events) => Ok(Json(events)),
Err(e) => match e {
DatastoreError::NoSuchBucket => Err(Status::NotFound),
e => {
warn!("Failed to create event(s): {:?}", e);
Err(Status::InternalServerError)
}
},

to return per event success/failure information in the response body (and set success in the header if everything succeeded, failure otherwise). For example, you could add an additional "success": field to events inserted, the details of this would be something to think about if this approach is chosen.

So I think it's mainly an API design choice whether to have this endpoint or not (simpler vs lower number of endpoints).

@johan-bjareholt johan-bjareholt added the enhancement New feature or request label Jul 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants