-
Notifications
You must be signed in to change notification settings - Fork 2
feat(sqs): listenless SQSServer for admin-only deployments #740
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,11 +11,17 @@ import ( | |
| "golang.org/x/sync/errgroup" | ||
| ) | ||
|
|
||
| // startSQSServer stands up the SQS adapter on sqsAddr and returns the | ||
| // running *adapter.SQSServer so the admin listener can call SigV4-bypass | ||
| // admin entrypoints against it (see adapter/sqs_admin.go). Returns | ||
| // (nil, nil) when sqsAddr is empty — that is the "SQS disabled" branch | ||
| // and the admin listener leaves /admin/api/v1/sqs/* off the wire. | ||
| // startSQSServer constructs the SQS adapter and returns the running | ||
| // *adapter.SQSServer. The admin listener calls SigV4-bypass admin | ||
| // entrypoints against this server (see adapter/sqs_admin.go); those | ||
| // admin methods only need the coordinator/store, NOT the public SQS | ||
| // HTTP listener. So when sqsAddr is empty the function still | ||
| // constructs the server (with a nil net.Listener) — Run() then skips | ||
| // httpServer.Serve while the reaper and throttle-sweep goroutines | ||
| // still run, keeping retention math behind the admin counters | ||
| // correct. The admin bridge in main_admin.go therefore wires | ||
| // /admin/api/v1/sqs/* on the wire even on builds that disabled the | ||
| // public SigV4 endpoint. | ||
| func startSQSServer( | ||
| ctx context.Context, | ||
| lc *net.ListenConfig, | ||
|
|
@@ -30,16 +36,19 @@ func startSQSServer( | |
| partitionObserver adapter.SQSPartitionObserver, | ||
| ) (*adapter.SQSServer, error) { | ||
| sqsAddr = strings.TrimSpace(sqsAddr) | ||
| if sqsAddr == "" { | ||
| return nil, nil | ||
| } | ||
| sqsL, err := lc.Listen(ctx, "tcp", sqsAddr) | ||
| if err != nil { | ||
| return nil, errors.Wrapf(err, "failed to listen on %s", sqsAddr) | ||
| var sqsL net.Listener | ||
| if sqsAddr != "" { | ||
| var err error | ||
| sqsL, err = lc.Listen(ctx, "tcp", sqsAddr) | ||
| if err != nil { | ||
| return nil, errors.Wrapf(err, "failed to listen on %s", sqsAddr) | ||
| } | ||
| } | ||
| staticCreds, err := loadSigV4StaticCredentialsFile(credentialsFile, "sqs") | ||
| if err != nil { | ||
| _ = sqsL.Close() | ||
| if sqsL != nil { | ||
| _ = sqsL.Close() | ||
| } | ||
|
Comment on lines
47
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎. |
||
| return nil, err | ||
| } | ||
| sqsServer := adapter.NewSQSServer( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error from
sqsL.Close()is silently ignored. According to the general rules, errors fromClose()methods on resources like network listeners should be logged to ensure that resource leaks or other cleanup problems are visible to operators.References