Skip to content
This repository has been archived by the owner on Aug 3, 2019. It is now read-only.

mp911de/spinach

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spinach - A scalable Java Disque client

Build Status Coverage Status Maven Central

Spinach is a scalable thread-safe Disque client providing both synchronous and asynchronous APIs. Multiple threads may share one connection if they do not use blocking commands. Spinach is based on lettuce 4. Multiple connections are efficiently managed by the excellent netty NIO framework.

See the Wiki for more docs.

Communication

Documentation

Binaries/Download

Binaries and dependency information for Maven, Ivy, Gradle and others can be found at http://search.maven.org.

Releases of spinach are available in the maven central repository. Take also a look at the Download page in the Wiki.

Example for Maven:

<dependency>
  <groupId>biz.paluch.redis</groupId>
  <artifactId>spinach</artifactId>
  <version>x.y.z</version>
</dependency>

All versions: Maven Central

Snapshots: Sonatype OSS Repository

Basic Usage

DisqueClient client = DisqueClient.create(DisqueURI.create("host", 7711));
DisqueConnection<String, String> connection = client.connect().sync();
DisqueCommands<String, String> sync = connection.sync();
String jobId = sync.addjob("queue", "body", 1, TimeUnit.MINUTES);
  
Job<String, String> job = sync.getjob("queue");
connection.ackjob(job.getId());

Each Disque command is implemented by one or more methods with names identical to the lowercase Disque command name. Complex commands with multiple modifiers that change the result type include the CamelCased modifier as part of the command name.

Disque connections are designed to be long-lived, and if the connection is lost will reconnect until close() is called. Pending commands that have not timed out will be (re)sent after successful reconnection.

All connections inherit a default timeout from their DisqueClient and and will throw a DisqueException when non-blocking commands fail to return a result before the timeout expires. The timeout defaults to 60 seconds and may be changed in the DisqueClient or for each individual connection.

Asynchronous API

DisqueConnection<String, String> connection = client.connect();
DisqueAsyncCommands<String, String>  async = connection.async();
RedisFuture<String> jobId1 = async.addjob("queue", "body1", 1, SECONDS);
RedisFuture<String> jobId2 = async.addjob("queue", "body2", 1, SECONDS);

async.awaitAll(jobId1, jobId2) == true

jobId1.get() == "D-...a1"
jobId2.get() == "D-...a1"

Building

Spinach is built with Apache Maven. The tests require multiple running Disque instances for different test cases which are configured using a Makefile.

  • Run the build: make test
  • Start Disque (manually): make start
  • Stop Disque (manually): make stop

License

Contributing

Github is for social coding: if you want to write code, I encourage contributions through pull requests from forks of this repository. Create Github tickets for bugs and new features and comment on the ones that you are interested in and take a look into CONTRIBUTING.md