Java Client SDK for Stateful.co
Java
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.github
src
.0pdd.yml
.gitignore
.pdd
.rultor.yml
.travis.yml
LICENSE.txt
README.md
appveyor.yml
pom.xml

README.md

Managed by Zerocracy DevOps By Rultor.com We recommend IntelliJ IDEA

Build Status Build status Maven Central Dependencies Javadoc

Java SDK of Stateful.co

JavaDoc is here: java-sdk.stateful.co

First, register an account at stateful.co. Then, you can create a counter and increment it:

import co.stateful.Counter;
import co.stateful.Counters;
import co.stateful.Sttc;
import co.stateful.RtSttc;
import com.jcabi.urn.URN;
public class Main {
  public static void main(String... args) {
    Sttc sttc = new RtSttc(
      new URN("urn:github:526301"),
      "9FF3-41E0-73FB-F900"
    );
    String name = "test-123";
    Counters counters = sttc.counters();
    Counter counter = counters.create(name);
    long value = counter.incrementAndGet(1L);
    System.out.println("new value: " + value);
    counters.delete(name);
  }
}

Here is how you can use a lock:

Locks locks = sttc.locks();
Lock lock = locks.get("test-lock");
new Atomic(lock).call(
  new Callable<Void>() {
    @Override
    public void call() {
      // perfectly synchronized code
      return null;
    }
  }
);