Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch API requests to ReadMe #48

Merged
merged 1 commit into from
Aug 19, 2020
Merged

Batch API requests to ReadMe #48

merged 1 commit into from
Aug 19, 2020

Conversation

thestrabusiness
Copy link
Contributor

🧰 What's being changed?

This commit adds simple request batching behavior to the middleware.

Previously, each request made to an application using this middleware
would cause a new request to be sent to the ReadMe API. A new
RequestQueue object was introduced to collect requests and provide a
batched response to send out when ready.

The batch size can be controlled by the user using the buffer_length
option. It defaults to 10.

🧪 Testing

Both unit and integrations tests were added to cover the new functionality.

Using the following sample application and curl request, we confirmed that middleware appropriately batches the requests.

curl 'http://localhost:9292/api/foo?id=1&name=joel' -H "X-Filtered: my custom header" -H "Content-Type: application/json" -X POST -d '{"key": "value", "dont_filter": "not filtered"}'

$LOAD_PATH << File.expand_path("../../metrics-sdks/packages/ruby/lib", __FILE__)
require "readme/metrics"

class ApiApp
  def call(env)
    [200, {}, ["Ok"]]
  end
end

map "/api" do
  options = {
    api_key: "YOUR_API_KEY",
    development: false
  }
  use Readme::Metrics, options do |env|
    {id: "anthonym", label: "Anthony M.", email: "[email protected]"}
  end
  run ApiApp.new
end

@thestrabusiness thestrabusiness requested a review from JoelQ August 18, 2020 21:51
This commit adds simple request batching behavior to the middleware.

Previously, each request made to an application using this middleware
would cause a new request to be sent to the ReadMe API. A new
`RequestQueue` object was introduced to collect requests and provide a
batched response to send out when ready.

The batch size can be controlled by the user using the `buffer_length`
option. It defaults to 10.
@thestrabusiness thestrabusiness merged commit 6846492 into master Aug 19, 2020
@thestrabusiness thestrabusiness deleted the am-request-queue branch August 19, 2020 14:42
djmango pushed a commit to djmango/metrics-sdks that referenced this pull request Sep 19, 2023
…admeio#48)

* chore(deps-dev): Bump @readme/eslint-config from 1.14.0 to 1.15.0

Bumps [@readme/eslint-config](https://github.com/readmeio/eslint-config) from 1.14.0 to 1.15.0.
- [Release notes](https://github.com/readmeio/eslint-config/releases)
- [Changelog](https://github.com/readmeio/eslint-config/blob/master/CHANGELOG.md)
- [Commits](readmeio/standards@1.14.0...1.15.0)

Signed-off-by: dependabot-preview[bot] <[email protected]>

* style: resolving some eslint issues

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Jon Ursenbach <[email protected]>
@erunion erunion added ruby Issues related to our Ruby SDK and removed area:ruby labels Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ruby Issues related to our Ruby SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants