Skip to content

Conversation

thomas-bousquet
Copy link
Contributor

@thomas-bousquet thomas-bousquet commented Sep 25, 2025

Motivation

The admin client does not carry / accept the context context.Context. Accepting a context as a first parameter is a Go idiom, and can be useful when the caller wants to set a request timeout instead of tracking manually a timeout with separate goroutine.

Modifications

In order to accept that context and make this a non-breaking change, a WithContext() method equivalent is added to each of the methods in the admin client. Existing methods are now calling internally the WithContext() method, with a context.Background() for the required context.

Verifying this change

This change can be verified with existing E2E tests on the admin client for regression.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API: no
  • The schema: no
  • The default values of configurations: no
  • The wire protocol: no

Documentation

  • Does this pull request introduce a new feature? no

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds context support to the Pulsar admin client by introducing WithContext() methods for all admin operations. This enables proper request timeout control and context-based cancellation following Go idioms.

Key changes:

  • Adds context parameter to all HTTP client methods in the REST client
  • Introduces WithContext() equivalent methods for all admin interfaces
  • Updates existing methods to call the new context-enabled methods with context.Background()

Reviewed Changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
pulsaradmin/pkg/rest/client.go Modified core HTTP client to accept context parameter in all request methods
pulsaradmin/pkg/admin/tenant.go Added WithContext() methods for tenant operations
pulsaradmin/pkg/admin/subscription.go Added context support for subscription management operations
pulsaradmin/pkg/admin/sources.go Added context-enabled methods for source connector operations
pulsaradmin/pkg/admin/sinks.go Added context support for sink connector management
pulsaradmin/pkg/admin/schema.go Added WithContext() methods for schema operations
pulsaradmin/pkg/admin/resource_quotas.go Added context support for resource quota management
pulsaradmin/pkg/admin/packages.go Added context-enabled methods for package operations
pulsaradmin/pkg/admin/ns_isolation_policy.go Added context support for namespace isolation policy operations
pulsaradmin/pkg/admin/namespace.go Added WithContext() methods for extensive namespace operations
pulsaradmin/pkg/admin/functions_worker.go Added context support for function worker operations
pulsaradmin/pkg/admin/functions.go Added context-enabled methods for function management
pulsaradmin/pkg/admin/cluster.go Added WithContext() methods for cluster operations
pulsaradmin/pkg/admin/brokers_test.go Updated test to use context-enabled method
pulsaradmin/pkg/admin/brokers.go Added context support for broker operations
pulsaradmin/pkg/admin/broker_stats.go Added WithContext() methods for broker statistics

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@thomas-bousquet thomas-bousquet requested a review from nodece October 9, 2025 20:14
Copy link
Member

@crossoverJie crossoverJie left a comment

Choose a reason for hiding this comment

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

LGTM, please fix the CI check.

@thomas-bousquet
Copy link
Contributor Author

Just fixed the last linter issues, I was not getting these locally with make lint. Should be ok now.

@nodece nodece requested a review from Copilot October 10, 2025 04:11
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@nodece
Copy link
Member

nodece commented Oct 10, 2025

TODO: Marking the old method as deprecated is a better approach.

@nodece nodece added this to the v0.17.0 milestone Oct 10, 2025
@nodece nodece merged commit d19a9f8 into apache:master Oct 10, 2025
7 checks passed
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