Code Monkey home page Code Monkey logo

rubberband's Introduction

RubberBand

Build Status Code Climate

An ElasticSearch client with ThriftClient-like failover handling.

License

Copyright 2010-2012 Grant Rodgers. See included LICENSE file.

Features

  • Automatic failover, retry, and peer discovery
  • Support for multiple transports (HTTP, Thrift, Memcached)
  • Support for multiple encodings (JSON, Smile TODO)

Rubberband uses MultiJson for JSON encoding and decoding and supports all JSON backends that MultiJson supports.

The HTTP transport uses Faraday, which also supports a number of http backends. Choose the one that works best for you.

Supported Rubies

Tested on 1.8.7, 1.9.2, 1.9.3, and Rubinius in 1.8 and 1.9 mode. Ruby 1.8.6 is NOT supported due to missing String#bytesize.

Usage

Instantiate a client:

client = ElasticSearch.new('http://127.0.0.1:9200', :index => "twitter", :type => "tweet")

Instantiate a client with multiple servers:

client = ElasticSearch.new(['127.0.0.1:9200', '127.0.0.1:9201'])

Instantiate a client using a Heroku URL (this sets the default index):

client = ElasticSearch.new(ENV['ELASTICSEARCH_URL'])

Connect using the thrift transport (requires the thrift gem and elasticsearch thrift plugin to be installed):

client = ElasticSearch.new('127.0.0.1:9500', :transport => ElasticSearch::Transport::Thrift)

Pass a block to Faraday to configure middleware and options:

  client = ElasticSearch::Client.new('127.0.0.1:9200') do |conn|
    conn.response :logger
    conn.adapter Faraday.default_adapter
  end

API:

  client.default_index = "test_index"
  client.default_type  = "test_type"
  client.index({:body => "elasticsearch is cool"}, :id => 1)  
  client.get("1")  
  client.search("body:elasticsearch")  

TODO

See TODO file.

Contributing

http://github.com/grantr/rubberband

Fork, code, send pull request

rubberband's People

Contributors

adammck avatar courtenay avatar dougal avatar edmundsalvacion avatar erickt avatar grantr avatar jeroig avatar mauricio avatar rb2k avatar rlivsey avatar speedmax avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.