Skip to content

Commit

Permalink
x-pack/filebeat/input/httpjson: document handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
efd6 committed Sep 6, 2023
1 parent 5ad7624 commit d178014
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions x-pack/filebeat/input/httpjson/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ func (r *requester) processRemainingChainEvents(stdCtx context.Context, trCtx *t
return p.eventCount()
}

// chainProcessor is a chained processing handler.
type chainProcessor struct {
req *requester
trCtx *transformContext
Expand All @@ -566,6 +567,7 @@ func newChainProcessor(req *requester, trCtx *transformContext, pub inputcursor.
}
}

// handleEvents processes msg as a request body in an execution chain.
func (p *chainProcessor) handleEvent(ctx context.Context, msg mapstr.M) {
if !p.tail {
// Skip first event as it has already been processed.
Expand Down Expand Up @@ -606,6 +608,7 @@ func (p *chainProcessor) handleError(err error) {
p.req.log.Errorf("error processing response: %v", err)
}

// eventCount returns the number of events that have been processed.
func (p *chainProcessor) eventCount() int {
return p.n
}
Expand Down Expand Up @@ -722,6 +725,7 @@ func generateNewUrl(replacement, oldUrl, id string) (url.URL, error) {
return *newUrl, nil
}

// publisher is an event publication handler.
type publisher struct {
trCtx *transformContext
pub inputcursor.Publisher
Expand All @@ -740,6 +744,7 @@ func newPublisher(trCtx *transformContext, pub inputcursor.Publisher, publish bo
}
}

// handleEvent publishes msg to the publishers backing inputcursor.Publisher.
func (p *publisher) handleEvent(_ context.Context, msg mapstr.M) {
if p.pub != nil {
event, err := makeEvent(msg)
Expand All @@ -762,10 +767,12 @@ func (p *publisher) handleEvent(_ context.Context, msg mapstr.M) {
p.n++
}

// handleError logs err.
func (p *publisher) handleError(err error) {
p.log.Errorf("error processing response: %v", err)
}

// eventCount returns the number of successfully published events.
func (p *publisher) eventCount() int {
return p.n
}
Expand Down

0 comments on commit d178014

Please sign in to comment.