Module: Shydra
- Defined in:
- lib/shydra/hydra.rb,
lib/shydra.rb,
lib/shydra/batch.rb,
lib/shydra/request.rb,
lib/shydra/version.rb,
lib/shydra/resource.rb,
lib/shydra/response.rb,
lib/shydra/resources/product.rb,
lib/shydra/resources/variant.rb,
lib/shydra/resources/metafield.rb
Overview
Scenarios:
1. request that might return more than 250
- limit: :none
- adds callback that fetches another page if result size == SHOPIFY_API_MAX_LIMIT
2. request that will return several pages that needs to be fast
- use a hydra
- does count first
- queues request for each page, callback inserts into correct slot in result_array
- if too many pages for api limit, fetch as many pages as possible, then sleep for some amount of time
- time to sleep: requests-used-before-starting / API-LIMIT
- at the end flatten the result_array
API LIMIT
- memcached
- cache {used: x, at: Time.now}
- before starting hydra:
- count requests
- check cache
- if at < TUNEABLE_PARAM (like, 20 seconds) & enough requests (including TUNEABLE_BUFFER)
- run everything
- do_run: run 1 request. update cache
- if enough requests, run everything
- else bail or sleep(time allowed)
- after sleeping time allowed, goto: do_run
- because requests may have callbacks that queue other requests, the run_loop has to go through this alogrithm every time it pulls a new batch of requests off
Defined Under Namespace
Modules: Resources, Response Classes: Batch, Hydra, Request, Resource
Constant Summary collapse
- VERSION =
"0.4.2"
Class Attribute Summary collapse
-
.max_concurrency ⇒ Object
Returns the value of attribute max_concurrency.
Class Attribute Details
.max_concurrency ⇒ Object
Returns the value of attribute max_concurrency.
15 16 17 |
# File 'lib/shydra.rb', line 15 def max_concurrency @max_concurrency end |