Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ServiceDiscovery

Service Discovery main entry point.

The service discovery is an infrastructure that let you publish and find `services`. A `service` is a discoverable functionality. It can be qualified by its type, metadata, and location. So a `service` can be a database, a service proxy, a HTTP endpoint. It does not have to be a vert.x entity, but can be anything. Each service is described by a Record.

The service discovery implements the interactions defined in the service-oriented computing. And to some extend, also provides the dynamic service-oriented computing interaction. So, application can react to arrival and departure of services.

A service provider can:

* publish a service record * un-publish a published record * update the status of a published service (down, out of service...)

A service consumer can:

* lookup for services * bind to a selected service (it gets a ServiceReference) and use it * release the service once the consumer is done with it * listen for arrival, departure and modification of services.

Consumer would 1) lookup for service record matching their need, 2) retrieve the ServiceReference that give access to the service, 3) get a service object to access the service, 4) release the service object once done.

A state above, the central piece of information shared by the providers and consumers are records.

Providers and consumers must create their own ServiceDiscovery instance. These instances are collaborating in background (distributed structure) to keep the set of services in sync.

Hierarchy

  • ServiceDiscovery

Index

Properties

Static Readonly EVENT_ID

EVENT_ID: string

Constant for id field of usage events.

Static Readonly EVENT_RECORD

EVENT_RECORD: string

Constant for record field of usage events.

Static Readonly EVENT_TYPE

EVENT_TYPE: string

Constant for type field of usage events.

Static Readonly EVENT_TYPE_BIND

EVENT_TYPE_BIND: string

Constant for event type Bind.

Static Readonly EVENT_TYPE_RELEASE

EVENT_TYPE_RELEASE: string

Constant for event type Release.

Methods

bindings

  • Returns ServiceReference

close

  • close(): void
  • Closes the service discovery

    Returns void

