# 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 66

### 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 319

  ##### 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 346

#### 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 171

  ##### 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 222

  ##### 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 155

  ##### 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 139

  ##### 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 123

  ##### 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 107

  ##### Returns:

  the server
  Type
    NetServer

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

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

  ##### 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 370

#### eventBus() → {EventBus}

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

  ##### 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 462

#### fileSystem() → {FileSystem}

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

  ##### Returns:

  the filesystem object
  Type
    FileSystem

#### getOrCreateContext() → {Context}

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

  ##### Returns:

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

#### isClustered() → {boolean}

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

  ##### Returns:

  true if clustered
  Type
    boolean

#### isMetricsEnabled() → {boolean}

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

  ##### 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 305

  ##### 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 333

#### 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 288

  ##### 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 255

  ##### 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 236

  ##### 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 272

  ##### 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 402