This generic base program class is intended to be used as a building block through inheritance when you are creating a server program.
Any methods that you need to change, you override it using polymorphism.
RabbitMQ is used for sending messages to external programs. Messages that are to be sent to the RabbitMQ will be stored offline if the communication goes down and will be re-sent when the communication is re-established.
- Subscribe temporarily for the following RabbitMQ message topic(s):
- Health.Request
- Sends RabbitMQ messages with the following topic(s):
- Error.Message.AsyncExampleProgram.<server>
- Health.Response.AsyncExampleProgram.<server>
| Method | __init__ |
The class constructor. |
| Async Method | exit |
Stop the server program. |
| Async Method | run |
Start the server program. |
| Instance Variable | error |
Program exit error status. |
| Instance Variable | future |
Asyncio Future handle (used for handling fatal error program exit). |
| Instance Variable | ini |
Handles INI file parameters for this program. |
| Instance Variable | location |
Current program name, including the path. |
| Instance Variable | log |
Handle colored and dynamic filter logging. |
| Instance Variable | program |
Current program name, used for logging. |
| Instance Variable | scheduler |
Handles periodic ini file change checks. |
| Instance Variable | worker |
Handles the bulk of the work for this program. |
| Method | _demo |
This method is only used for demo. |
| Async Method | _fatal |
Report error and trigger a fatal program exit. |
| Async Method | _handle |
Trigger a fatal program exit when errors found and fatal==True. |
| Async Method | _initiate |
Initiate resources used by the program. |
| Async Method | _initiate |
Initiate unique resources used by the program. |
| Async Method | _schedule |
Extract and validate INI file content if the Ini file is updated. |
| Async Method | _schedule |
Send INI file update notification to the worker. |
Start the server program.
- The following actions are performed:
- Initiate used resources.
- Start dynamic log level handling.
- Wait for program termination.
Trigger a fatal program exit when errors found and fatal==True.
| Parameters | |
fatal:bool | Is the error fatal or not? |
Initiate resources used by the program.
- The following actions are performed:
- Initiate unique resources used by the program.
- Start Ini file change supervision (every 5 seconds).
- Setup waits for program termination.
Initiate unique resources used by the program.
Abstract method that needs to be overridden.
- The following actions are performed:
- Validate INI file content.
- Start log processing.
- Initiate current worker.
Extract and validate INI file content if the Ini file is updated.
This method is called by the AsyncIOScheduler every 5 seconds.
A RuntimeError is raised if the validation of the changed INI file content fails, otherwise the worker is notified if the relevant parameter has changed.
| Raises | |
RuntimeError | When INI file validation fails. |