Class List Method List File List

# Class: VertxServiceDiscovery::ServicePublisher

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

## Overview

The publisher is used by the importer to publish or unpublish records.

## Instance Method Summary (collapse)

- - (void) publish(record = nil) { ... }
  Publishes a record.
- - (void) unpublish(id = nil) { ... }
  Un-publishes a record.

## Instance Method Details

### - (`void`) publish(record = nil) { ... }

This method returns an undefined value.

Publishes a record.

Parameters:

- record (`Hash`) (defaults to: `nil`) —
  the record

Yields:

- 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.

Raises:

- (`ArgumentError`)

    20
    21
    22
    23
    24
    25
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-service-discovery/service_publisher.rb', line 20

    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

### - (`void`) unpublish(id = nil) { ... }

This method returns an undefined value.

Un-publishes a record.

Parameters:

- id (`String`) (defaults to: `nil`) —
  the registration id

Yields:

- handler called when the operation has completed (successfully or not).

Raises:

- (`ArgumentError`)

    30
    31
    32
    33
    34
    35
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-service-discovery/service_publisher.rb', line 30

    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