Giter VIP home page Giter VIP logo

rubberlike's Introduction

Rubberlike

Rubberlike is a Clojure library for creating embedded Elasticsearch servers. Pretty useful for testing if I may say so myself.

Latest version is [rubberlike "0.2.1"].

Rubberlike requires Java >= 1.7 and quite possibly Elasticsearch >= 1.4.x.

Elasticsearch is not included as a dependency in Rubberlike so you would have to pull it in yourself, e.g. [org.elasticsearch/elasticsearch "1.4.0"].

Usage

All functions reside in the rubberlike.core namespace.

create creates and starts an embedded Elasticsearch server instance. Invoking create with no arguments will create a temporary directory for data storage, as well as bind the server instance to a dynamically allocated port.

Alternatively, create can be invoked with a map of configuration parameters. These are:

  • port to define which port Elasticsearch will bind to.
  • host to define which host Elasticsearch will bind to.
  • data-dir pointing to the directory where data is to be stored.
  • temp-data-dir? which if set to true will tell Rubberlike to create a temporary data directory for you.
  • disable-http? which will stop Rubberlike from launching a HTTP interface for your instance when set to true.

The object returned from create is to be provided as the sole argument to the following functions.

port will give you the server port, which will come in handy if the port is not specified in the call to create and thus is dynamically allocated.

There is also a client function which will give you an instance of org.elasticsearch.client.Client for use with Elasticsearch's native API.

The server can be stopped by calling stop. If temp-data-dir? in the call to create was set to true, the data directory will be deleted upon calling stop.

Let's summarize this with an example:

(require '[rubberlike.core :refer [create stop port]])

;; Create and start a new server.

> (def server (create))
#'user/server

;; Port is dynamically allocated as we didn't specify one. Let's get a hold of it.

> (port server)
9212

;; Assuming we've done our thing with this instance, let's tear it down.

> (stop server)
:stopped

License

Copyright © 2014 Anders Furseth

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

rubberlike's People

Contributors

duckyuck avatar

Watchers

Magnus Rundberget avatar James Cloos avatar  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.