GithubHelp home page GithubHelp logo

sqor / riak-rabbitmq-commit-hooks Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jbrisbin/riak-rabbitmq-commit-hooks

0.0 3.0 0.0 191 KB

Riak RabbitMQ commit hooks

Makefile 13.54% Erlang 86.46%

riak-rabbitmq-commit-hooks's Introduction

Riak RabbitMQ postcommit hook

This is a postcommit hook that sends entries into a RabbitMQ broker using the Erlang AMQP client.

You set this module/function as your postcommit hook using whatever tools you're used to. Your bucket properties should look something like this:

{
  "props":{
    "postcommit":[{"mod":"riak_rabbitmq","fun":"postcommit_send_amqp"}],
    ... other props ...
  }
}

Installation

To install from the binary (compiled with Erlang R14B03), download the tar.gz file. cd into the Riak lib directory. For example, Homebrew users on a Mac would:

cd /usr/local/Cellar/riak/1.0.0/libexec/lib
tar -zxvf $HOME/Downloads/riak_rabbitmq-0.1.4-R14B03.tar.gz

This should give you three new directories alongside riak_kv-1.0.0 and the other libraries:

amqp_client-2.6.1
rabbit_common-2.6.1
riak_rabbitmq-0.1.4

You can also clone the source, build, and then symlink the required dependencies into your Riak install:

git clone git://github.com/jbrisbin/riak-rabbitmq-commit-hooks.git
cd riak-rabbitmq-commit-hooks
./rebar get-deps
make
[...wait for a long time while spidermonkey builds...]
cd $RIAK_LIBS
ln -s $BUILD_DIR riak_rabbitmq-0.1.4
ln -s $BUILD_DIR/deps/amqp_client amqp_client-2.6.1
ln -s $BUILD_DIR/deps/rabbit_common rabbit_common-2.6.1

Either of these install methods should expose the module and the right dependencies to your Riak server.

Configuration

To tell the commit hook where to send your entry in the form of an AMQP message, you can pass special metadata properties to influence the commit hook's behaviour. The list of acceptable properties is pretty self-explanatory:

  • X-Riak-Meta-Amqp-Exchange
  • X-Riak-Meta-Amqp-Routing-Key
  • X-Riak-Meta-Amqp-Host
  • X-Riak-Meta-Amqp-Port
  • X-Riak-Meta-Amqp-Vhost
  • X-Riak-Meta-Amqp-User
  • X-Riak-Meta-Amqp-Password

Alternatively, you can specify settings for an entire bucket by setting these metadata headers on an empty document at the key AMQP-Meta in the bucket you want to configure.

This allows you to route entries in an entire bucket to specific RabbitMQ servers without your publisher having to know this information ahead of time.

Ignore Flag

If you don't want a particular entry in a RabbitMQ-enabled bucket to actually be sent out (like if you're updating the AMQP-Meta entry), then set a metadata header with the name X-Riak-Meta-Amqp-Ignore to the string "true". The postcommit hook will see this flag and not actually send any message.

Deleted Entries

If the update operation is a DELETE, the postcommit hook will set an AMQP message header named X-Riak-Deleted to "true". This way your application can distinguish between updates and deletes.

This utility is Apache licensed, just like Riak.

riak-rabbitmq-commit-hooks's People

Contributors

hansonkd avatar jbrisbin avatar

Watchers

 avatar  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.