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 @see \io\vertx\jphp\servicediscovery\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 @see \io\vertx\jphp\servicediscovery\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 @see \io\vertx\jphp\servicediscovery\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 @see \io\vertx\jphp\servicediscovery\Record.

Providers and consumers must create their own @see \io\vertx\jphp\servicediscovery\ServiceDiscovery instance. These instances are collaborating in background (distributed structure) to keep the set of services in sync.

package

Default

Methods

__construct

__construct() 

bindings

bindings() : array

Response

array

the set of service references retrieved by this service discovery.

Closes the service discovery

close() : void

Creates a new instance of @see \io\vertx\jphp\servicediscovery\ServiceDiscovery using the default configuration.

create( $arg0,  $arg1 = null,  $arg2 = null) : \io\vertx\jphp\servicediscovery\ServiceDiscovery
static

param $vertx [Vertx] the vert.x instance create($vertx)

Creates an instance of @see \io\vertx\jphp\servicediscovery\ServiceDiscovery.

param $vertx [Vertx] the vert.x instance param $options [ServiceDiscoveryOptions | array] the discovery options create($vertx, $options)

Creates a new instance of @see \io\vertx\jphp\servicediscovery\ServiceDiscovery using the default configuration.

param $vertx [Vertx] the vert.x instance param $completionHandler [callable] completion handler called when the service discovery has been initialized. This includes the initialization of the service importer registered from the SPI. create($vertx, $completionHandler)

Creates an instance of @see \io\vertx\jphp\servicediscovery\ServiceDiscovery.

param $vertx [Vertx] the vert.x instance param $options [ServiceDiscoveryOptions | array] the discovery options param $completionHandler [callable] completion handler called when the service discovery has been initialized. This includes the initialization of the service importer registered from the SPI. create($vertx, $options, $completionHandler)

Arguments

$arg0

Vertx

$arg1

callable | array | ServiceDiscoveryOptions

$arg2

callable

Response

\io\vertx\jphp\servicediscovery\ServiceDiscovery

the created instance

Lookups for a single record.

getRecord( $arg0,  $arg1,  $arg2 = null) : void

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. param $filter [array] the filter. param $resultHandler [callable] handler called when the lookup has been completed. When there are no matching record, the operation succeeds, but the async result has no result ({@code null}). getRecord($filter, $resultHandler) Lookups for a single record.

The filter is a taking a @see \io\vertx\jphp\servicediscovery\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. param $filter [callable] the filter, must not be {@code null}. To return all records, use a function accepting all records param $resultHandler [callable] the result handler called when the lookup has been completed. When there are no matching record, the operation succeed, but the async result has no result. getRecord($filter, $resultHandler) Lookups for a single record.

The filter is a taking a @see \io\vertx\jphp\servicediscovery\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 @see \io\vertx\jphp\servicediscovery\ServiceDiscovery::getRecord, this method may accept records with a OUT OF SERVICE status, if the includeOutOfService parameter is set to true. param $filter [callable] the filter, must not be {@code null}. To return all records, use a function accepting all records param $includeOutOfService [boolean] whether or not the filter accepts {@code OUT OF SERVICE} records param $resultHandler [callable] the result handler called when the lookup has been completed. When there are no matching record, the operation succeed, but the async result has no result. getRecord($filter, $includeOutOfService, $resultHandler)

Arguments

$arg0

callable | array

$arg1

callable | boolean

$arg2

callable

Lookups for a set of records. Unlike @see \io\vertx\jphp\servicediscovery\ServiceDiscovery::getRecord, this method returns all matching records.

getRecords( $arg0,  $arg1,  $arg2 = null) : void

param $filter [array] the filter - see #getRecord(JsonObject, param $resultHandler [callable] handler called when the lookup has been completed. When there are no matching record, the operation succeed, but the async result has an empty list as result. getRecords($filter, $resultHandler)

Lookups for a set of records. Unlike @see \io\vertx\jphp\servicediscovery\ServiceDiscovery::getRecord, this method returns all matching records.

