An open API service indexing awesome lists of open source software.

https://github.com/sttc/java-sdk

Java Client SDK for Stateful.co
https://github.com/sttc/java-sdk

java java-sdk locks multi-node synchronization

Last synced: about 1 month ago
JSON representation

Java Client SDK for Stateful.co

Awesome Lists containing this project

README

          

# Java SDK for Stateful.co

[![EO principles respected here](https://www.elegantobjects.org/badge.svg)](https://www.elegantobjects.org)
[![DevOps By Rultor.com](https://www.rultor.com/b/sttc/java-sdk)](https://www.rultor.com/p/sttc/java-sdk)
[![We recommend IntelliJ IDEA](https://www.elegantobjects.org/intellij-idea.svg)](https://www.jetbrains.com/idea/)

[![mvn](https://github.com/sttc/java-sdk/actions/workflows/mvn.yml/badge.svg)](https://github.com/sttc/java-sdk/actions/workflows/mvn.yml)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/co.stateful/java-sdk/badge.svg)](https://maven-badges.herokuapp.com/maven-central/co.stateful/java-sdk)
[![Javadoc](https://www.javadoc.io/badge/co.stateful/java-sdk.svg)](https://www.javadoc.io/doc/co.stateful/java-sdk)

This is Java SDK for [Stateful](https://www.stateful.co).

See our [JavaDoc](http://java-sdk.stateful.co/).

First, register an account at [Stateful](https://www.stateful.co).
Then, you can create a counter and increment it:

```java
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:

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

## How to Contribute

Fork repository, make changes, send us a
[pull request](https://www.yegor256.com/2014/04/15/github-guidelines.html).
We will review your changes and apply them to the `master` branch shortly,
provided they don't violate our quality standards. To avoid frustration,
before sending us your pull request please run full Maven build:

```bash
mvn clean install -Pqulice
```

You will need Maven 3.3+ and Java 11+.