Project

octoparts

0.0
Low commit activity in last 3 years
A long-lived project that still receives updates
Ruby client library for the Octoparts API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
~> 13.0.6
~> 3.0
>= 0

Runtime

 Project Readme

Octoparts

Gem Version Build Status

Octoparts Client for Ruby

Octoparts is the backend services aggregator. See more details here.

Installation

Add this line to your application's Gemfile:

gem 'octoparts'

And then execute:

$ bundle

Or install it yourself as:

$ gem install octoparts

Usage

# configuration
Octoparts.configure do |config|
  config.endpoint = 'http://localhost:9000'
  config.timeout_sec = 3       # open/read timeout in seconds
  config.open_timeout_sec = 1  # connection open timeout in seconds
end

# create client
client = Octoparts::Client.new

# invoke aggregate request with Hash
response = client.invoke({
  request_meta: {
    id: "test",
    timeout: 500
  },
  requests: [
    {
      part_id: "echo",
      params: [
        {
          key: "fooValue",
          value: "test"
        }
      ]
    }
  ]
})

response.status
response.body.responses.first.contents

# invoke with builder
aggregate_request = Octoparts.build_aggregate_request do
  request_meta(id: 'test', timeout: 500)
  requests do
    part_request(part_id: 'echo').add_param('fooValue', 'test')
  end
end
response = client.invoke(aggregate_request)

# cache invalidation
## post /octoparts/2/cache/invalidate/part/echo/fooValue/test
client.invalidate_cache('echo', param_name: 'fooValue', param_value: 'test')

## post /octoparts/2/cache/invalidate/cache-group/echo_group/params/fooValue
client.invalidate_cache_group('echo_group', param_value: 'fooValue')

Contributing

  1. Fork it ( https://github.com/m3dev/octoparts/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request