Options
All
  • Public
  • Public/Protected
  • All
Menu

Class OperationContext

Provides information about the context of the current operation.

The OperationContext is used to find out information about the request that trigger the current operation. The operation context can also be used to store information associated with a particular operation across async gaps.

In order to store data associated with the current operation across async gaps, a domain is created during operation invocation. This has the added benefit of being able to capture exceptions and route them through the error handling pipeline.

Note that if unhandled exceptions are caught, the RequestDispatcher should be closed by calling close and the process should exit once all pending operations have completed. (This is indicated by the closed event on the RequestDispatcher.) See the node documentation for more information.

Creation of an OperationContext is disabled by default. It is be enabled for a service by setting createOperationContext to true on the DispatchService. This can be accomplished by adding the Service decorator to the service implementation:

 @Service({ createOperationContext: true })
 @Contract("Calculator")
 class CalculatorService {
     ...
 }

Note that domains have been deprecated in Node.js and will be removed in the future. According to the discussion referenced above, they will not be removed until a viable alternative is introduced. However, this may introduce breaking changes in the usage of OperationContext.

Hierarchy

  • OperationContext

Index

Properties

items

items: Map<string, any>

Dictionary of values associated with the OperationContext. Can be used to share data between functions within the context of the execution of an operation.

outgoingHeaders

outgoingHeaders: MessageHeaders

Outgoing headers to be added to HTTP response. Note that the headers are not added if a fault is returned or for one-way operations.

requestContext

requestContext: RequestContext

Gets the RequestContext associated with the operation.

Accessors

Static current

  • Gets the OperationContext associated with the active domain. Throws an error if there is not an active domain.

    Returns OperationContext

  • Sets the OperationContext associated with the active domain. Throws an error if there is not an active domain.

    Parameters

    Returns void

Generated using TypeDoc