lib/logstash/outputs/httpbatch.rb
def receive(events, async_type=:background)
    body = event_body(events)

    # Block waiting for a token
    token = @request_tokens.pop if async_type == :background

    # Send the request
    url = @url
    headers = event_headers()

    # Create an async request
    request = client.send(async_type).send(@http_method, @url, :body => body, :headers => headers)

    request.on_complete do
      # Make sure we return the token to the pool
      @request_tokens << token  if async_type == :background
    end

    request.on_success do |response|
      if response.code < 200 || response.code > 299
        log_failure(
          "Encountered non-200 HTTP code #{response.code}",
          :response_code => response.code,
          :url => url)
      end
    end

    request.on_failure do |exception|
      log_failure("Could not fetch URL",
                  :url => url,
                  :method => @http_method,
                  :body => body,
                  :headers => headers,
                  :message => exception.message,
                  :class => exception.class.name,
                  :backtrace => exception.backtrace
      )
    end

    request.call if async_type == :background
  end
# Once we no longer need to support Logstash < 2.2 (pre-ng-pipeline)
# We don't need to handle :background style requests
#
# We use :background style requests for Logstash < 2.2 because before the microbatching
# pipeline performance is greatly improved by having some degree of async behavior.
#
# In Logstash 2.2 and after things are much simpler, we just run each batch in parallel
# This will make performance much easier to reason about, and more importantly let us guarantee
# that if `multi_receive` returns all items have been sent.
Once we no longer need to support Logstash < 2.2 (pre-ng-pipeline)
We don't need to handle :background style requests

We use :background style requests for Logstash < 2.2 because before the microbatching
pipeline performance is greatly improved by having some degree of async behavior.

In Logstash 2.2 and after things are much simpler, we just run each batch in parallel
This will make performance much easier to reason about, and more importantly let us guarantee
that if `multi_receive` returns all items have been sent.
Once we no longer need to support Logstash < 2 . 2 ( pre - ng - pipeline ) We don ' t need to handle : background style requests We use : background style requests for Logstash < 2 . 2 because before the microbatching pipeline performance is greatly improved by having some degree of async behavior . In Logstash 2 . 2 and after things are much simpler we just run each batch in parallel This will make performance much easier to reason about and more importantly let us guarantee that if ` multi_receive ` returns all items have been sent .
def receive(events, async_type=:background)
    body = event_body(events)
    token = @request_tokens.pop if async_type == :background
    url = @url
    headers = event_headers()
    request = client.send(async_type).send(@http_method, @url, :body => body, :headers => headers)
    request.on_complete do
      @request_tokens << token  if async_type == :background
    end
    request.on_success do |response|
      if response.code < 200 || response.code > 299
        log_failure(
          "Encountered non-200 HTTP code #{response.code}",
          :response_code => response.code,
          :url => url)
      end
    end
    request.on_failure do |exception|
      log_failure("Could not fetch URL",
                  :url => url,
                  :method => @http_method,
                  :body => body,
                  :headers => headers,
                  :message => exception.message,
                  :class => exception.class.name,
                  :backtrace => exception.backtrace
      )
    end
    request.call if async_type == :background
  end
def receive ( events , async_type = :background ) body = event_body ( events ) token = @request_tokens . pop if async_type == :background url = @url headers = event_headers ( ) request = client . send ( async_type ) . send ( @http_method , @url , :body => body , :headers => headers ) request . on_complete do @request_tokens << token if async_type == :background end request . on_success do | response | if response . code < 200 || response . code > 299 log_failure ( "Encountered non-200 HTTP code #{response.code}" , :response_code => response . code , :url => url ) end end request . on_failure do | exception | log_failure ( "Could not fetch URL" , :url => url , :method => @http_method , :body => body , :headers => headers , :message => exception . message , :class => exception . class . name , :backtrace => exception . backtrace ) end request . call if async_type == :background end
Once we no longer need to support Logstash < 2.2 (pre-ng-pipeline)
We don't need to handle :background style requests
Once we no longer need to support Logstash < 2 . 2 ( pre - ng - pipeline ) We don ' t need to handle : background style requests
# Block waiting for a token # Send the request # Create an async request # Make sure we return the token to the pool
events
async_type