Skip to content

feat(controller) Add and scaffold Cancel API in gateway#114

Closed
manjari25 wants to merge 4 commits into
mainfrom
manjari/cancel-gateway
Closed

feat(controller) Add and scaffold Cancel API in gateway#114
manjari25 wants to merge 4 commits into
mainfrom
manjari/cancel-gateway

Conversation

@manjari25
Copy link
Copy Markdown
Contributor

@manjari25 manjari25 commented Mar 3, 2026

Summary

feat(controller) Add and scaffold Cancel API in gateway

What?

  • Cancel API support
  • Add new topic - cancel to pass the request along to orchestrator

Why?

  • Requests once submitted for land can be cancelled. These changes set up the framework needed to do this.

Test Plan

Issues

@manjari25 manjari25 force-pushed the manjari/cancel-gateway branch from c365d38 to fb87fce Compare March 3, 2026 20:39
@manjari25 manjari25 marked this pull request as ready for review March 3, 2026 20:41
@manjari25 manjari25 requested review from a team, behinddwalls and sbalabanov as code owners March 3, 2026 20:41
Comment thread gateway/controller/cancel.go Outdated
Comment thread gateway/controller/cancel.go
@manjari25 manjari25 force-pushed the manjari/cancel-gateway branch from 1288676 to ff0ef20 Compare March 4, 2026 01:03
Comment thread gateway/proto/gateway.proto Outdated
Comment thread gateway/proto/gateway.proto Outdated
Comment thread gateway/controller/cancel.go
Comment thread gateway/controller/cancel.go
Comment thread gateway/controller/cancel.go Outdated
Comment thread gateway/controller/cancel.go Outdated
// Create queue message
// - Message ID: sqid for idempotency
// - Payload: sqid as bytes
// - Partition key: sqid (ensures ordering per request)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

how would it be ordered?
what if 2 sqids are being cancelled at the same time: "go/2" and "go/10"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

On second thought, I am not sure if we care about ordering for cancellation. I don't think there is any inherent order we need to enforce. We can simply leave the partition key empty. Thoughts?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think order does not matter here

sqid := req.Sqid

if sqid == "" {
return &pb.CancelResponse{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it should be INVALID_ARGUMENT + BadMessage first class GRPC error
errdetails.BadRequest
code.InvalidArgument

import (
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/status"
	"google.golang.org/genproto/googleapis/rpc/errdetails"
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The transformation from Go errors to GRPC errors is better to be done at a certain distinct function, means Cancel() function likely wants to wrap another cancelRequest(...) error function which is to return first class validationError.

Comment thread entity/cancel.go

// Cancel represents a request to cancel a previously submitted land request.
// The object is immutable after creation.
type Cancel struct {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

mb CancelRequest?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not critical

// Current status of the land request at the time of cancellation request.
RequestStatus current_status = 2;
// Optional error describing why the cancellation could not be completed.
Error error = 3;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should be first class grpc error

// processing. Note that cancellation is best effort and not guaranteed.
// To check for the status of the request, use Status API (TODO). A
// "Cancelled" status indicates that the requested cancellation was
// successful.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

may be update the last sentence to describe that it returns the current status, whatever it is

// Cancel handles the cancel request and returns a response.
// It publishes the sqid to the cancel topic for async processing.
// No validation is performed — the orchestrator handles that.
func (c *CancelController) Cancel(ctx context.Context, req *pb.CancelRequest) (resp *pb.CancelResponse, retErr error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note to future us (non blocking): we should discuss if controllers should receive proto structures directly. It seems that the final surfacing of the error should be a responsibility of a service, not a controller.

// The request has been successfully processed and landed. Terminal state.
LANDED = 4;
// The cancellation request has been accepted and is being processed.
CANCELLATION_ACCEPTED = 5;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

may be just "cancelling"

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