Class List Method List File List

# Class: VertxHealthChecks::HealthCheckHandler

Inherits:
  Object
  - Object
  - VertxHealthChecks::HealthCheckHandler
  show all
Defined in:
  /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-health-checks/health_check_handler.rb

## Overview

A Vert.x Web handler on which you register health check procedure. It computes the outcome status (`UP` or `DOWN`) . When the handler process a HTTP request, it computes the global outcome and build a HTTP response as follows:

- 204 - status is `UP` but no procedures installed (no payload)
- 200 - status is `UP`, the payload contains the result of the installed procedures
- 503 - status is `DOWN`, the payload contains the result of the installed procedures
- 500 - status is `DOWN`, the payload contains the result of the installed procedures, one of the procedure has failed

## Constant Summary

@@j_api_type =

      Object.new

## Class Method Summary (collapse)

- + (Boolean) accept?(obj)
- + (::VertxHealthChecks::HealthCheckHandler) create(vertx = nil, provider = nil)
  Creates an instance of the default implementation of the HealthCheckHandler.
- + (::VertxHealthChecks::HealthCheckHandler) create_with_health_checks(hc = nil, provider = nil)
  Creates an instance of the default implementation of the HealthCheckHandler.
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## Instance Method Summary (collapse)

- - (void) handle(event = nil)
  Something has happened, so handle it.
- - (self) register(name = nil, timeout = nil) { ... }
  Registers a health check procedure.
- - (self) unregister(name = nil)
  Unregisters a procedure.

## Class Method Details

### + (`Boolean`) accept?(obj)

Returns:

- (`Boolean`)

    31
    32
    33
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-health-checks/health_check_handler.rb', line 31

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

### + (`::VertxHealthChecks::HealthCheckHandler`) create(vertx = nil, provider = nil)

Creates an instance of the default implementation of the VertxHealthChecks::HealthCheckHandler. This function creates a new instance of VertxHealthChecks::HealthChecks.

Parameters:

- vertx (`::Vertx::Vertx`) (defaults to: `nil`) —
  the Vert.x instance, must not be `null`
- provider (`::VertxAuthCommon::AuthProvider`) (defaults to: `nil`) —
  the Authentication provider used to authenticate the HTTP request

Returns:

- (`::VertxHealthChecks::HealthCheckHandler`) —
  the created instance

Raises:

- (`ArgumentError`)

    60
    61
    62
    63
    64
    65
    66
    67
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-health-checks/health_check_handler.rb', line 60

    def self.create(vertx=nil,provider=nil)
      if vertx.class.method_defined?(:j_del) && !block_given? && provider == nil
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtHealthchecks::HealthCheckHandler.java_method(:create, [Java::IoVertxCore::Vertx.java_class]).call(vertx.j_del),::VertxHealthChecks::HealthCheckHandler)
      elsif vertx.class.method_defined?(:j_del) && provider.class.method_defined?(:j_del) && !block_given?
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtHealthchecks::HealthCheckHandler.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtAuth::AuthProvider.java_class]).call(vertx.j_del,provider.j_del),::VertxHealthChecks::HealthCheckHandler)
      end
      raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{provider})"
    end

### + (`::VertxHealthChecks::HealthCheckHandler`) create_with_health_checks(hc = nil, provider = nil)

Creates an instance of the default implementation of the VertxHealthChecks::HealthCheckHandler.

Parameters:

- hc (`::VertxHealthChecks::HealthChecks`) (defaults to: `nil`) —
  the health checks object to use, must not be `null`
- provider (`::VertxAuthCommon::AuthProvider`) (defaults to: `nil`)

Returns:

- (`::VertxHealthChecks::HealthCheckHandler`) —
  the created instance

Raises:

