Skip to content
A minimum-viable Amazon Web Services (AWS) client
Ruby
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
spec
.gitignore
.travis.yml
Gemfile
Guardfile
LICENSE
README.md
Rakefile
jeff.gemspec

README.md

Jeff

Jeff is a light-weight module that mixes in client behaviour for Amazon Web Services (AWS). It wraps the HTTP adapter Excon and implements Signature Version 2.

jeff

Usage

Here's a hypothetical client.

class Client
  include Jeff
end

Customise default headers and parameters.

class Client
  headers 'User-Agent' => 'Client'
  params  'Service'    => 'SomeService',
          'Tag'        => -> { tag }

  attr_accessor :tag
end

Set an AWS endpoint and credentials.

client = Client.new.tap do |config|
  config.endpoint = 'http://example.com/path'
  config.key      = 'key'
  config.secret   = 'secret'
end

You should now be able to access the endpoint.

client.post query: {},
            body:  'data'

Chunked Requests

You can upload large files performantly by passing a proc that delivers chunks.

file = File.open 'data'
chunker = -> { file.read Excon::CHUNK_SIZE).to_s }

client.post query:         {},
            request_block: chunker

Streaming Responses

Similarly, you can download and parse large files performantly by passing a block that will receive chunks.

streamer = ->(chunk, remaining, total) { puts chunk }

client.get query:          {},
           response_block: streamer

Instrumentation

Requests can be instrumented.

class Logger
  def self.instrument(name, params = {})
    if name =~ /request/
      $stderr.puts [
        params[:scheme],
        '://',
        params[:host],
        '/',
        params[:path],
        '?',
        params[:query]
      ].join
      yield if block_given?
    end
  end
end

client.get query:        {},
           instrumentor: Logger

Miscellaneous

HTTP connections are persistent.

By default, Jeff will retry failed requests 4 times.

For more detailed configuration options, check out excon.

Compatibility

Jeff is Ruby 1.9-compatible. It is tested against MRI 1.9.3 plus JRuby and Rubinius in 1.9 mode.

Something went wrong with that request. Please try again.