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 not only defines how the service is invoked and implemented, this interface is agnostic to transport protocol. 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 Microservice is defined using a Service interface the service interface is simple java interface annotated with a @Service annotation and @ServiceMethod

  @Service
  public interface GreetingService {

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

  }

Java Interface

The service interface is a simple java interface with one or more service methods. a service method may return java-8 CompletableFuture or void in case no result is expected. Service requests might be a local or remote call and should not block the service consumer (unless the consumer explicitly called the future.get() method).

Service Annotations

@Service Annotation is used to define the service name. by default if not specified the class name is used as service name. optionally, user may specify a specific desired logical name to a service @Service ("my-specific-service-name") the logical service name is used to address the service in the cluster when its registered and discovered. each service should have its own unique logical name in a given cluster / tenant.

@ServiceMethod Annotation is used to define the service method name. by default if not specified the method name in use is the java interface method name. optionally, user may specify a specific desired logical name to a service method

@ServiceMethod ("specific-method-name")

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