v2.0 - ScaleCube Services provides a low latency Reactive Microservices library for serverless service registry and discovery based on gossip protocol and without single point-of-failure or bottlenecks.
An open-source project that is focused on streamlining reactive-programming of Microservices Reactive-systems that scale, built by developers for developers. ScaleCube Services provides a low latency Reactive Microservices library for peer-to-peer service registry and discovery based on gossip protocol, without single point-of-failure or bottlenecks. Scalecube more gracefully address the cross cutting concernes of distributed microservices architecture. |
User Guide:
Basic Usage:
The example provisions 2 cluster nodes and making a remote interaction.
//1. ScaleCube Node node with no members
Microservices seed = Microservices.builder().startAwait();
//2. Construct a ScaleCube node which joins the cluster hosting the Greeting Service
Microservices microservices = Microservices.builder()
.seeds(seed.cluster().address()) // some address so its possible to join the cluster.
.services(new GreetingServiceImpl())
.startAwait();
//3. Create service proxy
GreetingsService service = seed.call().create().api(GreetingsService.class);
// Execute the services and subscribe to service events
service.sayHello("joe").subscribe(consumer -> {
System.out.println(consumer.message());
});
Basic Service Example:
A service is nothing but an interface declaring what methods we wish to provision at our cluster.
@Service
public interface ExampleService {
@ServiceMethod
Mono<String> sayHello(String request);
@ServiceMethod
Flux<MyResponse> helloStream();
@ServiceMethod
Flux<MyResponse> helloBidirectional(Flux<MyRequest> requests);
}
With scalecube-services you may plug-and-play alternative providers for Transport,Codecs and discovery.
Scalecube is using ServiceLoader to load providers from class path,
You can think about scalecube as slf4j for microservices - Currently supported SPIs:
Transport providers:
Message codec providers:
Service discovery providers:
Binaries and dependency information for Maven can be found at http://search.maven.org.
https://mvnrepository.com/artifact/io.scalecube
To add a dependency on ScaleCube Services using Maven, use the following:
<!-- -------------------------------------------
scalecube core and api:
------------------------------------------- -->
<!-- scalecube apis -->
<dependency>
<groupId>io.scalecube</groupId>
<artifactId>scalecube-services-api</artifactId>
<version>2.x.x</version>
</dependency>
<!-- scalecube services module -->
<dependency>
<groupId>io.scalecube</groupId>
<artifactId>scalecube-services</artifactId>
<version>2.x.x</version>
</dependency>
<!--
Plugins / SPIs: bellow a list of providers you may choose from. to constract your own configuration:
you are welcome to build/contribute your own plugins please consider the existing ones as example.
-->
<!-- -------------------------------------------
scalecube transport providers:
------------------------------------------- -->
<dependency>
<groupId>io.scalecube</groupId>
<artifactId>rsocket-services-transport</artifactId>
<version>2.x.x</version>
</dependency>
<!-- -------------------------------------------
scalecube message serialization providers:
------------------------------------------- -->
<!-- jackson scalecube messages codec -->
<dependency>
<groupId>io.scalecube</groupId>
<artifactId>scalecube-services-jackson</artifactId>
<version>2.x.x</version>
</dependency>
<!-- protostuff scalecube messages codec -->
<dependency>
<groupId>io.scalecube</groupId>
<artifactId>scalecube-services-protostuff</artifactId>
<version>2.x.x</version>
</dependency>
<!-- -------------------------------------------
scalecube service discovery provider
------------------------------------------- -->
<dependency>
<groupId>io.scalecube</groupId>
<artifactId>scalecube-services-discovery</artifactId>
<version>2.x.x</version>
</dependency>