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.

To create an instance of this class you can use the static factory methods: @see \io\vertx\jphp\core\Vertx::vertx,

see

and @see \io\vertx\jphp\core\Vertx::clusteredVertx.

Please see the user manual for more detailed usage information.

package

Default

Methods

__construct

__construct() 

Cancels the timer with the specified <code>id</code>.

cancelTimer( $arg0) : boolean

Arguments

$arg0

integer

Response

boolean

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

Stop the the Vertx instance and release any resources held by it.

close( $arg0 = null) : void

The instance cannot be used after it has been closed.

The actual close is asynchronous and may not complete until after the call has returned. close() Like @see \io\vertx\jphp\core\Vertx::close but the completionHandler will be called when the close is complete param $completionHandler [callable] The handler will be notified when the close is complete. close($completionHandler)

Arguments

$arg0

callable

Creates a clustered instance using the specified options.

clusteredVertx( $arg0,  $arg1) : void
static

The instance is created asynchronously and the resultHandler is called with the result when it is ready.

Arguments

$arg0

array | VertxOptions

$arg1

callable

Create a datagram socket using default options

createDatagramSocket( $arg0 = null) : \io\vertx\jphp\core\datagram\DatagramSocket

createDatagramSocket()

Create a datagram socket using the specified options

param $options [DatagramSocketOptions | array] the options to use createDatagramSocket($options)

Arguments

$arg0

DatagramSocketOptions | array

Response

\io\vertx\jphp\core\datagram\DatagramSocket

the socket

Create a DNS client to connect to the DNS server configured by @see \io\vertx\jphp\core\VertxOptions <p> DNS client takes the first configured resolver address provided by }

createDnsClient( $arg0 = null,  $arg1 = null) : \io\vertx\jphp\core\dns\DnsClient

createDnsClient()

Create a DNS client to connect to a DNS server

param $options [DnsClientOptions | array] the client options createDnsClient($options)

Create a DNS client to connect to a DNS server at the specified host and port, with the default query timeout (5 seconds)

param $port [integer] the port param $host [string] the host createDnsClient($port, $host)

Arguments

$arg0

DnsClientOptions | array | integer

$arg1

string

Response

\io\vertx\jphp\core\dns\DnsClient

the DNS client

Create a HTTP/HTTPS client using default options

createHttpClient( $arg0 = null) : \io\vertx\jphp\core\http\HttpClient

createHttpClient()

Create a HTTP/HTTPS client using the specified options

param $options [HttpClientOptions | array] the options to use createHttpClient($options)

Arguments

$arg0

array | HttpClientOptions

Response

\io\vertx\jphp\core\http\HttpClient

the client

Create an HTTP/HTTPS server using default options

createHttpServer( $arg0 = null) : \io\vertx\jphp\core\http\HttpServer

createHttpServer()

Create an HTTP/HTTPS server using the specified options

param $options [HttpServerOptions | array] the options to use createHttpServer($options)

Arguments

$arg0

array | HttpServerOptions

Response

\io\vertx\jphp\core\http\HttpServer

the server

Create a TCP/SSL client using default options

createNetClient( $arg0 = null) : \io\vertx\jphp\core\net\NetClient

createNetClient()

Create a TCP/SSL client using the specified options

param $options [NetClientOptions | array] the options to use createNetClient($options)

Arguments

$arg0

NetClientOptions | array

Response

\io\vertx\jphp\core\net\NetClient

the client

Create a TCP/SSL server using default options

createNetServer( $arg0 = null) : \io\vertx\jphp\core\net\NetServer

createNetServer()

Create a TCP/SSL server using the specified options

param $options [NetServerOptions | array] the options to use createNetServer($options)

Arguments

$arg0

array | NetServerOptions

Response

\io\vertx\jphp\core\net\NetServer

the server

Like @see \io\vertx\jphp\core\Vertx::createSharedWorkerExecutor but with the @see \io\vertx\jphp\core\VertxOptions <code>poolSize</code>.

createSharedWorkerExecutor( $arg0,  $arg1 = null,  $arg2 = null,  $arg3 = null) : \io\vertx\jphp\core\WorkerExecutor

param $name [string] createSharedWorkerExecutor($name)

Like @see \io\vertx\jphp\core\Vertx::createSharedWorkerExecutor but with the @see \io\vertx\jphp\core\VertxOptions maxExecuteTime.

param $name [string] param $poolSize [integer] createSharedWorkerExecutor($name, $poolSize)

Like @see \io\vertx\jphp\core\Vertx::createSharedWorkerExecutor but with the .

param $name [string] param $poolSize [integer] param $maxExecuteTime [integer] createSharedWorkerExecutor($name, $poolSize, $maxExecuteTime)

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 @see \io\vertx\jphp\core\WorkerExecutor sharing the same name are closed.

param $name [string] the name of the worker executor param $poolSize [integer] the size of the pool param $maxExecuteTime [integer] the value of max worker execute time param $maxExecuteTimeUnit [string] the value of unit of max worker execute time createSharedWorkerExecutor($name, $poolSize, $maxExecuteTime, $maxExecuteTimeUnit)

Arguments

$arg0

string

$arg1

integer

$arg2

integer

$arg3

string

Response

\io\vertx\jphp\core\WorkerExecutor

Gets the current context

currentContext() : \io\vertx\jphp\core\Context
static

Response

\io\vertx\jphp\core\Context

The current context or null if no current context