The filter is a taking a @see \io\vertx\jphp\servicediscovery\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. param $filter [callable] the filter, must not be {@code null}. To return all records, use a function accepting all records param $resultHandler [callable] handler called when the lookup has been completed. When there are no matching record, the operation succeed, but the async result has an empty list as result. getRecords($filter, $resultHandler) Lookups for a set of records. Unlike @see \io\vertx\jphp\servicediscovery\ServiceDiscovery::getRecord, this method returns all matching records.

The filter is a taking a @see \io\vertx\jphp\servicediscovery\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 @see \io\vertx\jphp\servicediscovery\ServiceDiscovery::getRecords, this method may accept records with a OUT OF SERVICE status, if the includeOutOfService parameter is set to true. param $filter [callable] the filter, must not be {@code null}. To return all records, use a function accepting all records param $includeOutOfService [boolean] whether or not the filter accepts {@code OUT OF SERVICE} records param $resultHandler [callable] handler called when the lookup has been completed. When there are no matching record, the operation succeed, but the async result has an empty list as result. getRecords($filter, $includeOutOfService, $resultHandler)

Arguments

$arg0

callable | array

$arg1

callable | boolean

$arg2

callable

Gets a service reference from the given record.

getReference( $arg0) : \io\vertx\jphp\servicediscovery\ServiceReference

Arguments

$arg0

array | Record

Response

\io\vertx\jphp\servicediscovery\ServiceReference

the service reference, that allows retrieving the service object. Once called the service reference is cached, and need to be released.

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

getReferenceWithConfiguration( $arg0,  $arg1) : \io\vertx\jphp\servicediscovery\ServiceReference

Arguments

$arg0

array | Record

$arg1

array

Response

\io\vertx\jphp\servicediscovery\ServiceReference

the service reference, that allows retrieving the service object. Once called the service reference is cached, and need to be released.

options

options() : \io\vertx\jphp\servicediscovery\ServiceDiscoveryOptions

Response

\io\vertx\jphp\servicediscovery\ServiceDiscoveryOptions

the discovery options. Modifying the returned object would not update the discovery service configuration. This object should be considered as read-only.

Publishes a record.

publish( $arg0,  $arg1) : void

Arguments

$arg0

array | Record

$arg1

callable

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

registerServiceExporter( $arg0,  $arg1,  $arg2 = null) : \io\vertx\jphp\servicediscovery\ServiceDiscovery

param $exporter [ServiceExporter] the service exporter param $configuration [array] the optional configuration registerServiceExporter($exporter, $configuration)

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

param $exporter [ServiceExporter] the service exporter param $configuration [array] the optional configuration param $completionHandler [callable] handler notified when the exporter has been correctly initialized. registerServiceExporter($exporter, $configuration, $completionHandler)

Arguments

$arg0

ServiceExporter

$arg1

array

$arg2

callable

Response

\io\vertx\jphp\servicediscovery\ServiceDiscovery

the current {@link ServiceDiscovery}

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

registerServiceImporter( $arg0,  $arg1,  $arg2 = null) : \io\vertx\jphp\servicediscovery\ServiceDiscovery

param $importer [ServiceImporter] the service importer param $configuration [array] the optional configuration registerServiceImporter($importer, $configuration)

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

param $importer [ServiceImporter] the service importer param $configuration [array] the optional configuration param $completionHandler [callable] handler call when the importer has finished its initialization and initial imports registerServiceImporter($importer, $configuration, $completionHandler)

Arguments

$arg0

ServiceImporter

$arg1

array

$arg2

callable

Response

\io\vertx\jphp\servicediscovery\ServiceDiscovery

the current {@link ServiceDiscovery}

Releases the service reference.

release( $arg0) : boolean

Arguments

$arg0

ServiceReference

Response

boolean

whether or not the reference has been released.

Release the service object retrieved using <code>get</code> methods from the service type interface.

releaseServiceObject( $arg0,  $arg1) : void
static

It searches for the reference associated with the given object and release it.

Arguments

$arg0

ServiceDiscovery

$arg1

mixed

Un-publishes a record.

unpublish( $arg0,  $arg1) : void

Arguments

$arg0

string

$arg1

callable

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

update( $arg0,  $arg1) : void

Arguments

$arg0

array | Record

$arg1

callable