Skip to content

added sync runner and refactored operator creation#171

Merged
NamanBalaji merged 5 commits into
mainfrom
feat/sync-operator-runner
Apr 29, 2026
Merged

added sync runner and refactored operator creation#171
NamanBalaji merged 5 commits into
mainfrom
feat/sync-operator-runner

Conversation

@NamanBalaji
Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 409b1e5c-ebc5-4ab9-831d-7dec17147115

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment thread client/rpc/server.go

// WithServerOptions appends gRPC server options (interceptors, TLS
// credentials, etc.) used when the underlying grpc.Server is created.
func WithServerOptions(opts ...grpc.ServerOption) ServerOption {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

grpc.WithServerOptions(opts ...GRPC.ServerOption) grpc.ServerOption

I think the pkg naming isn't optimal because we now have 2 grpc pkgs using the same name. So using this function requires one to make aliased imports.

What if we call this pkg rpc? Its a similar case like the AMQP and even if it weren't, I think its still cleaner.

Comment thread processor.go Outdated
// Processor handles signature verification, handler dispatch, and
// response signing. It is transport-agnostic: a Runner or server
// calls Processor.Process for each inbound TaskRequest.
Processor struct {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Let's discuss this new entity

@NamanBalaji NamanBalaji force-pushed the feat/sync-operator-runner branch from ee8895a to 20bf73e Compare April 24, 2026 15:00
apatsap
apatsap previously approved these changes Apr 27, 2026
Copy link
Copy Markdown
Contributor

@fabenan-f fabenan-f left a comment

Choose a reason for hiding this comment

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

just a few comments to consider

Comment thread client/amqp/amqp.go
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.

Since this directory evolved quite a bit, we could think of renaming it from client to transport or something else (probable better in a separate PR if at all)

Comment thread client/rpc/server.go
}
}

// Run registers the TaskService, starts serving, and blocks until
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.

Run can be called multiple times but stop only once, so the second server cannot be gracefully stopped. This might not happen when used but then again there is Murphy's Law

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.

Fixed it so that Run and stop can only be called once on a grpc client.

Comment thread target.go
// Signer and Verifier for signing and verification operations.
type TargetOperator struct {
Runner Runner
Client Responder
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 calling the field Responder is more accurate even though it is inconsistent with TargetManager (I'd then rather change the field name there, too, probably in a separate PR)

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.

Yes, naming could be better. I can create a subsequent refactoring PR

Comment thread operator.go Outdated
// shutdown.
Runner interface {
Run(ctx context.Context, process ProcessFunc)
// TaskRequestHandler is the processing pipeline handed to a Responder.
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.

np but I think important for the understanding: The TaskRequestHandler is handed to a SyncResponder and automatically called by an AsyncResponder

Comment thread target.go Outdated

// TargetOperator holds the runner and cryptographic implementation for responding
// Responder is the base interface for any transport that can be closed.
type Responder interface {
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'd rather keep Responder just as a speaking type without any method definition than having this misplaced (imho) Close here. Otherwise, we could define it as a constraint like

type Responder interface {
  SyncResponder | AsyncResponder
}

and go down the generic rabbit hole but I'm not sure if this is a good idea

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.

Yes if we add a union constraint we can't type switch in the operator anymore and then we would need

type TargetOperator[R SyncResponder | AsyncResponder] struct {
      Client R
  }
type Operator[R SyncResponder | AsyncResponder] struct { ... }

as go doesn't allow switching on type parameter.

Copy link
Copy Markdown
Contributor

@jithinkunjachan jithinkunjachan left a comment

Choose a reason for hiding this comment

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

LGTM

@NamanBalaji NamanBalaji merged commit 51fcc92 into main Apr 29, 2026
9 checks passed
@NamanBalaji NamanBalaji deleted the feat/sync-operator-runner branch April 29, 2026 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants