Class: Context

vertx-js/context~ Context

new Context()

Source:

Methods

config() → {Object}

If the context is associated with a Verticle deployment, this returns the configuration that was specified when the verticle was deployed.
Source:
Returns:
the configuration of the deployment or null if not a Verticle deployment
Type
Object

deploymentID() → {string}

If the context is associated with a Verticle deployment, this returns the deployment ID of that deployment.
Source:
Returns:
the deployment ID of the deployment or null if not a Verticle deployment
Type
string

exceptionHandler(handler) → {Context}

Set an exception handler called when the context runs an action throwing an uncaught throwable.

When this handler is called, Vertx#currentContext will return this context.

Parameters:
Name Type Description
handler function the exception handler
Source:
Returns:
a reference to this, so the API can be used fluently
Type
Context

executeBlocking(blockingCodeHandler, resultHandler)

Invoke Context#executeBlocking with order = true.
Parameters:
Name Type Description
blockingCodeHandler function handler representing the blocking code to run
resultHandler function handler that will be called when the blocking code is complete
Source:

get(key) → {Object}

Get some data from the context.
Parameters:
Name Type Description
key string the key of the data
Source:
Returns:
the data
Type
Object

getInstanceCount() → {number}

Source:
Returns:
the number of instances of the verticle that were deployed in the deployment (if any) related to this context
Type
number

getLocal(key) → {Object}

Get some local data from the context.
Parameters:
Name Type Description
key string the key of the data
Source:
Returns:
the data
Type
Object

isEventLoopContext() → {boolean}

Is the current context an event loop context?

NOTE! when running blocking code using Vertx#executeBlocking from a standard (not worker) verticle, the context will still an event loop context and this will return true.

Source:
Returns:
true if false otherwise
Type
boolean

isWorkerContext() → {boolean}

Is the current context a worker context?

NOTE! when running blocking code using Vertx#executeBlocking from a standard (not worker) verticle, the context will still an event loop context and this will return false.

Source:
Returns:
true if the current context is a worker context, false otherwise
Type
boolean

owner() → {Vertx}

Source:
Returns:
The Vertx instance that created the context
Type
Vertx

processArgs() → {Array.<string>}

The process args
Source:
Returns:
Type
Array.<string>

put(key, value)

Put some data in the context.

This can be used to share data between different handlers that share a context

Parameters:
Name Type Description
key string the key of the data
value Object the data
Source:

putLocal(key, value)

Put some local data in the context.

This can be used to share data between different handlers that share a context

Parameters:
Name Type Description
key string the key of the data
value Object the data
Source:

remove(key) → {boolean}

Remove some data from the context.
Parameters:
Name Type Description
key string the key to remove
Source:
Returns:
true if removed successfully, false otherwise
Type
boolean

removeLocal(key) → {boolean}

Remove some local data from the context.
Parameters:
Name Type Description
key string the key to remove
Source:
Returns:
true if removed successfully, false otherwise
Type
boolean

runOnContext(action)

Run the specified action asynchronously on the same context, some time after the current execution has completed.
Parameters:
Name Type Description
action function the action to run
Source: