Package com.codingchili.core.context
Interface CoreContext
- All Known Implementing Classes:
ContextMock
,StorageContext
,SystemContext
public interface CoreContext
Provides a simplified subset of the vertx toolkit with some wrapping
to simplify usage.
-
Method Summary
Modifier and TypeMethodDescription<T> void
blocking(io.vertx.core.Handler<io.vertx.core.Promise<T>> blocking, boolean ordered, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> result)
Call to execute the given blocking handler on a worker thread that is scoped to the current context.<T> void
blocking(io.vertx.core.Handler<io.vertx.core.Promise<T>> blocking, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> result)
Call to execute the given blocking handler on a worker thread that is scoped to the current context.io.vertx.core.eventbus.EventBus
bus()
void
cancel(long timer)
Cancels a running timer.void
close()
Shuts down the context and underlying pools and connections.void
io.vertx.core.Future<String>
Instantiates an object of the given class identifier and determines the type that should be deployed.default io.vertx.core.file.FileSystem
io.vertx.core.Future<String>
handler(Supplier<CoreHandler> handler)
Deploys a new handler in the cluster from given handler with a completion handler.io.vertx.core.Future<String>
listener(Supplier<CoreListener> listener)
Deploys the given verticle with a completion handler.metrics()
Creates a new metric namespace using the registryName.void
periodic(TimerSource delay, io.vertx.core.Handler<Long> handler)
Set a periodic timer that uses a timersource to adjust interval during runtime.io.vertx.core.Future<String>
service(Supplier<CoreService> service)
Deploys the given verticle with a completion handler.io.vertx.core.Future<io.vertx.core.CompositeFuture>
stop()
void
Undeploys a deployed handler by the deployment id.system()
long
Sets a timer that executes the given handler after the given time.io.vertx.core.Vertx
vertx()
-
Method Details
-
vertx
io.vertx.core.Vertx vertx()- Returns:
- the vertx instance.
-
bus
io.vertx.core.eventbus.EventBus bus()- Returns:
- get the EventBus attached to the vertx instance.
-
metrics
MetricCollector metrics()- Returns:
- the metrics collector.
-
metrics
Creates a new metric namespace using the registryName.- Parameters:
registryName
- the name of the registry to attach metrics to.- Returns:
- a new metric collector using the default timer.
-
fileSystem
default io.vertx.core.file.FileSystem fileSystem()- Returns:
- get filesystem access.
-
system
SystemSettings system()- Returns:
- the system configuration.
-
periodic
Set a periodic timer that uses a timersource to adjust interval during runtime.- Parameters:
delay
- a timer source that may change period during runtime.handler
- the handler to be invoked when each interval ends.
-
timer
Sets a timer that executes the given handler after the given time.- Parameters:
ms
- time unit in ms.handler
- the handler to be invoken when the timer runs out.- Returns:
- the id of the created timer so that it may be cancelled.
-
cancel
void cancel(long timer)Cancels a running timer.- Parameters:
timer
- the id of the timer to be stopped.
-
deploy
Instantiates an object of the given class identifier and determines the type that should be deployed. May be aCoreHandler
CoreService
CoreListener
or a plainVerticle
.- Parameters:
target
- the target class to deploy.- Returns:
- future completed on deployment.
-
handler
Deploys a new handler in the cluster from given handler with a completion handler.- Parameters:
handler
- the handler to be used to handle incoming requests.- Returns:
- a future to be completed on deployment completion.
-
listener
Deploys the given verticle with a completion handler.- Parameters:
listener
- the verticle to be deployed.- Returns:
- future completed on deployment completion.
-
service
Deploys the given verticle with a completion handler.- Parameters:
service
- the verticle to be deployed.- Returns:
- future to be completed on deployment completion.
-
stop
Undeploys a deployed handler by the deployment id.- Parameters:
deploymentId
- the id of the deployment to undeploy.
-
stop
io.vertx.core.Future<io.vertx.core.CompositeFuture> stop() -
blocking
<T> void blocking(io.vertx.core.Handler<io.vertx.core.Promise<T>> blocking, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> result)Call to execute the given blocking handler on a worker thread that is scoped to the current context.- Type Parameters:
T
- type parameter.- Parameters:
blocking
- a method that is blocking, to be executed on worker thread.result
- handler for the result of the blocking execution.
-
blocking
<T> void blocking(io.vertx.core.Handler<io.vertx.core.Promise<T>> blocking, boolean ordered, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> result)Call to execute the given blocking handler on a worker thread that is scoped to the current context.- Type Parameters:
T
- type parameter for the result- Parameters:
blocking
- a handler that executes blocking codeordered
- if true, indicates that the tasks must be completed in the same order as they are started.result
- handler for the result that is called asynchronously
-
logger
- Parameters:
aClass
- added as metadata to all logged events.- Returns:
- get a new instance of a logger.
-
close
void close()Shuts down the context and underlying pools and connections. -
close
- Parameters:
handler
- called when the context has closed or failed closing.
-