- (`ArgumentError`)

    72
    73
    74
    75
    76
    77
    78
    79
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-health-checks/health_check_handler.rb', line 72

    def self.create_with_health_checks(hc=nil,provider=nil)
      if hc.class.method_defined?(:j_del) && !block_given? && provider == nil
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtHealthchecks::HealthCheckHandler.java_method(:createWithHealthChecks, [Java::IoVertxExtHealthchecks::HealthChecks.java_class]).call(hc.j_del),::VertxHealthChecks::HealthCheckHandler)
      elsif hc.class.method_defined?(:j_del) && provider.class.method_defined?(:j_del) && !block_given?
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtHealthchecks::HealthCheckHandler.java_method(:createWithHealthChecks, [Java::IoVertxExtHealthchecks::HealthChecks.java_class,Java::IoVertxExtAuth::AuthProvider.java_class]).call(hc.j_del,provider.j_del),::VertxHealthChecks::HealthCheckHandler)
      end
      raise ArgumentError, "Invalid arguments when calling create_with_health_checks(#{hc},#{provider})"
    end

### + (`Object`) j_api_type

    40
    41
    42
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-health-checks/health_check_handler.rb', line 40

    def self.j_api_type
      @@j_api_type
    end

### + (`Object`) j_class

    43
    44
    45
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-health-checks/health_check_handler.rb', line 43

    def self.j_class
      Java::IoVertxExtHealthchecks::HealthCheckHandler.java_class
    end

### + (`Object`) unwrap(obj)

    37
    38
    39
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-health-checks/health_check_handler.rb', line 37

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

### + (`Object`) wrap(obj)

    34
    35
    36
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-health-checks/health_check_handler.rb', line 34

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

## Instance Method Details

### - (`void`) handle(event = nil)

This method returns an undefined value.

Something has happened, so handle it.

Parameters:

- event (`::VertxWeb::RoutingContext`) (defaults to: `nil`) —
  the event to handle

Raises:

- (`ArgumentError`)

    49
    50
    51
    52
    53
    54
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-health-checks/health_check_handler.rb', line 49

    def handle(event=nil)
      if event.class.method_defined?(:j_del) && !block_given?
        return @j_del.java_method(:handle, [Java::IoVertxExtWeb::RoutingContext.java_class]).call(event.j_del)
      end
      raise ArgumentError, "Invalid arguments when calling handle(#{event})"
    end

### - (`self`) register(name = nil, timeout = nil) { ... }

Registers a health check procedure.

The procedure is a taking a of Hash as parameter. Procedures are asynchronous, and must complete or fail the given . If the future object is failed, the procedure outcome is considered as `DOWN`. If the future is completed without any object, the procedure outcome is considered as `UP`. If the future is completed with a (not-null) Hash, the procedure outcome is the received status.

Parameters:

- name (`String`) (defaults to: `nil`) —
  the name of the procedure, must not be `null` or empty
- timeout (`Fixnum`) (defaults to: `nil`) —
  the procedure timeout

Yields:

- the procedure, must not be `null`

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-health-checks/health_check_handler.rb', line 91

    def register(name=nil,timeout=nil)
      if name.class == String && block_given? && timeout == nil
        @j_del.java_method(:register, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(name,(Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::Vertx::Promise,::Vertx::Util::data_object_type(Java::IoVertxExtHealthchecks::Status))) }))
        return self
      elsif name.class == String && timeout.class == Fixnum && block_given?
        @j_del.java_method(:register, [Java::java.lang.String.java_class,Java::long.java_class,Java::IoVertxCore::Handler.java_class]).call(name,timeout,(Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::Vertx::Promise,::Vertx::Util::data_object_type(Java::IoVertxExtHealthchecks::Status))) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling register(#{name},#{timeout})"
    end

### - (`self`) unregister(name = nil)

Unregisters a procedure.

Parameters:

- name (`String`) (defaults to: `nil`) —
  the name of the procedure

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    104
    105
    106
    107
    108
    109
    110
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-health-checks/health_check_handler.rb', line 104

    def unregister(name=nil)
      if name.class == String && !block_given?
        @j_del.java_method(:unregister, [Java::java.lang.String.java_class]).call(name)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling unregister(#{name})"
    end