getRecord

  • getRecord(filter: {}): PromiseLike<Record>
  • getRecord(filter: {}, resultHandler: ((res: AsyncResult<Record>) => void) | Handler<AsyncResult<Record>>): void
  • getRecord(id: string): PromiseLike<Record>
  • getRecord(id: string, resultHandler: ((res: AsyncResult<Record>) => void) | Handler<AsyncResult<Record>>): void
  • getRecord(filter: (arg: Record) => boolean): PromiseLike<Record>
  • getRecord(filter: (arg: Record) => boolean, resultHandler: ((res: AsyncResult<Record>) => void) | Handler<AsyncResult<Record>>): void
  • getRecord(filter: (arg: Record) => boolean, includeOutOfService: boolean): PromiseLike<Record>
  • getRecord(filter: (arg: Record) => boolean, includeOutOfService: boolean, resultHandler: ((res: AsyncResult<Record>) => void) | Handler<AsyncResult<Record>>): void
  • Lookups for a single record.

    Filters are expressed using a Json object. Each entry of the given filter will be checked against the record. All entry must match exactly the record. The entry can use the special "*" value to denotes a requirement on the key, but not on the value.

    Let's take some example:

      { "name" = "a" } => matches records with name set fo "a"
      { "color" = "*" } => matches records with "color" set
      { "color" = "red" } => only matches records with "color" set to "red"
      { "color" = "red", "name" = "a"} => only matches records with name set to "a", and color set to "red"
    

    If the filter is not set (null or empty), it accepts all records.

    This method returns the first matching record.

    Parameters

    • filter: {}
      • [key: string]: any

    Returns PromiseLike<Record>

  • Lookups for a single record.

    Filters are expressed using a Json object. Each entry of the given filter will be checked against the record. All entry must match exactly the record. The entry can use the special "*" value to denotes a requirement on the key, but not on the value.

    Let's take some example:

      { "name" = "a" } => matches records with name set fo "a"
      { "color" = "*" } => matches records with "color" set
      { "color" = "red" } => only matches records with "color" set to "red"
      { "color" = "red", "name" = "a"} => only matches records with name set to "a", and color set to "red"
    

    If the filter is not set (null or empty), it accepts all records.

    This method returns the first matching record.

    Parameters

    • filter: {}
      • [key: string]: any
    • resultHandler: ((res: AsyncResult<Record>) => void) | Handler<AsyncResult<Record>>

    Returns void

  • Looks up for a single record by its registration id.

    When there are no matching record, the operation succeeds, but the async result has no result (null).

    Parameters

    • id: string

    Returns PromiseLike<Record>

  • Looks up for a single record by its registration id.

    When there are no matching record, the operation succeeds, but the async result has no result (null).

    Parameters

    • id: string
    • resultHandler: ((res: AsyncResult<Record>) => void) | Handler<AsyncResult<Record>>

    Returns void

  • Lookups for a single record.

    The filter is a taking a Record as argument and returning a boolean. You should see it as an accept method of a filter. This method return a record passing the filter.

    This method only looks for records with a UP status.

    Parameters

    • filter: (arg: Record) => boolean
        • Parameters

          Returns boolean

    Returns PromiseLike<Record>

  • Lookups for a single record.

    The filter is a taking a Record as argument and returning a boolean. You should see it as an accept method of a filter. This method return a record passing the filter.

    This method only looks for records with a UP status.

    Parameters

    • filter: (arg: Record) => boolean
        • Parameters

          Returns boolean

    • resultHandler: ((res: AsyncResult<Record>) => void) | Handler<AsyncResult<Record>>

    Returns void

  • Lookups for a single record.

    The filter is a taking a Record as argument and returning a boolean. You should see it as an accept method of a filter. This method return a record passing the filter.

    Unlike {@link ServiceDiscovery#getRecord}, this method may accept records with a OUT OF SERVICE status, if the includeOutOfService parameter is set to true.

    Parameters

    • filter: (arg: Record) => boolean
        • Parameters

          Returns boolean

    • includeOutOfService: boolean

    Returns PromiseLike<Record>

  • Lookups for a single record.

    The filter is a taking a Record as argument and returning a boolean. You should see it as an accept method of a filter. This method return a record passing the filter.

    Unlike {@link ServiceDiscovery#getRecord}, this method may accept records with a OUT OF SERVICE status, if the includeOutOfService parameter is set to true.

    Parameters

    • filter: (arg: Record) => boolean
        • Parameters

          Returns boolean

    • includeOutOfService: boolean
    • resultHandler: ((res: AsyncResult<Record>) => void) | Handler<AsyncResult<Record>>

    Returns void

getRecords

  • getRecords(filter: {}): PromiseLike<Record>
  • getRecords(filter: {}, resultHandler: ((res: AsyncResult<Record>) => void) | Handler<AsyncResult<Record>>): void
  • getRecords(filter: (arg: Record) => boolean): PromiseLike<Record>
  • getRecords(filter: (arg: Record) => boolean, resultHandler: ((res: AsyncResult<Record>) => void) | Handler<AsyncResult<Record>>): void
  • getRecords(filter: (arg: Record) => boolean, includeOutOfService: boolean): PromiseLike<Record>
  • getRecords(filter: (arg: Record) => boolean, includeOutOfService: boolean, resultHandler: ((res: AsyncResult<Record>) => void) | Handler<AsyncResult<Record>>): void
  • Lookups for a set of records. Unlike {@link ServiceDiscovery#getRecord}, this method returns all matching records.

    Parameters

    • filter: {}
      • [key: string]: any

    Returns PromiseLike<Record>

  • Lookups for a set of records. Unlike {@link ServiceDiscovery#getRecord}, this method returns all matching records.

    Parameters

    • filter: {}
      • [key: string]: any
    • resultHandler: ((res: AsyncResult<Record>) => void) | Handler<AsyncResult<Record>>

    Returns void

  • Lookups for a set of records. Unlike {@link ServiceDiscovery#getRecord}, this method returns all matching records.

    The filter is a taking a Record as argument and returning a boolean. You should see it as an accept method of a filter. This method return a record passing the filter.

    This method only looks for records with a UP status.

    Parameters

    • filter: (arg: Record) => boolean
        • Parameters

          Returns boolean

    Returns PromiseLike<Record>

  • Lookups for a set of records. Unlike {@link ServiceDiscovery#getRecord}, this method returns all matching records.

    The filter is a taking a Record as argument and returning a boolean. You should see it as an accept method of a filter. This method return a record passing the filter.

    This method only looks for records with a UP status.

    Parameters

    • filter: (arg: Record) => boolean
        • Parameters

          Returns boolean

    • resultHandler: ((res: AsyncResult<Record>) => void) | Handler<AsyncResult<Record>>

    Returns void

  • Lookups for a set of records. Unlike {@link ServiceDiscovery#getRecord}, this method returns all matching records.

    The filter is a taking a Record as argument and returning a boolean. You should see it as an accept method of a filter. This method return a record passing the filter.

    Unlike {@link ServiceDiscovery#getRecords}, this method may accept records with a OUT OF SERVICE status, if the includeOutOfService parameter is set to true.

    Parameters

    • filter: (arg: Record) => boolean
        • Parameters

          Returns boolean

    • includeOutOfService: boolean

    Returns PromiseLike<Record>

  • Lookups for a set of records. Unlike {@link ServiceDiscovery#getRecord}, this method returns all matching records.

    The filter is a taking a Record as argument and returning a boolean. You should see it as an accept method of a filter. This method return a record passing the filter.

    Unlike {@link ServiceDiscovery#getRecords}, this method may accept records with a OUT OF SERVICE status, if the includeOutOfService parameter is set to true.

    Parameters

    • filter: (arg: Record) => boolean
        • Parameters

          Returns boolean

    • includeOutOfService: boolean
    • resultHandler: ((res: AsyncResult<Record>) => void) | Handler<AsyncResult<Record>>

    Returns void

getReference

  • Gets a service reference from the given record.

    Parameters

    Returns ServiceReference

getReferenceWithConfiguration

  • Gets a service reference from the given record, the reference is configured with the given json object.

    Parameters

    • record: Record
    • configuration: {}
      • [key: string]: any

    Returns ServiceReference

options

publish

  • publish(record: Record): PromiseLike<Record>
  • publish(record: Record, resultHandler: ((res: AsyncResult<Record>) => void) | Handler<AsyncResult<Record>>): void
  • Publishes a record.

    Parameters

    Returns PromiseLike<Record>

  • Publishes a record.

    Parameters

    • record: Record
    • resultHandler: ((res: AsyncResult<Record>) => void) | Handler<AsyncResult<Record>>

    Returns void

registerServiceExporter

  • registerServiceExporter(exporter: ServiceExporter, configuration: {}): PromiseLike<void>
  • registerServiceExporter(exporter: ServiceExporter, configuration: {}, completionHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): ServiceDiscovery
  • Registers a discovery bridge. Exporters let you integrate other discovery technologies in this service discovery.

    Parameters

    Returns PromiseLike<void>

  • Registers a discovery bridge. Exporters let you integrate other discovery technologies in this service discovery.

    Parameters

    • exporter: ServiceExporter
    • configuration: {}
      • [key: string]: any
    • completionHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>

    Returns ServiceDiscovery

registerServiceImporter

  • registerServiceImporter(importer: ServiceImporter, configuration: {}): PromiseLike<void>
  • registerServiceImporter(importer: ServiceImporter, configuration: {}, completionHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): ServiceDiscovery
  • Registers a discovery service importer. Importers let you integrate other discovery technologies in this service discovery.

    Parameters

    Returns PromiseLike<void>

  • Registers a discovery service importer. Importers let you integrate other discovery technologies in this service discovery.

    Parameters

    • importer: ServiceImporter
    • configuration: {}
      • [key: string]: any
    • completionHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>

    Returns ServiceDiscovery

release

  • Releases the service reference.

    Parameters

    Returns boolean

unpublish

  • unpublish(id: string): PromiseLike<void>
  • unpublish(id: string, resultHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): void
  • Un-publishes a record.

    Parameters

    • id: string

    Returns PromiseLike<void>

  • Un-publishes a record.

    Parameters

    • id: string
    • resultHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>

    Returns void

update

  • update(record: Record): PromiseLike<Record>
  • update(record: Record, resultHandler: ((res: AsyncResult<Record>) => void) | Handler<AsyncResult<Record>>): void
  • Updates the given record. The record must has been published, and has it's registration id set.

    Parameters

    Returns PromiseLike<Record>

  • Updates the given record. The record must has been published, and has it's registration id set.

    Parameters

    • record: Record
    • resultHandler: ((res: AsyncResult<Record>) => void) | Handler<AsyncResult<Record>>

    Returns void

Static create

Static releaseServiceObject

  • Release the service object retrieved using get methods from the service type interface. It searches for the reference associated with the given object and release it.

    Parameters

    Returns void

Generated using TypeDoc