Skip to main content
Version: 2.7

Service

A service that processes requests coming from other VMs connected to the data cloud.

Index

Constructors

constructor

  • Create a new instance of the service with the specified id. It uses the context to make the lifecycle of the service related to the context one.


    Parameters

    • serviceId: string

      the service id

    • context: Context

      the context of that service.

    Returns Service

Methods

listen

  • Start and listen to incoming requests.


    Returns Observable<ServiceRequest>

setUnsubscriptionHandler

  • setUnsubscriptionHandler(handler: (subId: string) => void): Service
  • Set a function to be executed each time a subscription to that service is closed. The function receives the subscription id that has been closed. The subscription id is the one that has been set and returned by the ServiceRequest.notifyOn method.


    Parameters

    • handler: (subId: string) => void

      the handler function to be executed when a subscription is closed.

    Returns Service

    this Service instance.

stop

  • stop(): void
  • Stop the service.


    Returns void

staticget

  • get(service: string, payload: Object, config?: ServiceConfig): Promise<Object>
  • Send a request to a Service and wait for a reply with a payload..


    Parameters

    • service: string

      the service id

    • payload: Object

      the message payload

    • optionalconfig: ServiceConfig

      optional parameters for the message

    Returns Promise<Object>

    a Promise wrapping the resulting value

staticobserve

  • Send a request to a Service and subscribe to notifications published from that service.


    Parameters

    • service: string

      the service id

    • context: Context

      the context used to link its lifecycle to this subscription

    • optionalpayload: Object

      the message payload, optional

    • optionalconfig: SubscriptionServiceConfig

      optional parameters for the message

    Returns Observable<Object>

    an Observable emitting notifications

staticpublish

  • publish(service: string, payload: Object): Promise<void>
  • Publish a message on the specified service without waiting for any acknowledge


    Parameters

    • service: string

      the service id

    • payload: Object

    Returns Promise<void>

staticsend

  • send(service: string, payload?: Object, config?: ServiceConfig): Promise<void>
  • Send a request to a Service and wait for an ack.


    Parameters

    • service: string

      the service id

    • optionalpayload: Object

      the message payload, optional

    • optionalconfig: ServiceConfig

      optional parameters for the message

    Returns Promise<void>

    a Promise that completes when the call has been executed