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:
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:
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:
createDatagramSocket() → {DatagramSocket}
Create a datagram socket using default options
- Source:
Returns:
the socket
- Type
- DatagramSocket
createDnsClient(options) → {DnsClient}
Create a DNS client to connect to a DNS server
Parameters:
| Name | Type | Description |
|---|---|---|
options |
Object | the client options |
- Source:
Returns:
the DNS client
- Type
- DnsClient
createHttpClient() → {HttpClient}
Create a HTTP/HTTPS client using default options
- Source:
Returns:
the client
- Type
- HttpClient
createHttpServer() → {HttpServer}
Create an HTTP/HTTPS server using default options
- Source:
Returns:
the server
- Type
- HttpServer
createNetClient() → {NetClient}
Create a TCP/SSL client using default options
- Source:
Returns:
the client
- Type
- NetClient
createNetServer() → {NetServer}
Create a TCP/SSL server using default options
- Source:
Returns:
the server
- Type
- NetServer
createSharedWorkerExecutor(name, poolSize, maxExecuteTime, maxExecuteTimeUnit) → {WorkerExecutor}
Create a named worker executor, the executor should be closed when it's not needed anymore to release
resources.
This method can be called mutiple times with the same
name. Executors with the same name will share
the same worker pool. The worker pool size , max execute time and unit of max execute time are set when the worker pool is created and
won't change after.The worker pool is released when all the WorkerExecutor sharing the same name are closed.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | the name of the worker executor |
poolSize |
number | the size of the pool |
maxExecuteTime |
number | the value of max worker execute time |
maxExecuteTimeUnit |
Object | the value of unit of max worker execute time |
- Source:
Returns:
the named worker executor
- Type
- WorkerExecutor
deploymentIDs() → {Array.<string>}
Return a Set of deployment IDs for the currently deployed deploymentIDs.
- Source:
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:
eventBus() → {EventBus}
Get the event bus object. There is a single instance of EventBus per Vertx instance.
- Source:
Returns:
the event bus object
- Type
- EventBus
exceptionHandler(handler) → {Vertx}
Set a default exception handler for Context, set on at creation.
Parameters:
| Name | Type | Description |
|---|---|---|
handler |
function | the exception handler |
- Source:
Returns:
a reference to this, so the API can be used fluently
- Type
- Vertx
executeBlocking(blockingCodeHandler, resultHandler)
Like Vertx#executeBlocking called with ordered = true.
Parameters:
| Name | Type | Description |
|---|---|---|
blockingCodeHandler |
function | |
resultHandler |
function |
- Source:
fileSystem() → {FileSystem}
Get the filesystem object. There is a single instance of FileSystem per Vertx instance.
- Source:
Returns:
the filesystem object
- Type
- FileSystem
getOrCreateContext() → {Context}
Gets the current context, or creates one if there isn't one
- Source:
Returns:
The current context (created if didn't exist)
- Type
- Context
isClustered() → {boolean}
Is this Vert.x instance clustered?
- Source:
Returns:
true if clustered
- Type
- boolean
isMetricsEnabled() → {boolean}
Whether the metrics are enabled for this measured object
- Source:
Returns:
true if metrics are enabled
- Type
- boolean
isNativeTransportEnabled() → {boolean}
- Source:
Returns:
whether the native transport is used
- 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:
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:
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:
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:
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:
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:
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: