Skip to content

Use InvocationClient in admin API, introduce new API endpoints for cancel/kill/purge #3227

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

Conversation

slinkydeveloper
Copy link
Contributor

This PR does two things:

  • Use InvocationClient in admin API
  • Introduce new endpoints for cancel/kill/purge, replacing the previous single endpoint. The reason I introduced a new endpoint is that i didn't want to break the old semantics (previously, on not found, nothing would happen, while now it returns 404), plus some of those commands will get ad-hoc new parameters soon (see Trimming journal #2890 (comment))

@slinkydeveloper
Copy link
Contributor Author

A followup of this one is to use this new endpoints in the e2e tests, to make sure they just work fine.

@slinkydeveloper slinkydeveloper force-pushed the issues/admin-api-use-invocation-client branch from 19af187 to db0a50c Compare May 6, 2025 16:36
@slinkydeveloper slinkydeveloper force-pushed the issues/admin-api-use-invocation-client branch from db0a50c to 7a1447c Compare May 28, 2025 12:07
@slinkydeveloper slinkydeveloper added the release-blocker Blocker for the next release label Jun 4, 2025
@slinkydeveloper slinkydeveloper force-pushed the issues/admin-api-use-invocation-client branch from 7a1447c to c32a935 Compare June 4, 2025 08:32
Copy link
Contributor

@tillrohrmann tillrohrmann left a comment

Choose a reason for hiding this comment

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

Thanks a lot for creating this PR @slinkydeveloper. The changes look good to me. I left a few minor comments. The main one being whether the outbox messages really need to carry the request id. Apart from this +1 for merging.

#[derive(Debug, PartialEq, Eq, Clone, Hash, serde::Serialize, serde::Deserialize)]
pub enum InvocationMutationResponseSink {
/// The invocation has been generated by a request received at an ingress, and the client is expecting a response back.
Ingress {
Copy link
Contributor

Choose a reason for hiding this comment

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

What other sinks are we planning to support?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just Ingress for now, but it makes sense to have a union type here for future proofing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It might be one day some of these features we expose them in the context API

AlreadyCompleted,
}

impl From<CancelInvocationRpcResponse> for CancelInvocationResponse {
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the difference between CancelInvocationRpcResponse and CancelInvocationReponse and why is it beneficial to have these two types? Is it possible to have a single type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I want to have split types to make sure I can model the API without being constrained by however the network serialization works.

@@ -116,3 +118,145 @@ pub async fn delete_invocation<V, IC>(
Ok(StatusCode::ACCEPTED)
}
}

generate_meta_api_error!(KillInvocationError: [InvocationNotFoundError, InvocationClientError, InvalidFieldError, InvocationWasAlreadyCompletedError]);
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure whether we are optimizing here for the reader or the writer of the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm optimizing a structured description of errors. I wished to do this with a macro on an enum TBH, like

enum KillError {
 #[error("error msg")]
 #[status_code(123, "openapi desc")]
 Variant()
}

But that ain't easy without writing proc macros 😢, I didn't want to get on that for now. I documented the macro, and there's enough examples how to use, so should be good.

@slinkydeveloper slinkydeveloper force-pushed the issues/admin-api-use-invocation-client branch from c32a935 to a3fad33 Compare June 6, 2025 07:31
…/<id>/purge Admin APIs.

Add cancel/kill/purge invocation to InvocationClient.
These new APIs replace the old delete_invocation single endpoint, and have the new semantics returning 404 when the invocation is not found, etc.
@slinkydeveloper slinkydeveloper force-pushed the issues/admin-api-use-invocation-client branch from a3fad33 to 96f77eb Compare June 6, 2025 07:37
@slinkydeveloper slinkydeveloper merged commit b7b1e10 into restatedev:main Jun 6, 2025
25 checks passed
@slinkydeveloper slinkydeveloper deleted the issues/admin-api-use-invocation-client branch June 6, 2025 12:32
@github-actions github-actions bot locked and limited conversation to collaborators Jun 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-blocker Blocker for the next release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants