Class: VertxServiceDiscovery::ServicePublisher

Inherits:
Object
  • Object
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.

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


17
18
19
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-service-discovery/service_publisher.rb', line 17

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

+ (Object) j_api_type



26
27
28
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-service-discovery/service_publisher.rb', line 26

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



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

def self.j_class
  Java::IoVertxServicediscoverySpi::ServicePublisher.java_class
end

+ (Object) unwrap(obj)



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

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

+ (Object) wrap(obj)



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

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

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)


36
37
38
39
40
41
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-service-discovery/service_publisher.rb', line 36

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)


46
47
48
49
50
51
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-service-discovery/service_publisher.rb', line 46

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