Multiple Services

This example demonstrates how signaling is implemented when a local service, S1, calls to a remote service, S2.

package io.opensignals.services.samples;

import io.opensignals.services.Services.Context;
import io.opensignals.services.Services.Name;
import io.opensignals.services.Services.Service;

import static io.opensignals.services.Services.context;
import static io.opensignals.services.Services.name;

final class MultipleServices {

  private static final Name S1 =
    name (
      "com.acme.service.one"
    );

  private static final Name S2 =
    name (
      "com.acme.service.two"
    );

  public static void main (
    final String[] args
  ) {

    final Context context =
      context ();

    final Service s1 =
      context
        .service (
          S1.name (
            "post"
          )
        );

    final Service s2 =
      context
        .service (
          S2.name (
            "get"
          )
        );

    s1.start ();
    s2.call ();
    s2.succeeded ();
    s1.succeed ()
      .stop ();

  }

}