Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

tv2norge-collab/java-serf-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

java-serf-client

A java library that implements the serf RPC protocol as described on the serf project site.

Quick Start

//Create a serf socket endpoint
SerfEndpoint ep = new SocketEndpoint(ip, port);

//Create a serf client and perform handshake
Client client = new Client(ep);
client.handshake();

//Add/delete some tags
client.tags(ImmutableMap.<String, String>of("tag-to-create", "tag-value"), ImmutableList.<String>of("tag-to-delete"));

//Join a cluster
JoinResponse response = client.join(ImmutableList.<String>of("10.2.2.11:7946"), false);

//Subscribe to events
StreamSubscription subscription = client.stream("user:event1");

//Get next event (blocking)
Event event = subscription.take();

//Query the cluster
QuerySubscription querySubscription = client.query("my-query", "a payload", ImmutableList.<String>of("serf-agent2"), ImmutableMap.<String, String>of(), true, 0);

//Get the next response (blocking)
QueryResponse response = querySubscription.take();

Integration tests

The project includes a Vagrantfile that creates two VM's with serf agent that can be controlled by the RPC client.Vagrant 1.5 or newer is required.

Run vagrant up in the base folder to create the VM's. The VM's are named serf1 and serf2 and you may log into them by using vagrant ssh serf1 or vagrant ssh serf2. When the VM's are up, you may run the integration tests:

mvn -Dtest=no.tv2.serf.client.SerfClientIT -Dorg.slf4j.simpleLogger.defaultLogLevel=DEBUG surefire:test

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published