Class: VertxServiceDiscovery::ServiceDiscovery
- Inherits:
-
Object
- Object
- VertxServiceDiscovery::ServiceDiscovery
- Defined in:
- /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_discovery.rb
Overview
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 Hash.
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 Hashrecords.
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.
Constant Summary
- @@j_api_type =
Object.new
Class Method Summary (collapse)
- + (Boolean) accept?(obj)
-
+ (::VertxServiceDiscovery::ServiceDiscovery) create(vertx = nil, options = nil) { ... }
Creates an instance of ServiceDiscovery.
- + (Object) j_api_type
- + (Object) j_class
-
+ (void) release_service_object(discovery = nil, svcObject = nil)
Release the service object retrieved using get methods from the service type interface.
- + (Object) unwrap(obj)
- + (Object) wrap(obj)
Instance Method Summary (collapse)
-
- (Set<::VertxServiceDiscovery::ServiceReference>) bindings
The set of service references retrieved by this service discovery.
-
- (void) close
Closes the service discovery.
-
- (void) get_record(param_1 = nil, param_2 = nil)
Lookups for a single record.
-
- (void) get_records(param_1 = nil, param_2 = nil)
Lookups for a set of records.
-
- (::VertxServiceDiscovery::ServiceReference) get_reference(record = nil)
Gets a service reference from the given record.
-
- (::VertxServiceDiscovery::ServiceReference) get_reference_with_configuration(record = nil, configuration = nil)
Gets a service reference from the given record, the reference is configured with the given json object.
-
- (Hash) options
The discovery options.
-
- (void) publish(record = nil) { ... }
Publishes a record.
-
- (::VertxServiceDiscovery::ServiceDiscovery) register_service_exporter(exporter = nil, configuration = nil) { ... }
Registers a discovery bridge.
-
- (::VertxServiceDiscovery::ServiceDiscovery) register_service_importer(importer = nil, configuration = nil) { ... }
Registers a discovery service importer.
-
- (true, false) release?(reference = nil)
Releases the service reference.
-
- (void) unpublish(id = nil) { ... }
Un-publishes a record.
-
- (void) update(record = nil) { ... }
Updates the given record.
Class Method Details
+ (Boolean) accept?(obj)
51 52 53 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_discovery.rb', line 51 def @@j_api_type.accept?(obj) obj.class == ServiceDiscovery end |
+ (::VertxServiceDiscovery::ServiceDiscovery) create(vertx = nil, options = nil) { ... }
71 72 73 74 75 76 77 78 79 80 81 82 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_discovery.rb', line 71 def self.create(vertx=nil,=nil) if vertx.class.method_defined?(:j_del) && !block_given? && == nil return ::Vertx::Util::Utils.safe_create(Java::IoVertxServicediscovery::ServiceDiscovery.java_method(:create, [Java::IoVertxCore::Vertx.java_class]).call(vertx.j_del),::VertxServiceDiscovery::ServiceDiscovery) elsif vertx.class.method_defined?(:j_del) && .class == Hash && !block_given? return ::Vertx::Util::Utils.safe_create(Java::IoVertxServicediscovery::ServiceDiscovery.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxServicediscovery::ServiceDiscoveryOptions.java_class]).call(vertx.j_del,Java::IoVertxServicediscovery::ServiceDiscoveryOptions.new(::Vertx::Util::Utils.to_json_object())),::VertxServiceDiscovery::ServiceDiscovery) elsif vertx.class.method_defined?(:j_del) && block_given? && == nil return ::Vertx::Util::Utils.safe_create(Java::IoVertxServicediscovery::ServiceDiscovery.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxCore::Handler.java_class]).call(vertx.j_del,(Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::VertxServiceDiscovery::ServiceDiscovery)) })),::VertxServiceDiscovery::ServiceDiscovery) elsif vertx.class.method_defined?(:j_del) && .class == Hash && block_given? return ::Vertx::Util::Utils.safe_create(Java::IoVertxServicediscovery::ServiceDiscovery.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxServicediscovery::ServiceDiscoveryOptions.java_class,Java::IoVertxCore::Handler.java_class]).call(vertx.j_del,Java::IoVertxServicediscovery::ServiceDiscoveryOptions.new(::Vertx::Util::Utils.to_json_object()),(Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::VertxServiceDiscovery::ServiceDiscovery)) })),::VertxServiceDiscovery::ServiceDiscovery) end raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{})" end |
+ (Object) j_api_type
60 61 62 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_discovery.rb', line 60 def self.j_api_type @@j_api_type end |
+ (Object) j_class
63 64 65 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_discovery.rb', line 63 def self.j_class Java::IoVertxServicediscovery::ServiceDiscovery.java_class end |
+ (void) release_service_object(discovery = nil, svcObject = nil)
This method returns an undefined value.
Release the service object retrieved usingget
methods from the service type interface.
It searches for the reference associated with the given object and release it.
253 254 255 256 257 258 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_discovery.rb', line 253 def self.release_service_object(discovery=nil,svcObject=nil) if discovery.class.method_defined?(:j_del) && ::Vertx::Util::unknown_type.accept?(svcObject) && !block_given? return Java::IoVertxServicediscovery::ServiceDiscovery.java_method(:releaseServiceObject, [Java::IoVertxServicediscovery::ServiceDiscovery.java_class,Java::java.lang.Object.java_class]).call(discovery.j_del,::Vertx::Util::Utils.to_object(svcObject)) end raise ArgumentError, "Invalid arguments when calling release_service_object(#{discovery},#{svcObject})" end |
+ (Object) unwrap(obj)
57 58 59 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_discovery.rb', line 57 def @@j_api_type.unwrap(obj) obj.j_del end |
+ (Object) wrap(obj)
54 55 56 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_discovery.rb', line 54 def @@j_api_type.wrap(obj) ServiceDiscovery.new(obj) end |
Instance Method Details
- (Set<::VertxServiceDiscovery::ServiceReference>) bindings
235 236 237 238 239 240 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_discovery.rb', line 235 def bindings if !block_given? return ::Vertx::Util::Utils.to_set(@j_del.java_method(:bindings, []).call()).map! { |elt| ::Vertx::Util::Utils.safe_create(elt,::VertxServiceDiscovery::ServiceReference) } end raise ArgumentError, "Invalid arguments when calling bindings()" end |
- (void) close
This method returns an undefined value.
Closes the service discovery
141 142 143 144 145 146 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_discovery.rb', line 141 def close if !block_given? return @j_del.java_method(:close, []).call() end raise ArgumentError, "Invalid arguments when calling close()" end |
- (void) getRecord(filter, resultHandler) { ... } - (void) getRecord(filter, resultHandler) { ... } - (void) getRecord(filter, includeOutOfService, resultHandler) { ... }
This method returns an undefined value.
Lookups for a single record.
The filter is a taking a Hash 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 #get_record, this method may accept records with a OUT OF SERVICE
status, if the includeOutOfService
parameter is set to true
.
185 186 187 188 189 190 191 192 193 194 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_discovery.rb', line 185 def get_record(param_1=nil,param_2=nil) if param_1.class == Hash && block_given? && param_2 == nil return @j_del.java_method(:getRecord, [Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(::Vertx::Util::Utils.to_json_object(param_1),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) })) elsif param_1.class == Proc && block_given? && param_2 == nil return @j_del.java_method(:getRecord, [Java::JavaUtilFunction::Function.java_class,Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| param_1.call(event != nil ? JSON.parse(event.toJson.encode) : nil) }),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) })) elsif param_1.class == Proc && (param_2.class == TrueClass || param_2.class == FalseClass) && block_given? return @j_del.java_method(:getRecord, [Java::JavaUtilFunction::Function.java_class,Java::boolean.java_class,Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| param_1.call(event != nil ? JSON.parse(event.toJson.encode) : nil) }),param_2,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) })) end raise ArgumentError, "Invalid arguments when calling get_record(#{param_1},#{param_2})" end |
- (void) getRecords(filter, resultHandler) { ... } - (void) getRecords(filter, resultHandler) { ... } - (void) getRecords(filter, includeOutOfService, resultHandler) { ... }
This method returns an undefined value.
Lookups for a set of records. Unlike #get_record, this method returns all matching records.
The filter is a taking a Hash 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 #get_records, this method may accept records with a OUT OF SERVICE
status, if the includeOutOfService
parameter is set to true
.
214 215 216 217 218 219 220 221 222 223 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_discovery.rb', line 214 def get_records(param_1=nil,param_2=nil) if param_1.class == Hash && block_given? && param_2 == nil return @j_del.java_method(:getRecords, [Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(::Vertx::Util::Utils.to_json_object(param_1),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result.to_a.map { |elt| elt != nil ? JSON.parse(elt.toJson.encode) : nil } : nil) })) elsif param_1.class == Proc && block_given? && param_2 == nil return @j_del.java_method(:getRecords, [Java::JavaUtilFunction::Function.java_class,Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| param_1.call(event != nil ? JSON.parse(event.toJson.encode) : nil) }),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result.to_a.map { |elt| elt != nil ? JSON.parse(elt.toJson.encode) : nil } : nil) })) elsif param_1.class == Proc && (param_2.class == TrueClass || param_2.class == FalseClass) && block_given? return @j_del.java_method(:getRecords, [Java::JavaUtilFunction::Function.java_class,Java::boolean.java_class,Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| param_1.call(event != nil ? JSON.parse(event.toJson.encode) : nil) }),param_2,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result.to_a.map { |elt| elt != nil ? JSON.parse(elt.toJson.encode) : nil } : nil) })) end raise ArgumentError, "Invalid arguments when calling get_records(#{param_1},#{param_2})" end |
- (::VertxServiceDiscovery::ServiceReference) get_reference(record = nil)
86 87 88 89 90 91 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_discovery.rb', line 86 def get_reference(record=nil) if record.class == Hash && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:getReference, [Java::IoVertxServicediscovery::Record.java_class]).call(Java::IoVertxServicediscovery::Record.new(::Vertx::Util::Utils.to_json_object(record))),::VertxServiceDiscovery::ServiceReference) end raise ArgumentError, "Invalid arguments when calling get_reference(#{record})" end |
- (::VertxServiceDiscovery::ServiceReference) get_reference_with_configuration(record = nil, configuration = nil)
96 97 98 99 100 101 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_discovery.rb', line 96 def get_reference_with_configuration(record=nil,configuration=nil) if record.class == Hash && configuration.class == Hash && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:getReferenceWithConfiguration, [Java::IoVertxServicediscovery::Record.java_class,Java::IoVertxCoreJson::JsonObject.java_class]).call(Java::IoVertxServicediscovery::Record.new(::Vertx::Util::Utils.to_json_object(record)),::Vertx::Util::Utils.to_json_object(configuration)),::VertxServiceDiscovery::ServiceReference) end raise ArgumentError, "Invalid arguments when calling get_reference_with_configuration(#{record},#{configuration})" end |
- (Hash) options
242 243 244 245 246 247 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_discovery.rb', line 242 def if !block_given? return @j_del.java_method(:options, []).call() != nil ? JSON.parse(@j_del.java_method(:options, []).call().toJson.encode) : nil end raise ArgumentError, "Invalid arguments when calling options()" end |
- (void) publish(record = nil) { ... }
This method returns an undefined value.
Publishes a record.
151 152 153 154 155 156 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_discovery.rb', line 151 def publish(record=nil) if record.class == Hash && block_given? return @j_del.java_method(:publish, [Java::IoVertxServicediscovery::Record.java_class,Java::IoVertxCore::Handler.java_class]).call(Java::IoVertxServicediscovery::Record.new(::Vertx::Util::Utils.to_json_object(record)),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) })) end raise ArgumentError, "Invalid arguments when calling publish(#{record})" end |
- (::VertxServiceDiscovery::ServiceDiscovery) register_service_exporter(exporter = nil, configuration = nil) { ... }
131 132 133 134 135 136 137 138 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_discovery.rb', line 131 def register_service_exporter(exporter=nil,configuration=nil) if exporter.class.method_defined?(:j_del) && configuration.class == Hash && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:registerServiceExporter, [Java::IoVertxServicediscoverySpi::ServiceExporter.java_class,Java::IoVertxCoreJson::JsonObject.java_class]).call(exporter.j_del,::Vertx::Util::Utils.to_json_object(configuration)),::VertxServiceDiscovery::ServiceDiscovery) elsif exporter.class.method_defined?(:j_del) && configuration.class == Hash && block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:registerServiceExporter, [Java::IoVertxServicediscoverySpi::ServiceExporter.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(exporter.j_del,::Vertx::Util::Utils.to_json_object(configuration),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) })),::VertxServiceDiscovery::ServiceDiscovery) end raise ArgumentError, "Invalid arguments when calling register_service_exporter(#{exporter},#{configuration})" end |
- (::VertxServiceDiscovery::ServiceDiscovery) register_service_importer(importer = nil, configuration = nil) { ... }
117 118 119 120 121 122 123 124 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_discovery.rb', line 117 def register_service_importer(importer=nil,configuration=nil) if importer.class.method_defined?(:j_del) && configuration.class == Hash && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:registerServiceImporter, [Java::IoVertxServicediscoverySpi::ServiceImporter.java_class,Java::IoVertxCoreJson::JsonObject.java_class]).call(importer.j_del,::Vertx::Util::Utils.to_json_object(configuration)),::VertxServiceDiscovery::ServiceDiscovery) elsif importer.class.method_defined?(:j_del) && configuration.class == Hash && block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:registerServiceImporter, [Java::IoVertxServicediscoverySpi::ServiceImporter.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(importer.j_del,::Vertx::Util::Utils.to_json_object(configuration),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) })),::VertxServiceDiscovery::ServiceDiscovery) end raise ArgumentError, "Invalid arguments when calling register_service_importer(#{importer},#{configuration})" end |
- (true, false) release?(reference = nil)
105 106 107 108 109 110 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_discovery.rb', line 105 def release?(reference=nil) if reference.class.method_defined?(:j_del) && !block_given? return @j_del.java_method(:release, [Java::IoVertxServicediscovery::ServiceReference.java_class]).call(reference.j_del) end raise ArgumentError, "Invalid arguments when calling release?(#{reference})" end |
- (void) unpublish(id = nil) { ... }
This method returns an undefined value.
Un-publishes a record.
161 162 163 164 165 166 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_discovery.rb', line 161 def unpublish(id=nil) if id.class == String && block_given? return @j_del.java_method(:unpublish, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(id,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) })) end raise ArgumentError, "Invalid arguments when calling unpublish(#{id})" end |
- (void) update(record = nil) { ... }
This method returns an undefined value.
Updates the given record. The record must has been published, and has it's registration id set.
228 229 230 231 232 233 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_discovery.rb', line 228 def update(record=nil) if record.class == Hash && block_given? return @j_del.java_method(:update, [Java::IoVertxServicediscovery::Record.java_class,Java::IoVertxCore::Handler.java_class]).call(Java::IoVertxServicediscovery::Record.new(::Vertx::Util::Utils.to_json_object(record)),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) })) end raise ArgumentError, "Invalid arguments when calling update(#{record})" end |