Class List Method List File List

# Module: Vertx

Defined in:
  src/main/ruby_scripts/core/deploy.rb,
  src/main/ruby_scripts/core/net.rb,
  src/main/ruby_scripts/core/env.rb,
  src/main/ruby_scripts/core/http.rb,
  src/main/ruby_scripts/core/timers.rb,
  src/main/ruby_scripts/core/buffer.rb,
  src/main/ruby_scripts/core/logger.rb,
  src/main/ruby_scripts/core/streams.rb,
  src/main/ruby_scripts/core/sock_js.rb,
  src/main/ruby_scripts/core/event_bus.rb,
  src/main/ruby_scripts/core/parsetools.rb,
  src/main/ruby_scripts/core/ssl_support.rb,
  src/main/ruby_scripts/core/tcp_support.rb,
  src/main/ruby_scripts/core/file_system.rb,
  src/main/ruby_scripts/core/shared_data.rb

## Overview

Copyright 2011-2012 the original author or authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

## Defined Under Namespace

Modules: ReadStream, SSLSupport, TCPSupport, WriteStream Classes: AsyncFile, Buffer, EventBus, FSProps, FileProps, FileSystem, HttpClient, HttpClientRequest, HttpClientResponse, HttpServer, HttpServerRequest, HttpServerResponse, Message, NetClient, NetServer, NetSocket, Pump, RecordParser, RouteMatcher, ServerWebSocket, SharedData, SockJSServer, SockJSSocket, WebSocket

## Constant Summary

@@j_vertx =

      org.vertx.java.deploy.impl.VertxLocator.vertx()

## Class Method Summary (collapse)

- + (Boolean) cancel_timer(id)
  Cancels a timer.
- + (Hash) config
  Get config for the verticle.
- + (Object) deploy_module(module_name, config = nil, instances = 1, &block)
  Deploy a module.
- + (String) deploy_verticle(main, config = nil, instances = 1, &block)
  Deploy a verticle.
- + (Object) deploy_worker_verticle(main, config = nil, instances = 1, &block)
  Deploy a worker verticle.
- + (Hash) env
  Get the environment for the verticle.
- + (Object) exit
  Cause the container to exit.
- + (Logger) logger
  Get the logger for the verticle.
- + (Object) run_on_loop(proc = nil, &hndlr)
  Put the handler on the event queue for this loop so it will be run asynchronously ASAP after this event has been processed.
- + (FixNum) set_periodic(delay, proc = nil, &hndlr)
  Sets a periodic timer.
- + (FixNum) set_timer(delay, proc = nil, &hndlr)
  Sets a one-shot timer that will fire after a certain delay.
- + (Object) undeploy_module(id)
  Undeploy a module.
- + (Object) undeploy_verticle(id)
  Undeploy a verticle.

## Class Method Details

### + (`Boolean`) cancel_timer(id)

Cancels a timer.

Parameters:

- id (`FixNum`) —
  the id of the timer, as returned from set_timer or set_periodic

Returns:

- (`Boolean`) —
  true if the timer was cancelled, false if it wasn't found.

    44
    45
    46

    # File 'src/main/ruby_scripts/core/timers.rb', line 44

    def Vertx.cancel_timer(id)
      @@j_vertx.cancelTimer(id)
    end

### + (`Hash`) config

Get config for the verticle

Returns:

- (`Hash`) —
  The JSON config for the verticle

    76
    77
    78
    79
    80
    81
    82

    # File 'src/main/ruby_scripts/core/deploy.rb', line 76

    def Vertx.config
      if !defined? @@j_conf
        @@j_conf = org.vertx.java.deploy.impl.VertxLocator.container.getConfig
        @@j_conf = JSON.parse(@@j_conf.encode) if @@j_conf
      end
      @@j_conf
    end

### + (`Object`) deploy_module(module_name, config = nil, instances = 1, &block)

Deploy a module. The actual deploy happens asynchronously

Parameters:

- module_name (`String`) —
  The name of the module to deploy
- config (`Hash`) (defaults to: `nil`) —
  JSON configuration for the module
- instances (`FixNum`) (defaults to: `1`) —
  Number of instances to deploy
- block (`Block`) —
  Block will be executed when deploy has completed

    49
    50
    51
    52
    53
    54
    55

    # File 'src/main/ruby_scripts/core/deploy.rb', line 49

    def Vertx.deploy_module(module_name, config = nil, instances = 1, &block)
      if config
        json_str = JSON.generate(config)
        config = org.vertx.java.core.json.JsonObject.new(json_str)
      end
      org.vertx.java.deploy.impl.VertxLocator.container.deployModule(module_name, config, instances, block)
    end

### + (`String`) deploy_verticle(main, config = nil, instances = 1, &block)

Deploy a verticle. The actual deploy happens asynchronously

Parameters:

- main (`String`) —
  The main of the verticle to deploy
- config (`Hash`) (defaults to: `nil`) —
  JSON configuration for the verticle
- instances (`FixNum`) (defaults to: `1`) —
  Number of instances to deploy
- block (`Block`) —
  Block will be executed when deploy has completed

Returns:

- (`String`) —
  Unique id of deployment

    23
    24
    25
    26
    27
    28
    29

    # File 'src/main/ruby_scripts/core/deploy.rb', line 23

    def Vertx.deploy_verticle(main, config = nil, instances = 1, &block)
      if config
        json_str = JSON.generate(config)
        config = org.vertx.java.core.json.JsonObject.new(json_str)
      end
      org.vertx.java.deploy.impl.VertxLocator.container.deployVerticle(main, config, instances, block)
    end

### + (`Object`) deploy_worker_verticle(main, config = nil, instances = 1, &block)

Deploy a worker verticle. The actual deploy happens asynchronously

Parameters:

- main (`String`) —
  The main of the verticle to deploy
- config (`Hash`) (defaults to: `nil`) —
  JSON configuration for the verticle
- instances (`FixNum`) (defaults to: `1`) —
  Number of instances to deploy
- block (`Block`) —
  Block will be executed when deploy has completed

    36
    37
    38
    39
    40
    41
    42

    # File 'src/main/ruby_scripts/core/deploy.rb', line 36

    def Vertx.deploy_worker_verticle(main, config = nil, instances = 1, &block)
      if config
        json_str = JSON.generate(config)
        config = org.vertx.java.core.json.JsonObject.new(json_str)
      end
      org.vertx.java.deploy.impl.VertxLocator.container.deployWorkerVerticle(main, config, instances, block)
    end

### + (`Hash`) env

Get the environment for the verticle

Returns:

- (`Hash`) —
  Get the environment for the verticle

    19
    20
    21

    # File 'src/main/ruby_scripts/core/env.rb', line 19

    def Vertx.env
      org.vertx.java.deploy.impl.VertxLocator.container.getEnv
    end

### + (`Object`) exit

Cause the container to exit

    70
    71
    72

    # File 'src/main/ruby_scripts/core/deploy.rb', line 70

    def Vertx.exit
      org.vertx.java.deploy.impl.VertxLocator.container.exit
    end

### + (`Logger`) logger

Get the logger for the verticle

Returns:

- (`Logger`) —
  Get the logger for the verticle

    19
    20
    21

    # File 'src/main/ruby_scripts/core/logger.rb', line 19

    def Vertx.logger
      org.vertx.java.deploy.impl.VertxLocator.container.getLogger
    end

### + (`Object`) run_on_loop(proc = nil, &hndlr)

Put the handler on the event queue for this loop so it will be run asynchronously ASAP after this event has been processed

Parameters:

- proc (`Proc`) (defaults to: `nil`) —
  a proc representing the code that will be run ASAP
- hndlr (`Block`) —
  a block representing the code that will be run ASAP

    52
    53
    54
    55

    # File 'src/main/ruby_scripts/core/timers.rb', line 52

    def Vertx.run_on_loop(proc = nil, &hndlr)
      hndlr = proc if proc
      @@j_vertx.runOnLoop(hndlr)
    end

### + (`FixNum`) set_periodic(delay, proc = nil, &hndlr)

Sets a periodic timer. This method will accept either a Proc or a block.

Parameters:

- delay (`FixNum`) —
  the period of the timer, in milliseconds
- proc (`Proc`) (defaults to: `nil`) —
  a proc representing the code that will be run when the timer fires
- hndlr (`Block`) —
  a block representing the code that will be when the timer fires

Returns:

- (`FixNum`) —
  the unique id of the timer

    36
    37
    38
    39

    # File 'src/main/ruby_scripts/core/timers.rb', line 36

    def Vertx.set_periodic(delay, proc = nil, &hndlr)
      hndlr = proc if proc
      @@j_vertx.setPeriodic(delay, hndlr)
    end

### + (`FixNum`) set_timer(delay, proc = nil, &hndlr)

Sets a one-shot timer that will fire after a certain delay. This method will accept either a Proc or a block.

Parameters:

- delay (`FixNum`) —
  the delay, in milliseconds
- proc (`Proc`) (defaults to: `nil`) —
  a proc representing the code that will be run after the delay
- hndlr (`Block`) —
  a block representing the code that will be run after the delay

Returns:

- (`FixNum`) —
  the unique id of the timer

    25
    26
    27
    28

    # File 'src/main/ruby_scripts/core/timers.rb', line 25

    def Vertx.set_timer(delay, proc = nil, &hndlr)
      hndlr = proc if proc
      @@j_vertx.setTimer(delay, hndlr)
    end

### + (`Object`) undeploy_module(id)

Undeploy a module

Parameters:

- id (`String`) —
  The unique id of the deployment

    65
    66
    67

    # File 'src/main/ruby_scripts/core/deploy.rb', line 65

    def Vertx.undeploy_module(id)
      org.vertx.java.deploy.impl.VertxLocator.container.undeployModule(id)
    end

### + (`Object`) undeploy_verticle(id)

Undeploy a verticle

Parameters:

- id (`String`) —
  The unique id of the deployment

    59
    60
    61

    # File 'src/main/ruby_scripts/core/deploy.rb', line 59

    def Vertx.undeploy_verticle(id)
      org.vertx.java.deploy.impl.VertxLocator.container.undeployVerticle(id)
    end