Return a Set of deployment IDs for the currently deployed deploymentIDs.

deploymentIDs() : array

Response

array

Set of deployment IDs

Deploy a verticle instance given a name.

deployVerticle( $arg0,  $arg1 = null,  $arg2 = null) : void

Given the name, Vert.x selects a instance to use to instantiate the verticle.

For the rules on how factories are selected please consult the user manual. param $name [string] the name. deployVerticle($name) Like @see \io\vertx\jphp\core\Vertx::deployVerticle but the completionHandler will be notified when the deployment is complete.

If the deployment is successful the result will contain a String representing the unique deployment ID of the deployment.

This deployment ID can subsequently be used to undeploy the verticle. param $name [string] The identifier param $completionHandler [callable] a handler which will be notified when the deployment is complete deployVerticle($name, $completionHandler) Like @see \io\vertx\jphp\core\Vertx::deployVerticle but @see \io\vertx\jphp\core\DeploymentOptions are provided to configure the deployment. param $name [string] the name param $options [DeploymentOptions | array] the deployment options. deployVerticle($name, $options) Like @see \io\vertx\jphp\core\Vertx::deployVerticle but @see \io\vertx\jphp\core\DeploymentOptions are provided to configure the deployment. param $name [string] the name param $options [DeploymentOptions | array] the deployment options. param $completionHandler [callable] a handler which will be notified when the deployment is complete deployVerticle($name, $options, $completionHandler)

Arguments

$arg0

string

$arg1

callable | DeploymentOptions | array

$arg2

callable

Get the event bus object. There is a single instance of EventBus per Vertx instance.

eventBus() : \io\vertx\jphp\core\eventbus\EventBus

Response

\io\vertx\jphp\core\eventbus\EventBus

the event bus object

Set a default exception handler for @see \io\vertx\jphp\core\Context, set on at creation.

exceptionHandler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

a reference to this, so the API can be used fluently

Like @see \io\vertx\jphp\core\Vertx::executeBlocking called with ordered = true.

executeBlocking( $arg0,  $arg1,  $arg2 = null) : void

param $blockingCodeHandler [callable] param $resultHandler [callable] executeBlocking($blockingCodeHandler, $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 @see \io\vertx\jphp\core\Future::complete or @see \io\vertx\jphp\core\Future::complete method, or the @see \io\vertx\jphp\core\Future::fail method if it failed.

In the blockingCodeHandler the current context remains the original context and therefore any task scheduled in the blockingCodeHandler will be executed on the this context and not on the worker thread. param $blockingCodeHandler [callable] handler representing the blocking code to run param $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 param $resultHandler [callable] handler that will be called when the blocking code is complete executeBlocking($blockingCodeHandler, $ordered, $resultHandler)

Arguments

$arg0

callable

$arg1

callable | boolean

$arg2

callable

Get the filesystem object. There is a single instance of FileSystem per Vertx instance.

fileSystem() : \io\vertx\jphp\core\file\FileSystem

Response

\io\vertx\jphp\core\file\FileSystem

the filesystem object

Gets the current context, or creates one if there isn't one

getOrCreateContext() : \io\vertx\jphp\core\Context

Response

\io\vertx\jphp\core\Context

The current context (created if didn't exist)

Is this Vert.x instance clustered?

isClustered() : boolean

Response

boolean

true if clustered

Whether the metrics are enabled for this measured object

isMetricsEnabled() : boolean

Response

boolean

{@code true} if metrics are enabled

isNativeTransportEnabled

isNativeTransportEnabled() : boolean

Response

boolean

whether the native transport is used

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

periodicStream( $arg0) : \io\vertx\jphp\core\TimeoutStream

Arguments

$arg0

integer

Response

\io\vertx\jphp\core\TimeoutStream

the periodic stream

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.

runOnContext( $arg0) : void

Arguments

$arg0

callable

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

setPeriodic( $arg0,  $arg1) : integer

Arguments

$arg0

integer

$arg1

callable

Response

integer

the unique ID of the timer

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

setTimer( $arg0,  $arg1) : integer

Arguments

$arg0

integer

$arg1

callable

Response

integer

the unique ID of the timer

Get the shared data object. There is a single instance of SharedData per Vertx instance.

sharedData() : \io\vertx\jphp\core\shareddata\SharedData

Response

\io\vertx\jphp\core\shareddata\SharedData

the shared data object

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

timerStream( $arg0) : \io\vertx\jphp\core\TimeoutStream

Arguments

$arg0

integer

Response

\io\vertx\jphp\core\TimeoutStream

the timer stream

Undeploy a verticle deployment.

undeploy( $arg0,  $arg1 = null) : void

The actual undeployment happens asynchronously and may not complete until after the method has returned. param $deploymentID [string] the deployment ID undeploy($deploymentID) Like @see \io\vertx\jphp\core\Vertx #undeploy(String) but the completionHandler will be notified when the undeployment is complete. param $deploymentID [string] the deployment ID param $completionHandler [callable] a handler which will be notified when the undeployment is complete undeploy($deploymentID, $completionHandler)

Arguments

$arg0

string

$arg1

callable

Creates a non clustered instance using default options.

vertx( $arg0 = null) : \io\vertx\jphp\core\Vertx
static

vertx()

Creates a non clustered instance using the specified options

param $options [VertxOptions | array] the options to use vertx($options)

Arguments

$arg0

array | VertxOptions

Response

\io\vertx\jphp\core\Vertx

the instance