Class: VertxServiceDiscovery::EventBusService

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/event_bus_service.rb

Overview

for event bus services (service proxies). Consumers receive a service proxy to use the service.

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


19
20
21
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/event_bus_service.rb', line 19

def @@j_api_type.accept?(obj)
  obj.class == EventBusService
end

+ (Hash) create_record(name = nil, address = nil, itf = nil, metadata = nil)

Sugar method to creates a record for this type.

The java interface is added to the metadata in the `service.interface` key.

Parameters:

  • name (String) (defaults to: nil)
    the name of the service.
  • address (String) (defaults to: nil)
    the event bus address on which the service available
  • itf (String) (defaults to: nil)
    the Java interface (name)
  • metadata (Hash{String => Object}) (defaults to: nil)
    the metadata

Returns:

  • (Hash)
    the created record

Raises:

  • (ArgumentError)


42
43
44
45
46
47
48
49
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/event_bus_service.rb', line 42

def self.create_record(name=nil,address=nil,itf=nil,=nil)
  if name.class == String && address.class == String && itf.class == String && !block_given? &&  == nil
    return Java::IoVertxServicediscoveryTypes::EventBusService.java_method(:createRecord, [Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(name,address,itf) != nil ? JSON.parse(Java::IoVertxServicediscoveryTypes::EventBusService.java_method(:createRecord, [Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(name,address,itf).toJson.encode) : nil
  elsif name.class == String && address.class == String && itf.class == String && .class == Hash && !block_given?
    return Java::IoVertxServicediscoveryTypes::EventBusService.java_method(:createRecord, [Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonObject.java_class]).call(name,address,itf,::Vertx::Util::Utils.to_json_object()) != nil ? JSON.parse(Java::IoVertxServicediscoveryTypes::EventBusService.java_method(:createRecord, [Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonObject.java_class]).call(name,address,itf,::Vertx::Util::Utils.to_json_object()).toJson.encode) : nil
  end
  raise ArgumentError, "Invalid arguments when calling create_record(#{name},#{address},#{itf},#{})"
end

+ (Object) get_service_proxy(discovery = nil, filter = nil, clientClass = nil) { ... }

Lookup for a service record and if found, retrieve it and return the service object (used to consume the service). This is a convenient method to avoid explicit lookup and then retrieval of the service. This method requires to have the clientClass set with the expected set of client. This is important for usages not using Java so you can pass the expected type.

Parameters:

  • discovery (::VertxServiceDiscovery::ServiceDiscovery) (defaults to: nil)
    the service discovery
  • filter (Proc) (defaults to: nil)
    the filter
  • clientClass (Nil) (defaults to: nil)
    the client class

Yields:

  • the result handler

Returns:

  • (Object)
    null - do not use

Raises:

  • (ArgumentError)


59
60
61
62
63
64
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/event_bus_service.rb', line 59

def self.get_service_proxy(discovery=nil,filter=nil,clientClass=nil)
  if discovery.class.method_defined?(:j_del) && filter.class == Proc && clientClass.class == Class && block_given?
    return ::Vertx::Util::Utils.v_type_of(clientClass).wrap(Java::IoVertxServicediscoveryTypes::EventBusService.java_method(:getServiceProxy, [Java::IoVertxServicediscovery::ServiceDiscovery.java_class,Java::JavaUtilFunction::Function.java_class,Java::JavaLang::Class.java_class,Java::IoVertxCore::Handler.java_class]).call(discovery.j_del,(Proc.new { |event| filter.call(event != nil ? JSON.parse(event.toJson.encode) : nil) }),::Vertx::Util::Utils.j_class_of(clientClass),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.v_type_of(clientClass).wrap(ar.result) : nil) })))
  end
  raise ArgumentError, "Invalid arguments when calling get_service_proxy(#{discovery},#{filter},#{clientClass})"
end

+ (Object) get_service_proxy_with_json_filter(discovery = nil, filter = nil, clientClass = nil) { ... }

Lookup for a service record and if found, retrieve it and return the service object (used to consume the service). This is a convenient method to avoid explicit lookup and then retrieval of the service. This method requires to have the clientClass set with the expected set of client. This is important for usages not using Java so you can pass the expected type.

Parameters:

  • discovery (::VertxServiceDiscovery::ServiceDiscovery) (defaults to: nil)
    the service discovery
  • filter (Hash{String => Object}) (defaults to: nil)
    the filter as json object
  • clientClass (Nil) (defaults to: nil)
    the client class

Yields:

  • the result handler

Returns:

  • (Object)
    null - do not use

Raises:

  • (ArgumentError)


74
75
76
77
78
79
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/event_bus_service.rb', line 74

def self.get_service_proxy_with_json_filter(discovery=nil,filter=nil,clientClass=nil)
  if discovery.class.method_defined?(:j_del) && filter.class == Hash && clientClass.class == Class && block_given?
    return ::Vertx::Util::Utils.v_type_of(clientClass).wrap(Java::IoVertxServicediscoveryTypes::EventBusService.java_method(:getServiceProxyWithJsonFilter, [Java::IoVertxServicediscovery::ServiceDiscovery.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::JavaLang::Class.java_class,Java::IoVertxCore::Handler.java_class]).call(discovery.j_del,::Vertx::Util::Utils.to_json_object(filter),::Vertx::Util::Utils.j_class_of(clientClass),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.v_type_of(clientClass).wrap(ar.result) : nil) })))
  end
  raise ArgumentError, "Invalid arguments when calling get_service_proxy_with_json_filter(#{discovery},#{filter},#{clientClass})"
end

+ (Object) j_api_type



28
29
30
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/event_bus_service.rb', line 28

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



31
32
33
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/event_bus_service.rb', line 31

def self.j_class
  Java::IoVertxServicediscoveryTypes::EventBusService.java_class
end

+ (Object) TYPE

Name of the type.


85
86
87
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/event_bus_service.rb', line 85

def self.TYPE
  Java::IoVertxServicediscoveryTypes::EventBusService.TYPE
end

+ (Object) UNKNOWN

Unknown type.


81
82
83
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/event_bus_service.rb', line 81

def self.UNKNOWN
  Java::IoVertxServicediscoveryTypes::EventBusService.UNKNOWN
end

+ (Object) unwrap(obj)



25
26
27
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/event_bus_service.rb', line 25

def @@j_api_type.unwrap(obj)
  obj.j_del
end

+ (Object) wrap(obj)



22
23
24
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/event_bus_service.rb', line 22

def @@j_api_type.wrap(obj)
  EventBusService.new(obj)
end