Class ServiceDiscovery
- All Implemented Interfaces:
io.vertx.lang.rx.RxDelegate
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 Record.
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.
NOTE: This class has been automatically generated from the original non RX-ified interface using Vert.x codegen.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final io.vertx.lang.rx.TypeArg<ServiceDiscovery> static final StringConstant for id field of usage events.static final StringConstant for record field of usage events.static final StringConstant for type field of usage events.static final StringConstant for event type `Bind`.static final StringConstant for event type `Release`. -
Constructor Summary
ConstructorsConstructorDescriptionServiceDiscovery(ServiceDiscovery delegate) ServiceDiscovery(Object delegate) -
Method Summary
Modifier and TypeMethodDescriptionbindings()voidclose()Closes the service discoverystatic ServiceDiscoveryCreates a new instance ofServiceDiscoveryusing the default configuration.static ServiceDiscoverycreate(Vertx vertx, ServiceDiscoveryOptions options) Creates an instance ofServiceDiscovery.booleangetRecord(JsonObject filter) Lookups for a single record.Looks up for a single record by its registrationid.Lookups for a single record.Lookups for a single record.getRecords(JsonObject filter) Lookups for a set of records.getRecords(Function<Record, Boolean> filter) Lookups for a set of records.getRecords(Function<Record, Boolean> filter, boolean includeOutOfService) Lookups for a set of records.getReference(Record record) Gets a service reference from the given record.getReferenceWithConfiguration(Record record, JsonObject configuration) Gets a service reference from the given record, the reference is configured with the given json object.inthashCode()static ServiceDiscoveryoptions()Publishes a record.registerServiceExporter(ServiceExporter exporter, JsonObject configuration) Registers a discovery bridge.registerServiceImporter(ServiceImporter importer, JsonObject configuration) Registers a discovery service importer.booleanrelease(ServiceReference reference) Releases the service reference.static voidreleaseServiceObject(ServiceDiscovery discovery, Object svcObject) Release the service object retrieved usinggetmethods from the service type interface.rxGetRecord(JsonObject filter) Lookups for a single record.rxGetRecord(String id) Looks up for a single record by its registrationid.rxGetRecord(Function<Record, Boolean> filter) Lookups for a single record.rxGetRecord(Function<Record, Boolean> filter, boolean includeOutOfService) Lookups for a single record.rxGetRecords(JsonObject filter) Lookups for a set of records.rxGetRecords(Function<Record, Boolean> filter) Lookups for a set of records.rxGetRecords(Function<Record, Boolean> filter, boolean includeOutOfService) Lookups for a set of records.Publishes a record.rxRegisterServiceExporter(ServiceExporter exporter, JsonObject configuration) Registers a discovery bridge.rxRegisterServiceImporter(ServiceImporter importer, JsonObject configuration) Registers a discovery service importer.rxUnpublish(String id) Un-publishes a record.Updates the given record.toString()Un-publishes a record.Updates the given record.
-
Field Details
-
__TYPE_ARG
-
EVENT_TYPE
-
EVENT_TYPE_BIND
-
EVENT_TYPE_RELEASE
-
EVENT_RECORD
-
EVENT_ID
-
-
Constructor Details
-
ServiceDiscovery
-
ServiceDiscovery
-
-
Method Details
-
toString
-
equals
-
hashCode
-
getDelegate
- Specified by:
getDelegatein interfaceio.vertx.lang.rx.RxDelegate
-
create
Creates an instance ofServiceDiscovery.- Parameters:
vertx- the vert.x instanceoptions- the discovery options- Returns:
- the created service discovery instance.
-
create
Creates a new instance ofServiceDiscoveryusing the default configuration.- Parameters:
vertx- the vert.x instance- Returns:
- the created instance
-
getReference
Gets a service reference from the given record.- Parameters:
record- the chosen record- Returns:
- the service reference, that allows retrieving the service object. Once called the service reference is cached, and need to be released.
-
getReferenceWithConfiguration
Gets a service reference from the given record, the reference is configured with the given json object.- Parameters:
record- the chosen recordconfiguration- the configuration- Returns:
- the service reference, that allows retrieving the service object. Once called the service reference is cached, and need to be released.
-
release
Releases the service reference.- Parameters:
reference- the reference to release, must not benull- Returns:
- whether or not the reference has been released.
-
registerServiceImporter
Registers a discovery service importer. Importers let you integrate other discovery technologies in this service discovery.- Parameters:
importer- the service importerconfiguration- the optional configuration- Returns:
- a future notified when the importer has finished its initialization and initial imports
-
rxRegisterServiceImporter
Registers a discovery service importer. Importers let you integrate other discovery technologies in this service discovery.- Parameters:
importer- the service importerconfiguration- the optional configuration- Returns:
- a future notified when the importer has finished its initialization and initial imports
-
registerServiceExporter
Registers a discovery bridge. Exporters let you integrate other discovery technologies in this service discovery.- Parameters:
exporter- the service exporterconfiguration- the optional configuration- Returns:
- a future notified when the exporter has been correctly initialized.
-
rxRegisterServiceExporter
Registers a discovery bridge. Exporters let you integrate other discovery technologies in this service discovery.- Parameters:
exporter- the service exporterconfiguration- the optional configuration- Returns:
- a future notified when the exporter has been correctly initialized.
-
close
public void close()Closes the service discovery -
publish
-
rxPublish
-
unpublish
Un-publishes a record.- Parameters:
id- the registration id- Returns:
- a future notified when the operation has completed (successfully or not).
-
rxUnpublish
Un-publishes a record.- Parameters:
id- the registration id- Returns:
- a future notified when the operation has completed (successfully or not).
-
getRecord
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 (
nullor empty), it accepts all records.This method returns the first matching record.
- Parameters:
filter- the filter.- Returns:
- a future notified when the lookup has been completed. When there are no matching record, the operation succeeds, but the async result has no result (
null).
-
rxGetRecord
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 (
nullor empty), it accepts all records.This method returns the first matching record.
- Parameters:
filter- the filter.- Returns:
- a future notified when the lookup has been completed. When there are no matching record, the operation succeeds, but the async result has no result (
null).
-
getRecord
-
rxGetRecord
-
getRecord
Lookups for a single record.The filter is a taking a
Recordas argument and returning a boolean. You should see it as anacceptmethod of a filter. This method return a record passing the filter.This method only looks for records with a
UPstatus.- Parameters:
filter- the filter, must not benull. To return all records, use a function accepting all records- Returns:
- a future notified when the lookup has been completed. When there are no matching record, the operation succeed, but the async result has no result.
-
rxGetRecord
Lookups for a single record.The filter is a taking a
Recordas argument and returning a boolean. You should see it as anacceptmethod of a filter. This method return a record passing the filter.This method only looks for records with a
UPstatus.- Parameters:
filter- the filter, must not benull. To return all records, use a function accepting all records- Returns:
- a future notified when the lookup has been completed. When there are no matching record, the operation succeed, but the async result has no result.
-
getRecord
Lookups for a single record.The filter is a taking a
Recordas argument and returning a boolean. You should see it as anacceptmethod of a filter. This method return a record passing the filter.Unlike
getRecord(JsonObject), this method may accept records with aOUT OF SERVICEstatus, if theincludeOutOfServiceparameter is set totrue.- Parameters:
filter- the filter, must not benull. To return all records, use a function accepting all recordsincludeOutOfService- whether or not the filter acceptsOUT OF SERVICErecords- Returns:
- a future notified when the lookup has been completed. When there are no matching record, the operation succeed, but the async result has no result.
-
rxGetRecord
Lookups for a single record.The filter is a taking a
Recordas argument and returning a boolean. You should see it as anacceptmethod of a filter. This method return a record passing the filter.Unlike
getRecord(JsonObject), this method may accept records with aOUT OF SERVICEstatus, if theincludeOutOfServiceparameter is set totrue.- Parameters:
filter- the filter, must not benull. To return all records, use a function accepting all recordsincludeOutOfService- whether or not the filter acceptsOUT OF SERVICErecords- Returns:
- a future notified when the lookup has been completed. When there are no matching record, the operation succeed, but the async result has no result.
-
getRecords
Lookups for a set of records. UnlikegetRecord(JsonObject), this method returns all matching records.- Parameters:
filter- the filter - seegetRecord(JsonObject)- Returns:
- a future notified 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.
-
rxGetRecords
Lookups for a set of records. UnlikegetRecord(JsonObject), this method returns all matching records.- Parameters:
filter- the filter - seegetRecord(JsonObject)- Returns:
- a future notified 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
Lookups for a set of records. UnlikegetRecord(JsonObject), this method returns all matching records.The filter is a taking a
Recordas argument and returning a boolean. You should see it as anacceptmethod of a filter. This method return a record passing the filter.This method only looks for records with a
UPstatus.- Parameters:
filter- the filter, must not benull. To return all records, use a function accepting all records- Returns:
- a future notified 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.
-
rxGetRecords
Lookups for a set of records. UnlikegetRecord(JsonObject), this method returns all matching records.The filter is a taking a
Recordas argument and returning a boolean. You should see it as anacceptmethod of a filter. This method return a record passing the filter.This method only looks for records with a
UPstatus.- Parameters:
filter- the filter, must not benull. To return all records, use a function accepting all records- Returns:
- a future notified 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
public Single<List<Record>> getRecords(Function<Record, Boolean> filter, boolean includeOutOfService) Lookups for a set of records. UnlikegetRecord(JsonObject), this method returns all matching records.The filter is a taking a
Recordas argument and returning a boolean. You should see it as anacceptmethod of a filter. This method return a record passing the filter.Unlike
getRecords(JsonObject), this method may accept records with aOUT OF SERVICEstatus, if theincludeOutOfServiceparameter is set totrue.- Parameters:
filter- the filter, must not benull. To return all records, use a function accepting all recordsincludeOutOfService- whether the filter acceptsOUT OF SERVICErecords- Returns:
- a future notified 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.
-
rxGetRecords
public Single<List<Record>> rxGetRecords(Function<Record, Boolean> filter, boolean includeOutOfService) Lookups for a set of records. UnlikegetRecord(JsonObject), this method returns all matching records.The filter is a taking a
Recordas argument and returning a boolean. You should see it as anacceptmethod of a filter. This method return a record passing the filter.Unlike
getRecords(JsonObject), this method may accept records with aOUT OF SERVICEstatus, if theincludeOutOfServiceparameter is set totrue.- Parameters:
filter- the filter, must not benull. To return all records, use a function accepting all recordsincludeOutOfService- whether the filter acceptsOUT OF SERVICErecords- Returns:
- a future notified 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.
-
update
-
rxUpdate
-
bindings
- Returns:
- the set of service references retrieved by this service discovery.
-
options
- Returns:
- the discovery options. Modifying the returned object would not update the discovery service configuration. This object should be considered as read-only.
-
releaseServiceObject
Release the service object retrieved usinggetmethods from the service type interface. It searches for the reference associated with the given object and release it.- Parameters:
discovery- the service discoverysvcObject- the service object
-
newInstance
-