ruby-amqp / rabbitmq_http_api_client

RabbitMQ HTTP API client for Ruby
MIT License
79 stars 49 forks source link

support optional parameters, e.g. columns #29

Closed msayler closed 4 years ago

msayler commented 7 years ago

Per RMQ Management HTTP API:

Many URIs return lists. [...] You can also restrict what information is returned per item with the columns parameter. This is a comma-separated list of subfields separated by dots. See the example below.

It would be great if I could, for example, say something likeclient.list_queues(:columns=>["name","messages"]) This particular use case can reduce both client and server load when incurred when doing monitoring checks using the client for clusters with 100s or 1000s of queues.

michaelklishin commented 7 years ago

I wouldn't expect effect beyond JSON serialization taking less time because columns are filtered out after querying and most of the time is spend loading and aggregating a lot of data that sorting might require.

msayler commented 7 years ago

Fair that it might be equivalent load on the server, but it definitely reduces load on the client when using this library. We measured a 3MB JSON output for /api/queues returning ~1500 items. The list_queues call took about 13 seconds of wall clock time at ~100% CPU on a c4.large instance in AWS. After returning only the needed columns, the wall-clock time for the whole process of connect, retrieve, and filter was less than a second.

msayler commented 7 years ago

I'm happy to put a change together, BTW. I just wanted to see whether it had a chance of landing.

michaelklishin commented 7 years ago

I don't have any objections if we can avoid breaking the API.

sharshenov commented 4 years ago

Fixed by https://github.com/ruby-amqp/rabbitmq_http_api_client/pull/43

client.list_queues(vhost, columns: 'name,messages')
# or for default vhost
client.list_queues(nil, columns: 'name,messages')
michaelklishin commented 4 years ago

Thanks @sharshenov 👍