Class List Method List File List

# Class: VertxServiceDiscovery::MessageSource

Inherits:
  Object
  - Object
  - VertxServiceDiscovery::MessageSource
  show all
Defined in:
  /Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-service-discovery/message_source.rb

## Overview

Service type for data producer. Providers are publishing data to a specific event bus address.

## Class Method Summary (collapse)

- + (Hash) create_record(name = nil, address = nil, type = nil, metadata = nil)
  Create a record representing a data producer.
- + (void) get_consumer(discovery = nil, filter = nil) { ... }
  Convenient method that looks for a message source and provides the configured .

## Class Method Details

### + (`Hash`) create_record(name = nil, address = nil, type = nil, metadata = nil)

Create a record representing a data producer.

Parameters:

- name (`String`) (defaults to: `nil`) —
  the name of the service
- address (`String`) (defaults to: `nil`) —
  the address on which the data is sent
- type (`String`) (defaults to: `nil`) —
  the type of payload (fully qualified name of the class)
- metadata (`Hash{String => Object}`) (defaults to: `nil`) —
  additional metadata

Returns:

- (`Hash`) —
  the created record

Raises:

- (`ArgumentError`)

    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-service-discovery/message_source.rb', line 24

    def self.create_record(name=nil,address=nil,type=nil,metadata=nil)
      if name.class == String && address.class == String && !block_given? && type == nil && metadata == nil
        return Java::IoVertxServicediscoveryTypes::MessageSource.java_method(:createRecord, [Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(name,address) != nil ? JSON.parse(Java::IoVertxServicediscoveryTypes::MessageSource.java_method(:createRecord, [Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(name,address).toJson.encode) : nil
      elsif name.class == String && address.class == String && type.class == String && !block_given? && metadata == nil
        return Java::IoVertxServicediscoveryTypes::MessageSource.java_method(:createRecord, [Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(name,address,type) != nil ? JSON.parse(Java::IoVertxServicediscoveryTypes::MessageSource.java_method(:createRecord, [Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(name,address,type).toJson.encode) : nil
      elsif name.class == String && address.class == String && type.class == String && metadata.class == Hash && !block_given?
        return Java::IoVertxServicediscoveryTypes::MessageSource.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,type,::Vertx::Util::Utils.to_json_object(metadata)) != nil ? JSON.parse(Java::IoVertxServicediscoveryTypes::MessageSource.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,type,::Vertx::Util::Utils.to_json_object(metadata)).toJson.encode) : nil
      end
      raise ArgumentError, "Invalid arguments when calling create_record(name,address,type,metadata)"
    end

### + (`void`) get_consumer(discovery = nil, filter = nil) { ... }

This method returns an undefined value.

Convenient method that looks for a message source and provides the configured . The async result is marked as failed is there are no matching services, or if the lookup fails.

Parameters:

- discovery (`::VertxServiceDiscovery::ServiceDiscovery`) (defaults to: `nil`) —
  The service discovery instance
- filter (`Hash{String => Object}`) (defaults to: `nil`) —
  The filter, optional

Yields:

- The result handler

Raises:

- (`ArgumentError`)

    40
    41
    42
    43
    44
    45
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-service-discovery/message_source.rb', line 40

    def self.get_consumer(discovery=nil,filter=nil)
      if discovery.class.method_defined?(:j_del) && filter.class == Hash && block_given?
        return Java::IoVertxServicediscoveryTypes::MessageSource.java_method(:getConsumer, [Java::IoVertxServicediscovery::ServiceDiscovery.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(discovery.j_del,::Vertx::Util::Utils.to_json_object(filter),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::MessageConsumer) : nil) }))
      end
      raise ArgumentError, "Invalid arguments when calling get_consumer(discovery,filter)"
    end