Repository navigation
service: add oauth2 and retry field constructors - #513
Conversation
|
Commits Review LGTM |
Jeffail
left a comment
There was a problem hiding this comment.
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.
d4ed6ae to
c32f009
Compare
|
Commits Review LGTM |
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/oauth2andinternal/retriesforked 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 fulloauth2object (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_retriesplus thebackoffobject. It takes the same defaults asNewBackOffField, and nil uses that function's defaults.benthos uses them too.
internal/httpclientdrops its OAuth2 spec, and theretryoutput dropsinternal/retries.CommonRetryBackOffFields.Wording changes:
oauth2now says how to exchange a refresh token throughendpoint_params, which the code already supports.endpoint_paramshas a realisticaudienceandresourceexample.backoffdescribes 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 inprocessor_workflow_test.go. The CHANGELOG has an Unreleased entry. redpanda-data/connect#4877 switches Connect over.