Skip to content

service: add oauth2 and retry field constructors - #513

Merged
JakeSCahill merged 1 commit into
mainfrom
docs/export-shared-fields
Sep 30, 2026
Merged

JakeSCahill merged 1 commit into
mainfrom
docs/export-shared-fields

Conversation

@JakeSCahill

@JakeSCahill JakeSCahill commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Why

Redpanda Connect publishes its reference docs from field descriptions, and a Connect test fails when the same field is described in more than one place. Connect's internal/oauth2 and internal/retries forked the benthos field definitions, so a fix on one side never reached the other.

What changes

Following review, plugins now build these fields with shared constructors instead of copying each subfield:

  • NewOAuth2Field(name string) *ConfigField: the full oauth2 object (enabled, client_key, client_secret, token_url, scopes, endpoint_params), optional and advanced. The field names are unchanged, so plugins keep reading the children by name.
  • NewMaxRetriesField(defaultMaxRetries int) *ConfigField: max_retries, where zero means no limit.
  • NewRetryBackOffFields(defaultMaxRetries int, defaults *backoff.ExponentialBackOff) []*ConfigField: max_retries plus the backoff object. It takes the same defaults as NewBackOffField, and nil uses that function's defaults.

benthos uses them too. internal/httpclient drops its OAuth2 spec, and the retry output drops internal/retries.CommonRetryBackOffFields.

Wording changes:

  • oauth2 now says how to exchange a refresh token through endpoint_params, which the code already supports.
  • endpoint_params has a realistic audience and resource example.
  • backoff describes the exponential backoff.

Build, tests for the touched packages (including a new config_retries_test.go), and lint pass. Lint reports only the four existing issues in processor_workflow_test.go. The CHANGELOG has an Unreleased entry. redpanda-data/connect#4877 switches Connect over.

@claude

claude Bot commented Sep 27, 2026

Copy link
Copy Markdown

Commits
LGTM

Review
Adds exported description constants to public/service for the retry backoff fields, the oauth2 fields and the TLS root_cas_file field, and switches internal/retries, internal/httpclient and internal/tls over to them. Field names, defaults and flags are unchanged; only the description text changes. The internal packages already imported public/service, and TLSRootCASFileDescription re-exports the internal/tls constant, so this adds no import cycle. The CHANGELOG entry is included.

LGTM

@JakeSCahill
JakeSCahill requested a review from Jeffail September 27, 2026 18:08

@Jeffail Jeffail left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Rather than exporting the docs as consts it might be cleaner to move plugins into using a common NewOAuth2Field etc with parameters for the defaults they need to customize, in which case they wouldn't need to manually specify custom variants of each subfield. Could we try that instead?

NewOAuth2Field, NewRetryBackOffFields and NewMaxRetriesField define the fields that the http components and the retry output use, so plugins can reuse them instead of copying each subfield.
@JakeSCahill JakeSCahill changed the title service: export retry, oauth2, and tls root_cas_file field descriptions service: add oauth2 and retry field constructors Sep 30, 2026
@JakeSCahill
JakeSCahill force-pushed the docs/export-shared-fields branch from d4ed6ae to c32f009 Compare September 30, 2026 11:36
@claude

claude Bot commented Sep 30, 2026

Copy link
Copy Markdown

Commits
LGTM

Review
Moves the oauth2 object and the max_retries/backoff retry fields into public service constructors (NewOAuth2Field, NewRetryBackOffFields, NewMaxRetriesField). The internal callers (httpclient.AuthFieldSpecsExpanded, the retry output) now use them. Field names still match the parsers in internal/httpclient and internal/retries. The retry output defaults (500ms/3s/0s) are unchanged, and the fallback defaults match NewBackOffField. There is a unit test for the new retry fields.

LGTM

@JakeSCahill
JakeSCahill requested a review from Jeffail September 30, 2026 11:41
@JakeSCahill
JakeSCahill merged commit cd2c3eb into main Sep 30, 2026
4 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.

2 participants