View on GitHub

ScaleCube Reactive Microservices

The Future is reactive - The Future is right here!

Defining Services

ScaleCube services are described by an interface. This interface defines how the service is invoked and implemented. Generally, the service interface, its implementation and consumption should remain agnostic to what transport is being used, it mainly defines the service API and data-model.

A ScaleCube service is defined using an interface, the service interface is simple java interface annotated with a @Service and @ServiceMethod ScaleCube annotaions.

  @Service
  public interface GreetingService {

    @ServiceMethod
    Mono<GreetingResponse> greeting(GreetingRequest request);

    @ServiceMethod
    Flux<GreetingResponse> greetingStream(GreetingRequest request);

    @ServiceMethod
    Flux<GreetingResponse> greetingChannel(Flux<GreetingRequest> requests);
    
  }

Java Interface

The service interface is a simple java interface with one or more service methods. A service method may return Reactor Project Mono | Flux or void in case no result is expected.
Service requests might be a local or a remote call and should not block the service consumer (unless the consumer explicitly called the Mono.block() method).

Service Annotations

@Service annotation is used to define the service name. By default if a logical name is not specified, the class name is used as the service logical name. Optionally, a user may specify a logical name of a service like so: @Service ("my-specific-service-name") .
The logical service name is used to address the service in the cluster when it is registered and discovered. Each service should have its own unique logical name in a given cluster / tenant.

@ServiceMethod annotation is used to define a service method. By default if a logical name is not specified, the method name is used as the service method logical name. Optionally, a user may specify a logical name of a service method like so:

@ServiceMethod ("specific-method-name")

Each service method should have its own unique logical name for a given service.