class documentation

class TriggerRequestManager: (source)

View In Hierarchy

Manager for TriggerRequest functionality.

Note

This is a placeholder implementation that will be extended in the future to provide the actual functionality for managing TriggerRequests.

Method configure Configure the GroupManager with the provided configuration.
Method determineNSE Determine the NSE (Network Service Entity) for a given TriggerRequest.
Method hasNSE Check if a given NSE is available.
Method replaceTriggerRequest Attempt to replace an existing TriggerRequest that is currently being processed.
Method restart Restart the TriggerRequestManager.
Method sendTriggerRequest Handle the sending of a TriggerRequest to the determined NSE.
Method start Start the TriggerRequestManager.
Method stop Stop the TriggerRequestManager.
Method terminateTriggerRequest Terminate (or recall) a TriggerRequest that is currently being processed.
Method validate Validate the GroupManager configuration.
Class Variable triggerRequestActors Dictionary to keep track of active TriggerRequest actors. The key is the TriggerRequest resource ID (ri), and the value is a tuple containing the BackgroundWorker instance and the corresponding TGR resource.
Method _terminateAllTriggerRequests Terminate all currently active TriggerRequests. This method is called when the TriggerRequestManager is stopped or restarted.
Method _triggerHandler Internal method to handle the actual sending of the TriggerRequest to the NSE.
Method _triggerHandlerCompleted Internal method called when the trigger handler actor has completed its execution.
def configure(self, config: Configuration): (source)

Configure the GroupManager with the provided configuration.

Parameters
config:ConfigurationThe configuration to apply.
def determineNSE(self, tgr: TGR) -> str | None: (source)

Determine the NSE (Network Service Entity) for a given TriggerRequest.

This method iterates through the registered triggerRequestHandler services that have the triggerRequestHandler tag and calls their acceptsM2MExtID` endpoint to determine if they can handle the provided TriggerRequest's M2M-Ext-ID.

Parameters
tgr:TGRThe TriggerRequest resource for which to determine the NSE.
Returns
str | NoneThe first NSE service handler plugin's name if found, otherwise None.
def hasNSE(self, nse: str) -> bool: (source)

Check if a given NSE is available.

Parameters
nse:strThe name of the NSE service handler plugin to check.
Returns
boolTrue if the NSE is available, False otherwise.
def replaceTriggerRequest(self, tgr: TGR, nse: str) -> bool: (source)

Attempt to replace an existing TriggerRequest that is currently being processed.

This method checks if the provided TriggerRequest is currently being processed by an actor. If it is, it attempts to terminate the existing processing and allows for a new TriggerRequest to be sent in its place.

Parameters
tgr:TGRThe TriggerRequest resource that is attempting to replace an existing one.
nse:strThe name of the NSE service handler plugin to which the TriggerRequest should be sent.
Returns
boolTrue if the existing TriggerRequest was successfully terminated and replaced, False otherwise.
def restart(self): (source)

Restart the TriggerRequestManager.

def sendTriggerRequest(self, tgr: TGR, nse: str, replace: bool = False): (source)

Handle the sending of a TriggerRequest to the determined NSE.

This method is responsible for initiating the process of sending the TriggerRequest to the determined NSE. The actual sending process may be asynchronous and handled in the background.

Parameters
tgr:TGRThe TriggerRequest resource to be sent.
nse:strThe name of the NSE service handler plugin to which the TriggerRequest should be sent.
replace:boolA boolean indicating whether this is a replacement of an existing TriggerRequest. If True, the NSE handler may handle the request differently.
def start(self): (source)

Start the TriggerRequestManager.

def stop(self): (source)

Stop the TriggerRequestManager.

def terminateTriggerRequest(self, tgr: TGR, replace: bool = False) -> bool: (source)

Terminate (or recall) a TriggerRequest that is currently being processed.

This method is responsible for stopping any background processing related to the provided TriggerRequest. It should be called when a TriggerRequest is deleted or no longer needs to be processed.

This method also removes the TriggerRequest's actor from the triggerRequestActors dictionary and calls the terminateTriggerRequest endpoint of the assigned NSE service handler plugin to notify it of the termination.

Parameters
tgr:TGRThe TriggerRequest resource to be terminated.
replace:boolA boolean indicating whether this termination is part of a replacement process. If True, the NSE handler may handle the termination differently.
Returns
boolTrue if the TriggerRequest was successfully terminated, False otherwise. True is also returned if the TriggerRequest was not currently being processed.
def validate(self, config: Configuration): (source)

Validate the GroupManager configuration.

Parameters
config:ConfigurationThe configuration to validate.
triggerRequestActors: dict[str, tuple[BackgroundWorker, TGR]] = (source)

Dictionary to keep track of active TriggerRequest actors. The key is the TriggerRequest resource ID (ri), and the value is a tuple containing the BackgroundWorker instance and the corresponding TGR resource.

Be aware that this Triggerrequest resource may be updated or deleted outside of this manager, so the manager should always check the current state of the resource before acting on it.

def _terminateAllTriggerRequests(self): (source)

Terminate all currently active TriggerRequests. This method is called when the TriggerRequestManager is stopped or restarted.

def _triggerHandler(self, tgr: TGR, nse: str, replace: bool, actor: BackgroundWorker): (source)

Internal method to handle the actual sending of the TriggerRequest to the NSE.

This method is executed in a background worker and is responsible for the actual communication with the NSE. It should handle any necessary retries, error handling, and updating of the TriggerRequest's status based on the response from the NSE.

Parameters
tgr:TGRThe TriggerRequest resource to be sent.
nse:strThe name of the NSE service handler plugin to which the TriggerRequest should be sent.
replace:boolA boolean indicating whether this is a replacement of an existing TriggerRequest. If True, the NSE handler may handle the request differently.
actor:BackgroundWorkerThe background worker actor handling this trigger request.
def _triggerHandlerCompleted(self, tgr: TGR, nse: str, actor: BackgroundWorker): (source)

Internal method called when the trigger handler actor has completed its execution.

This method is responsible for cleaning up after the trigger handling process, including removing the actor from the triggerRequestActors dictionary and performing any necessary finalization steps.

Parameters
tgr:TGRThe TriggerRequest resource that was being processed.
nse:strThe name of the NSE service handler plugin to which the TriggerRequest was sent.
actor:BackgroundWorkerThe background worker actor that handled this trigger request.