public class DiscoveryImpl extends Object implements ServiceDiscovery, ServicePublisher
| Constructor and Description |
|---|
DiscoveryImpl(Vertx vertx,
ServiceDiscoveryOptions options) |
| Modifier and Type | Method and Description |
|---|---|
Set<ServiceReference> |
bindings() |
void |
close()
Closes the service discovery
|
void |
getRecord(Function<Record,Boolean> filter,
boolean includeOutOfService,
Handler<AsyncResult<Record>> resultHandler)
Lookups for a single record.
|
void |
getRecord(Function<Record,Boolean> filter,
Handler<AsyncResult<Record>> resultHandler)
Lookups for a single record.
|
void |
getRecord(JsonObject filter,
Handler<AsyncResult<Record>> resultHandler)
Lookups for a single record.
|
void |
getRecords(Function<Record,Boolean> filter,
boolean includeOutOfService,
Handler<AsyncResult<List<Record>>> resultHandler)
Lookups for a set of records.
|
void |
getRecords(Function<Record,Boolean> filter,
Handler<AsyncResult<List<Record>>> resultHandler)
Lookups for a set of records.
|
void |
getRecords(JsonObject filter,
Handler<AsyncResult<List<Record>>> resultHandler)
Lookups for a set of records.
|
ServiceReference |
getReference(Record record)
Gets a service reference from the given record.
|
ServiceReference |
getReferenceWithConfiguration(Record record,
JsonObject configuration)
Gets a service reference from the given record, the reference is configured with the given json object.
|
void |
initialize(Handler<ServiceDiscovery> completionHandler) |
ServiceDiscoveryOptions |
options() |
void |
publish(Record record,
Handler<AsyncResult<Record>> resultHandler)
Publishes a record.
|
ServiceDiscovery |
registerServiceExporter(ServiceExporter exporter,
JsonObject configuration)
Registers a discovery bridge.
|
ServiceDiscovery |
registerServiceExporter(ServiceExporter exporter,
JsonObject configuration,
Handler<AsyncResult<Void>> completionHandler)
Registers a discovery bridge.
|
ServiceDiscovery |
registerServiceImporter(ServiceImporter importer,
JsonObject configuration)
Registers a discovery service importer.
|
ServiceDiscovery |
registerServiceImporter(ServiceImporter importer,
JsonObject configuration,
Handler<AsyncResult<Void>> completionHandler)
Registers a discovery service importer.
|
boolean |
release(ServiceReference reference)
Releases the service reference.
|
void |
unbind(ServiceReference reference)
Checks whether the reference is hold by this service discovery.
|
void |
unpublish(String id,
Handler<AsyncResult<Void>> resultHandler)
Un-publishes a record.
|
void |
update(Record record,
Handler<AsyncResult<Record>> resultHandler)
Updates the given record.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreate, create, create, create, releaseServiceObjectpublic DiscoveryImpl(Vertx vertx, ServiceDiscoveryOptions options)
public void initialize(Handler<ServiceDiscovery> completionHandler)
public ServiceReference getReference(Record record)
ServiceDiscoverygetReference in interface ServiceDiscoveryrecord - the chosen recordpublic ServiceReference getReferenceWithConfiguration(Record record, JsonObject configuration)
ServiceDiscoverygetReferenceWithConfiguration in interface ServiceDiscoveryrecord - the chosen recordconfiguration - the configurationpublic boolean release(ServiceReference reference)
ServiceDiscoveryrelease in interface ServiceDiscoveryreference - the reference to release, must not be nullpublic ServiceDiscovery registerServiceImporter(ServiceImporter importer, JsonObject configuration, Handler<AsyncResult<Void>> completionHandler)
ServiceDiscoveryregisterServiceImporter in interface ServiceDiscoveryimporter - the service importerconfiguration - the optional configurationcompletionHandler - handler call when the importer has finished its initialization and
initial importsServiceDiscoverypublic ServiceDiscovery registerServiceImporter(ServiceImporter importer, JsonObject configuration)
ServiceDiscoveryregisterServiceImporter in interface ServiceDiscoveryimporter - the service importerconfiguration - the optional configurationServiceDiscoverypublic ServiceDiscovery registerServiceExporter(ServiceExporter exporter, JsonObject configuration)
ServiceDiscoveryregisterServiceExporter in interface ServiceDiscoveryexporter - the service exporterconfiguration - the optional configurationServiceDiscoverypublic ServiceDiscovery registerServiceExporter(ServiceExporter exporter, JsonObject configuration, Handler<AsyncResult<Void>> completionHandler)
ServiceDiscoveryregisterServiceExporter in interface ServiceDiscoveryexporter - the service exporterconfiguration - the optional configurationcompletionHandler - handler notified when the exporter has been correctly initialized.ServiceDiscoverypublic void close()
ServiceDiscoveryclose in interface ServiceDiscoverypublic void publish(Record record, Handler<AsyncResult<Record>> resultHandler)
ServiceDiscoverypublish in interface ServiceDiscoverypublish in interface ServicePublisherrecord - the recordresultHandler - handler called when the operation has completed (successfully or not). In case of success,
the passed record has a registration id required to modify and un-register the service.public void unpublish(String id, Handler<AsyncResult<Void>> resultHandler)
ServiceDiscoveryunpublish in interface ServiceDiscoveryunpublish in interface ServicePublisherid - the registration idresultHandler - handler called when the operation has completed (successfully or not).public void getRecord(JsonObject filter, Handler<AsyncResult<Record>> resultHandler)
ServiceDiscoveryFilters 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.
getRecord in interface ServiceDiscoveryfilter - the filter.resultHandler - handler called when the lookup has been completed. When there are no matching record, the
operation succeeds, but the async result has no result (null).public void getRecord(Function<Record,Boolean> filter, Handler<AsyncResult<Record>> resultHandler)
ServiceDiscovery
The filter is a Function 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.
getRecord in interface ServiceDiscoveryfilter - the filter, must not be null. To return all records, use a function accepting all recordsresultHandler - 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.public void getRecord(Function<Record,Boolean> filter, boolean includeOutOfService, Handler<AsyncResult<Record>> resultHandler)
ServiceDiscovery
The filter is a Function 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 ServiceDiscovery.getRecord(Function, Handler), this method may accept records with a OUT OF SERVICE
status, if the includeOutOfService parameter is set to true.
getRecord in interface ServiceDiscoveryfilter - the filter, must not be null. To return all records, use a function accepting all recordsincludeOutOfService - whether or not the filter accepts OUT OF SERVICE recordsresultHandler - 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.public void getRecords(JsonObject filter, Handler<AsyncResult<List<Record>>> resultHandler)
ServiceDiscoveryServiceDiscovery.getRecord(JsonObject, Handler), this method returns all matching
records.getRecords in interface ServiceDiscoveryfilter - the filter - see ServiceDiscovery.getRecord(JsonObject, Handler)resultHandler - 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.public void getRecords(Function<Record,Boolean> filter, Handler<AsyncResult<List<Record>>> resultHandler)
ServiceDiscoveryServiceDiscovery.getRecord(Function, Handler), this method returns all matching
records.
The filter is a Function 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.
getRecords in interface ServiceDiscoveryfilter - the filter, must not be null. To return all records, use a function accepting all recordsresultHandler - 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.public void getRecords(Function<Record,Boolean> filter, boolean includeOutOfService, Handler<AsyncResult<List<Record>>> resultHandler)
ServiceDiscoveryServiceDiscovery.getRecord(Function, Handler), this method returns all matching
records.
The filter is a Function 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 ServiceDiscovery.getRecords(Function, Handler), this method may accept records with a OUT OF SERVICE
status, if the includeOutOfService parameter is set to true.
getRecords in interface ServiceDiscoveryfilter - the filter, must not be null. To return all records, use a function accepting all recordsincludeOutOfService - whether or not the filter accepts OUT OF SERVICE recordsresultHandler - 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.public void update(Record record, Handler<AsyncResult<Record>> resultHandler)
ServiceDiscoveryupdate in interface ServiceDiscoveryupdate in interface ServicePublisherrecord - the updated recordresultHandler - handler called when the lookup has been completed.public Set<ServiceReference> bindings()
bindings in interface ServiceDiscoverypublic ServiceDiscoveryOptions options()
options in interface ServiceDiscoverypublic void unbind(ServiceReference reference)
reference - the referenceCopyright © 2020. All rights reserved.