Skip to content

A Scala client for beanstalkd, based on Finagle RPC framework.

Notifications You must be signed in to change notification settings

cb372/finagle-beanstalk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

finagle-beanstalk

Build Status Maven Central

An asynchronous Scala client for beanstalkd built with Finagle.

Versioning

Built for Scala 2.11.x.

How to use

Add the following dependency to your sbt build file:

libraryDependencies += "com.github.cb372" %% "finagle-beanstalk" % "0.0.1"

In your Scala application, create a new BeanstalkClient by passing it a comma-separated list of host:port pairs:

import com.github.cb372.finagle.beanstalk.client.BeanstalkClient

val client = BeanstalkClient.build("host1:11300,host2:11300")

Then use it, e.g.:

val jobData = "foo"
val putOptions = PutOpts(priority = 1, delay = 2, timeToRun = 3)
val futureOfResponse: Future[Either[Reply, Int]] = client.put(jobData, putOptions)
futureOfResponse map {
  case Left(reply) => 
    // Server replied with an error.
    // Pattern match on it to find out what it was.
  case Right(id) =>
    // The job was successfully inserted.
    // This is the job ID.
}

Finally shut down the client:

client.quit()

How to run the tests

Make sure you have beanstalkd installed and available on your $PATH. The tests will automatically start a beanstalkd server on a random port.

Then run:

$ sbt test

About

A Scala client for beanstalkd, based on Finagle RPC framework.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages