Manager for interceptors. This class is responsible for registering interceptors and calling the appropriate interceptor handlers when a request is processed by the CSE. It maintains a registry of all interceptor handlers and their metadata, and uses this registry to find and call the appropriate handlers for each request.
| Method | __init__ |
Initialize the InterceptorManager with an empty registry and cache. |
| Method | intercept |
Call the interceptor handlers for the REQUEST_ERROR_RESPONSE phase. |
| Method | intercept |
Call the interceptor handlers for the REQUEST_POST_PROCESSING phase. |
| Method | intercept |
Call the interceptor handlers for the REQUEST_PRE_PROCESSING phase. |
| Method | register |
Register an interceptor with the InterceptorManager. This method is called when an interceptor plugin is loaded and instantiated. |
| Method | _find |
Find and return the list of interceptor handlers for the given phase, operation, and resource type. |
| Instance Variable | _cache |
Cache for interceptor handler lookups. The keys are InterceptorFilter tuples and the values are lists of InterceptorHandlerInfo objects that match the filter. This cache is used to speed up the lookup of interceptor handlers for each request... |
| Instance Variable | _registry |
The registry of interceptor handlers. This is a list of InterceptorHandlerInfo objects that contain the handler function and its metadata (phase, operation, resource, priority). This registry is populated when interceptors are registered with the InterceptorManager. |
Call the interceptor handlers for the REQUEST_ERROR_RESPONSE phase.
| Parameters | |
request:CSERequest | The incoming CSERequest object that is being processed. |
result:Result | The Result object that is the response to the request, which can be modified by the interceptor handlers. |
Call the interceptor handlers for the REQUEST_POST_PROCESSING phase.
| Parameters | |
request:CSERequest | The incoming CSERequest object that is being processed. |
result:Result | The Result object that is the response to the request, which can be modified by the interceptor handlers. |
Call the interceptor handlers for the REQUEST_PRE_PROCESSING phase.
| Parameters | |
request:CSERequest | The incoming CSERequest object that is being processed. |
Register an interceptor with the InterceptorManager. This method is called when an interceptor plugin is loaded and instantiated.
pluginName: The name of the plugin that the interceptor belongs to.
| Parameters | |
interceptor:Interceptor | The interceptor instance to register. This instance should have its handler methods decorated with @intercept. |
pluginstr | Undocumented |
Find and return the list of interceptor handlers for the given phase, operation, and resource type.
This method uses caching to improve performance. The cache is invalidated whenever a new interceptor is registered.
| Parameters | |
filter:InterceptorFilter | A tuple of (phase, operation, resource) to find handlers for. Each element can be a specific value or None to match all. |
| Returns | |
list | A list of interceptor handlers sorted by priority, or an empty list if no handlers are found. |
Cache for interceptor handler lookups. The keys are InterceptorFilter tuples and the values are lists of InterceptorHandlerInfo objects that match the filter. This cache is used to speed up the lookup of interceptor handlers for each request. The cache is invalidated whenever a new interceptor is registered.