class ServiceDiscovery extends AnyRef
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 io.vertx.scala.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 io.vertx.scala.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 Record.
Providers and consumers must create their own io.vertx.scala.servicediscovery.ServiceDiscovery instance. These instances are collaborating in background (distributed structure) to keep the set of services in sync.
- Alphabetic
- By Inheritance
- ServiceDiscovery
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new ServiceDiscovery(_asJava: AnyRef)
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
- def asJava: AnyRef
-
def
bindings(): Set[ServiceReference]
- returns
the set of service references retrieved by this service discovery.
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
close(): Unit
Closes the service discovery
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
getRecord(filter: (Record) ⇒ Boolean, includeOutOfService: Boolean, resultHandler: Handler[AsyncResult[Record]]): Unit
Lookups for a single 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 io.vertx.scala.servicediscovery.ServiceDiscovery#getRecordFuture, this method may accept records with a
OUT OF SERVICE
status, if theincludeOutOfService
parameter is set totrue
.- filter
the filter, must not be
null
. To return all records, use a function accepting all records- includeOutOfService
whether or not the filter accepts
OUT OF SERVICE
records- resultHandler
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.
-
def
getRecord(filter: (Record) ⇒ Boolean, resultHandler: Handler[AsyncResult[Record]]): Unit
Lookups for a single 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.- filter
the filter, must not be
null
. To return all records, use a function accepting all records- resultHandler
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.
-
def
getRecord(filter: JsonObject, resultHandler: Handler[AsyncResult[Record]]): Unit
Lookups for a single 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.
- filter
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
).
-
def
getRecordFuture(filter: (Record) ⇒ Boolean, includeOutOfService: Boolean): Future[Record]
Like getRecord but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.
-
def
getRecordFuture(filter: (Record) ⇒ Boolean): Future[Record]
Like getRecord but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.
-
def
getRecordFuture(filter: JsonObject): Future[Record]
Like getRecord but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.
-
def
getRecords(filter: (Record) ⇒ Boolean, includeOutOfService: Boolean, resultHandler: Handler[AsyncResult[Buffer[Record]]]): Unit
Lookups for a set of records.
Lookups for a set of records. Unlike io.vertx.scala.servicediscovery.ServiceDiscovery#getRecordFuture, 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 io.vertx.scala.servicediscovery.ServiceDiscovery#getRecordsFuture, this method may accept records with a
OUT OF SERVICE
status, if theincludeOutOfService
parameter is set totrue
.- filter
the filter, must not be
null
. To return all records, use a function accepting all records- includeOutOfService
whether or not the filter accepts
OUT OF SERVICE
records- 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.
-
def
getRecords(filter: (Record) ⇒ Boolean, resultHandler: Handler[AsyncResult[Buffer[Record]]]): Unit
Lookups for a set of records.
Lookups for a set of records. Unlike io.vertx.scala.servicediscovery.ServiceDiscovery#getRecordFuture, 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.- filter
the filter, must not be
null
. To return all records, use a function accepting all records- 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.
-
def
getRecords(filter: JsonObject, resultHandler: Handler[AsyncResult[Buffer[Record]]]): Unit
Lookups for a set of records.
Lookups for a set of records. Unlike io.vertx.scala.servicediscovery.ServiceDiscovery#getRecordFuture, this method returns all matching records.
- filter
the filter - see #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.
-
def
getRecordsFuture(filter: (Record) ⇒ Boolean, includeOutOfService: Boolean): Future[Buffer[Record]]
Like getRecords but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.
-
def
getRecordsFuture(filter: (Record) ⇒ Boolean): Future[Buffer[Record]]
Like getRecords but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.
-
def
getRecordsFuture(filter: JsonObject): Future[Buffer[Record]]
Like getRecords but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.
-
def
getReference(record: Record): ServiceReference
Gets a service reference from the given record.
Gets a service reference from the given record.
- record
the chosen recordsee Record
- returns
the service reference, that allows retrieving the service object. Once called the service reference is cached, and need to be released.
-
def
getReferenceWithConfiguration(record: Record, configuration: JsonObject): ServiceReference
Gets a service reference from the given record, the reference is configured with the given json object.
Gets a service reference from the given record, the reference is configured with the given json object.
- record
the chosen recordsee Record
- configuration
the configuration
- returns
the service reference, that allows retrieving the service object. Once called the service reference is cached, and need to be released.
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
def
options(): ServiceDiscoveryOptions
- returns
the discovery options. Modifying the returned object would not update the discovery service configuration. This object should be considered as read-only.see ServiceDiscoveryOptions
-
def
publish(record: Record, resultHandler: Handler[AsyncResult[Record]]): Unit
Publishes a record.
Publishes a record.
- record
the recordsee Record
- resultHandler
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.
-
def
publishFuture(record: Record): Future[Record]
Like publish but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.
-
def
registerServiceExporter(exporter: ServiceExporter, configuration: JsonObject, completionHandler: Handler[AsyncResult[Unit]]): ServiceDiscovery
Registers a discovery bridge.
Registers a discovery bridge. Exporters let you integrate other discovery technologies in this service discovery.
- exporter
the service exporter
- configuration
the optional configuration
- completionHandler
handler notified when the exporter has been correctly initialized.
- returns
the current ServiceDiscovery
-
def
registerServiceExporter(exporter: ServiceExporter, configuration: JsonObject): ServiceDiscovery
Registers a discovery bridge.
Registers a discovery bridge. Exporters let you integrate other discovery technologies in this service discovery.
- exporter
the service exporter
- configuration
the optional configuration
- returns
the current ServiceDiscovery
-
def
registerServiceExporterFuture(exporter: ServiceExporter, configuration: JsonObject): Future[Unit]
Like registerServiceExporter but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.
-
def
registerServiceImporter(importer: ServiceImporter, configuration: JsonObject, completionHandler: Handler[AsyncResult[Unit]]): ServiceDiscovery
Registers a discovery service importer.
Registers a discovery service importer. Importers let you integrate other discovery technologies in this service discovery.
- importer
the service importer
- configuration
the optional configuration
- completionHandler
handler call when the importer has finished its initialization and initial imports
- returns
the current ServiceDiscovery
-
def
registerServiceImporter(importer: ServiceImporter, configuration: JsonObject): ServiceDiscovery
Registers a discovery service importer.
Registers a discovery service importer. Importers let you integrate other discovery technologies in this service discovery.
- importer
the service importer
- configuration
the optional configuration
- returns
the current ServiceDiscovery
-
def
registerServiceImporterFuture(importer: ServiceImporter, configuration: JsonObject): Future[Unit]
Like registerServiceImporter but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.
-
def
release(reference: ServiceReference): Boolean
Releases the service reference.
Releases the service reference.
- reference
the reference to release, must not be
null
- returns
whether or not the reference has been released.
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
unpublish(id: String, resultHandler: Handler[AsyncResult[Unit]]): Unit
Un-publishes a record.
Un-publishes a record.
- id
the registration id
- resultHandler
handler called when the operation has completed (successfully or not).
-
def
unpublishFuture(id: String): Future[Unit]
Like unpublish but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.
-
def
update(record: Record, resultHandler: Handler[AsyncResult[Record]]): Unit
Updates the given record.
Updates the given record. The record must has been published, and has it's registration id set.
- record
the updated recordsee Record
- resultHandler
handler called when the lookup has been completed.
-
def
updateFuture(record: Record): Future[Record]
Like update but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )