https://github.com/dimosr/service-call-4j
A service call library for Java
https://github.com/dimosr/service-call-4j
distributed-systems java microservices resiliency
Last synced: 8 months ago
JSON representation
A service call library for Java
- Host: GitHub
- URL: https://github.com/dimosr/service-call-4j
- Owner: dimosr
- License: gpl-3.0
- Created: 2017-05-06T11:38:55.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-08-20T17:44:12.000Z (about 8 years ago)
- Last Synced: 2025-01-04T23:17:20.440Z (9 months ago)
- Topics: distributed-systems, java, microservices, resiliency
- Language: Java
- Size: 88.9 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Protect your RPCs with ServiceCall4j
[](https://travis-ci.org/dimosr/service-call-4j)
[](https://coveralls.io/github/dimosr/service-call-4j?branch=master)
[](https://sonarcloud.io/dashboard/index/com.dimosr%3AServiceCall4j)
[](http://search.maven.org/#artifactdetails|com.github.dimosr|ServiceCall4j|1.1.0|jar)## Service-Call-4j
A library for adding resiliency capabilities to your RPCs (Remote Procedure Calls) in a declarative way. The capabilities provided by this library are the following:
* Caching
* Monitoring
* Retrying
* Timeout
* Throttling
* Circuit Breaker### Install
* Maven
```xmlcom.github.dimosr
ServiceCall4j
1.1.0```
* Gradle
```
compile 'com.github.dimosr:ServiceCall4j:1.1.0'
```### Getting Started
1. Make sure the call you want to enhance implements the **ServiceCall** interface provided by Service-Call-4j:
```java
public interface ServiceCall {
RESPONSE call(REQUEST request);
}...
public class MyAdjustedHelloWorldCall implements ServiceCall {
String call(String input) {
return "Hello " + input;
}
}
```2. Use the provided **Builder** to build your enhanced ServiceCall:
```java
ServiceCall enhancedHelloWorldCall = new ServiceCallBuilder<>(new MyAdjustedHelloWorldCall())
.withCircuitBreaker(15, 5, 3, 300)
.withCache(cache)
.withMonitoring((i, d) -> System.out.println("Duration: " + d.toMillis()))
.withTimeouts(Duration.ofMillis(1), TimeUnit.MILLISECONDS, Executors.newFixedThreadPool(10))
.withThrottling(100)
.withRetrying(false, 2)
.build();
```3. Perform your calls
```java
String response = enhancedHelloWorldCall.call("World");
```## More Info
Check the project's Wiki for more documentation about how each capability can be used.
This Wiki also contains a FAQ section, describing what's the difference between this library and alternatives, such as Hystrix.If you want a quick demo of how you can use the library, check [this](https://github.com/dimosr/service-call4j-demo).