# Class: Vertx

## vertx-js/vertx~ Vertx

#### new Vertx()

  The entry point into the Vert.x Core API.

  You use an instance of this class for functionality including:

  - Creating TCP clients and servers
  - Creating HTTP clients and servers
  - Creating DNS clients
  - Creating Datagram sockets
  - Setting and cancelling periodic and one-shot timers
  - Getting a reference to the event bus API
  - Getting a reference to the file system API
  - Getting a reference to the shared data API
  - Deploying and undeploying verticles

  Most functionality in Vert.x core is fairly low level.

  Source:
    - vertx.js, line 64

### Methods

#### cancelTimer(id) → {boolean}

  Cancels the timer with the specified `id`.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `id` | number | The id of the timer to cancel

  Source:
    - vertx.js, line 317

  ##### Returns:

  true if the timer was successfully cancelled, or false if the timer does not exist.
  Type
    boolean

#### close(completionHandler)

  Like Vertx#close but the completionHandler will be called when the close is complete

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `completionHandler` | function | The handler will be notified when the close is complete.

  Source:
    - vertx.js, line 344

#### createDatagramSocket(options) → {DatagramSocket}

  Create a datagram socket using the specified options

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `options` | Object | the options to use

  Source:
    - vertx.js, line 169

  ##### Returns:

  the socket
  Type
    DatagramSocket

#### createDnsClient(port, host) → {DnsClient}

  Create a DNS client to connect to a DNS server at the specified host and port

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `port` | number | the port
  `host` | string | the host

  Source:
    - vertx.js, line 220

  ##### Returns:

  the DNS client
  Type
    DnsClient

#### createHttpClient(options) → {HttpClient}

  Create a HTTP/HTTPS client using the specified options

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `options` | Object | the options to use

  Source:
    - vertx.js, line 153

  ##### Returns:

  the client
  Type
    HttpClient

#### createHttpServer(options) → {HttpServer}

  Create an HTTP/HTTPS server using the specified options

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `options` | Object | the options to use

  Source:
    - vertx.js, line 137

  ##### Returns:

  the server
  Type
    HttpServer

#### createNetClient(options) → {NetClient}

  Create a TCP/SSL client using the specified options

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `options` | Object | the options to use

  Source:
    - vertx.js, line 121

  ##### Returns:

  the client
  Type
    NetClient

#### createNetServer(options) → {NetServer}

  Create a TCP/SSL server using the specified options

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `options` | Object | the options to use

  Source:
    - vertx.js, line 105

  ##### Returns:

  the server
  Type
    NetServer

#### deploymentIDs() → {Array.<string>}

  Return a Set of deployment IDs for the currently deployed deploymentIDs.
  Source:
    - vertx.js, line 422

  ##### Returns:

  Set of deployment IDs
  Type
    Array.<string>

#### deployVerticle(name, options, completionHandler)

  Like Vertx#deployVerticle but DeploymentOptions are provided to configure the deployment.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `name` | string | the name
  `options` | Object | the deployment options.
  `completionHandler` | function | a handler which will be notified when the deployment is complete

  Source:
    - vertx.js, line 368

#### eventBus() → {EventBus}

  Get the event bus object. There is a single instance of EventBus per Vertx instance.
  Source:
    - vertx.js, line 202

  ##### Returns:

  the event bus object
  Type
    EventBus

#### executeBlocking(blockingCodeHandler, ordered, resultHandler)

  Safely execute some blocking code.

  Executes the blocking code in the handler `blockingCodeHandler` using a thread from the worker pool.

  When the code is complete the handler `resultHandler` will be called with the result on the original context (e.g. on the original event loop of the caller).

  A `Future` instance is passed into `blockingCodeHandler`. When the blocking code successfully completes, the handler should call the Future#complete or {@link Future#complete} method, or the Future#fail method if it failed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `blockingCodeHandler` | function | handler representing the blocking code to run
  `ordered` | boolean | if true then if executeBlocking is called several times on the same context, the executions for that context will be executed serially, not in parallel. if false then they will be no ordering guarantees
  `resultHandler` | function | handler that will be called when the blocking code is complete

  Source:
    - vertx.js, line 460

#### fileSystem() → {FileSystem}

  Get the filesystem object. There is a single instance of FileSystem per Vertx instance.
  Source:
    - vertx.js, line 185

  ##### Returns:

  the filesystem object
  Type
    FileSystem

#### getOrCreateContext() → {Context}

  Gets the current context, or creates one if there isn't one
  Source:
    - vertx.js, line 91

  ##### Returns:

  The current context (created if didn't exist)
  Type
    Context

#### isClustered() → {boolean}

  Is this Vert.x instance clustered?
  Source:
    - vertx.js, line 436

  ##### Returns:

  true if clustered
  Type
    boolean

#### isMetricsEnabled() → {boolean}

  Whether the metrics are enabled for this measured object
  Source:
    - vertx.js, line 77

  ##### Returns:

  true if the metrics are enabled
  Type
    boolean

#### periodicStream(delay) → {TimeoutStream}

  Returns a periodic timer as a read stream. The timer will be fired every `delay` milliseconds after the has been called.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `delay` | number | the delay in milliseconds, after which the timer will fire

  Source:
    - vertx.js, line 303

  ##### Returns:

  the periodic stream
  Type
    TimeoutStream

#### runOnContext(action)

  Puts the handler on the event queue for the current context so it will be run asynchronously ASAP after all preceeding events have been handled.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `action` | function | a handler representing the action to execute

  Source:
    - vertx.js, line 331

#### setPeriodic(delay, handler) → {number}

  Set a periodic timer to fire every `delay` milliseconds, at which point `handler` will be called with the id of the timer.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `delay` | number | the delay in milliseconds, after which the timer will fire
  `handler` | function | the handler that will be called with the timer ID when the timer fires

  Source:
    - vertx.js, line 286

  ##### Returns:

  the unique ID of the timer
  Type
    number

#### setTimer(delay, handler) → {number}

  Set a one-shot timer to fire after `delay` milliseconds, at which point `handler` will be called with the id of the timer.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `delay` | number | the delay in milliseconds, after which the timer will fire
  `handler` | function | the handler that will be called with the timer ID when the timer fires

  Source:
    - vertx.js, line 253

  ##### Returns:

  the unique ID of the timer
  Type
    number

#### sharedData() → {SharedData}

  Get the shared data object. There is a single instance of SharedData per Vertx instance.
  Source:
    - vertx.js, line 234

  ##### Returns:

  the shared data object
  Type
    SharedData

#### timerStream(delay) → {TimeoutStream}

  Returns a one-shot timer as a read stream. The timer will be fired after `delay` milliseconds after the has been called.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `delay` | number | the delay in milliseconds, after which the timer will fire

  Source:
    - vertx.js, line 270

  ##### Returns:

  the timer stream
  Type
    TimeoutStream

#### undeploy(deploymentID, completionHandler)

  Like [#undeploy(String)] Vertx but the completionHandler will be notified when the undeployment is complete.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `deploymentID` | string | the deployment ID
  `completionHandler` | function | a handler which will be notified when the undeployment is complete

  Source:
    - vertx.js, line 400