Skip to content

Commit

Permalink
x-pack/filebeat/input/httpjson: reduce name stutter
Browse files Browse the repository at this point in the history
  • Loading branch information
efd6 committed Sep 6, 2023
1 parent 9619329 commit c678c7c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions x-pack/filebeat/input/httpjson/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func run(ctx v2.Context, cfg config, pub inputcursor.Publisher, crsr *inputcurso

metrics := newInputMetrics(reg)

httpClient, err := newHTTPClient(stdCtx, cfg, log, reg)
client, err := newHTTPClient(stdCtx, cfg, log, reg)
if err != nil {
return err
}
Expand All @@ -144,9 +144,9 @@ func run(ctx v2.Context, cfg config, pub inputcursor.Publisher, crsr *inputcurso
return err
}
}
pagination := newPagination(cfg, httpClient, log)
pagination := newPagination(cfg, client, log)
responseProcessor := newResponseProcessor(cfg, pagination, xmlDetails, metrics, log)
requester := newRequester(httpClient, requestFactory, responseProcessor, log)
requester := newRequester(client, requestFactory, responseProcessor, log)

trCtx := emptyTransformContext()
trCtx.cursor = newCursor(cfg.Cursor, log)
Expand Down
8 changes: 4 additions & 4 deletions x-pack/filebeat/input/httpjson/pagination.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import (
const paginationNamespace = "pagination"

type pagination struct {
httpClient *httpClient
client *httpClient
requestFactory *requestFactory
decoder decoderFunc
log *logp.Logger
}

func newPagination(config config, httpClient *httpClient, log *logp.Logger) *pagination {
pagination := &pagination{httpClient: httpClient, log: log}
func newPagination(config config, client *httpClient, log *logp.Logger) *pagination {
pagination := &pagination{client: client, log: log}
if config.Response == nil {
return pagination
}
Expand Down Expand Up @@ -138,7 +138,7 @@ func (iter *pageIterator) next() (*response, bool, error) {
}

//nolint:bodyclose // response body is closed through drainBody method
resp, err := iter.pagination.httpClient.do(iter.stdCtx, httpReq)
resp, err := iter.pagination.client.do(iter.stdCtx, httpReq)
if err != nil {
return nil, false, err
}
Expand Down
18 changes: 9 additions & 9 deletions x-pack/filebeat/input/httpjson/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ func (rf *requestFactory) collectResponse(ctx context.Context, trCtx *transformC
return nil, fmt.Errorf("failed to create http request: %w", err)
}

if rf.isChain && rf.chainHTTPClient != nil {
httpResp, err = rf.chainHTTPClient.do(ctx, req)
if rf.isChain && rf.chainClient != nil {
httpResp, err = rf.chainClient.do(ctx, req)
if err != nil {
return nil, fmt.Errorf("failed to execute chain http client.Do: %w", err)
}
Expand Down Expand Up @@ -258,7 +258,7 @@ func (c *httpClient) do(ctx context.Context, req *http.Request) (*http.Response,
}

type requestFactory struct {
chainHTTPClient *httpClient
chainClient *httpClient
url url.URL
method string
body *mapstr.M
Expand Down Expand Up @@ -309,7 +309,7 @@ func newRequestFactory(ctx context.Context, config config, log *logp.Logger, met
if ch.Step != nil {
ts, _ := newBasicTransformsFromConfig(registeredTransforms, ch.Step.Request.Transforms, requestNamespace, log)
ch.Step.Auth = tryAssignAuth(config.Auth, ch.Step.Auth)
httpClient, err := newChainHTTPClient(ctx, ch.Step.Auth, ch.Step.Request, log, reg)
client, err := newChainHTTPClient(ctx, ch.Step.Auth, ch.Step.Request, log, reg)
if err != nil {
return nil, fmt.Errorf("failed in creating chain http client with error : %w", err)
}
Expand All @@ -318,7 +318,7 @@ func newRequestFactory(ctx context.Context, config config, log *logp.Logger, met
rf.password = ch.Step.Auth.Basic.Password
}

responseProcessor := newChainResponseProcessor(ch, httpClient, xmlDetails, metrics, log)
responseProcessor := newChainResponseProcessor(ch, client, xmlDetails, metrics, log)

rf = &requestFactory{
url: *ch.Step.Request.URL.URL,
Expand All @@ -330,14 +330,14 @@ func newRequestFactory(ctx context.Context, config config, log *logp.Logger, met
replace: ch.Step.Replace,
replaceWith: ch.Step.ReplaceWith,
isChain: true,
chainHTTPClient: httpClient,
chainClient: client,
chainResponseProcessor: responseProcessor,
}
} else if ch.While != nil {
ts, _ := newBasicTransformsFromConfig(registeredTransforms, ch.While.Request.Transforms, requestNamespace, log)
policy := newHTTPPolicy(evaluateResponse, ch.While.Until, log)
ch.While.Auth = tryAssignAuth(config.Auth, ch.While.Auth)
httpClient, err := newChainHTTPClient(ctx, ch.While.Auth, ch.While.Request, log, reg, policy)
client, err := newChainHTTPClient(ctx, ch.While.Auth, ch.While.Request, log, reg, policy)
if err != nil {
return nil, fmt.Errorf("failed in creating chain http client with error : %w", err)
}
Expand All @@ -346,7 +346,7 @@ func newRequestFactory(ctx context.Context, config config, log *logp.Logger, met
rf.password = ch.While.Auth.Basic.Password
}

responseProcessor := newChainResponseProcessor(ch, httpClient, xmlDetails, metrics, log)
responseProcessor := newChainResponseProcessor(ch, client, xmlDetails, metrics, log)
rf = &requestFactory{
url: *ch.While.Request.URL.URL,
method: ch.While.Request.Method,
Expand All @@ -358,7 +358,7 @@ func newRequestFactory(ctx context.Context, config config, log *logp.Logger, met
replaceWith: ch.While.ReplaceWith,
until: ch.While.Until,
isChain: true,
chainHTTPClient: httpClient,
chainClient: client,
chainResponseProcessor: responseProcessor,
}
}
Expand Down
4 changes: 2 additions & 2 deletions x-pack/filebeat/input/httpjson/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ func newResponseProcessor(config config, pagination *pagination, xmlDetails map[
return rps
}

func newChainResponseProcessor(config chainConfig, httpClient *httpClient, xmlDetails map[string]xml.Detail, metrics *inputMetrics, log *logp.Logger) *responseProcessor {
pagination := &pagination{httpClient: httpClient, log: log}
func newChainResponseProcessor(config chainConfig, client *httpClient, xmlDetails map[string]xml.Detail, metrics *inputMetrics, log *logp.Logger) *responseProcessor {
pagination := &pagination{client: client, log: log}

rp := &responseProcessor{
pagination: pagination,
Expand Down

0 comments on commit c678c7c

Please sign in to comment.