netflix / batch_request_api Goto Github PK
View Code? Open in Web Editor NEWRuby Middleware to provide Batch operations on Rails applications
License: Apache License 2.0
Ruby Middleware to provide Batch operations on Rails applications
License: Apache License 2.0
Hi,
I would like to know is this Middleware production ready ? Since there is not much happening here in terms of development.
I would like to use it on Rails 6.
Thanks.
Known issue. Fix coming up soon.
Hi,
How can I get the batch values when I am in the controller ?
I am using batch_sequential, I can see the payload is correct using request.body.read.
After inspecting the source code of the gem, I have no clue how to obtain the correct payload.
I am using the ember addon
initializer:
Rails.application.config do |config|
config.batch_sequential_paths = ['batch_sequential'] # ['/api/v1/batch_sequential']
config.batch_parallel_paths = nil # ['/api/v1/batch_parallel']
end
controller:
class BatchSequentialController < ApplicationController
def create
puts JSON.parse(request.body.read.to_json)
byebug
end
Something like:
"requests": [
{
"method": "POST",
"url": "/api/v1/movies",
"body": { },
"headers": { }
}
]
}
Hi all,
I was wondering if you could use concurrent-ruby to improve concurrency of the batch import.
It is also possible to expose a config variable to control maximum concurrency for the batch importing.
Previously we used arsduo's batch_api
gem to implement similar functionality but it wasn't maintained for a long while and never supports parallel requests.
One main different between that and batch_request_api
is a slightly different payload format:
{
ops: [
{method: "get", url: "/patrons"},
{method: "post", url: "/orders/new", params: {dish_id: 123}},
{method: "get", url: "/oh/no/error", headers: {break: "fast"}},
{method: "delete", url: "/patrons/456"}
],
sequential: true
}
v.s.
{
"requests": [
{
"method": "POST",
"url": "/api/v1/movies",
"body": { }, { }
}
]
}
{
results: [
{status: 200, body: [{id: 1, name: "Jim-Bob"}, ...], headers: {}},
{status: 201, body: {id: 4, dish_name: "Spicy Crab Legs"}, headers: {}},
{status: 500, body: {error: {oh: "noes!"}}, headers: {Problem: "woops"}},
{status: 200, body: null, headers: {}}}
]
}
v.s.
[
{"status"=>200, "headers"=>{}, "response"=>{}},
{"status"=>200, "headers"=>{}, "response"=>{}}
]
I believe there're some other users of batch_api
would want to migrate to batch_request_api
as well.
I propose two ways, and please let me know how you think:
requests
/ results
)A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.