message_handling_service
messageflux.message_handling_service
BatchMessageHandlerBase
a batch message handler base class. used to handle a batch of messages
handle_message_batch
abstractmethod
handles a batch of messages that was read from input devices
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch |
List[Tuple[InputDevice, ReadResult]]
|
a list of tuples of input device and the ReadResult object that was read from it |
required |
prepare
called when the service starts. can be overrided by child class to perform some initialization logic
BatchMessageHandlingService
Bases: MessageHandlingServiceBase
a service that reads from input devices and handles the messages
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch_handler |
BatchMessageHandlerBase
|
the message handler to use. |
required |
**kwargs |
passed to parent as is |
{}
|
MessageHandlerBase
a message handler base class. used to handle a single message
handle_message
abstractmethod
handles a single message from the device
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_device |
InputDevice
|
the input device that the message was read from |
required |
read_result |
ReadResult
|
the read result returned from the device |
required |
prepare
called when the service starts. can be overrided by child class to perform some initialization logic
MessageHandlingService
Bases: BatchMessageHandlingService
a service that reads a SINGLE message from devices and handles it
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs |
passed to parent as is |
{}
|
MessageHandlingServiceBase
MessageHandlingServiceBase(
*,
input_device_manager,
input_device_names,
use_transactions=True,
read_timeout=5,
max_batch_read_count=1,
wait_for_batch_count=False,
**kwargs
)
Bases: ServerLoopService
a service thats reads from input devices and handles the messages
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_device_manager |
InputDeviceManager
|
the device manager to read messages from |
required |
input_device_names |
Union[List[str], str]
|
the device names to read messages from |
required |
use_transactions |
bool
|
whether to use transaction when reading from device |
True
|
read_timeout |
float
|
the time (in seconds) to wait on device to return a message |
5
|
max_batch_read_count |
int
|
the maximum batch size to read from device |
1
|
wait_for_batch_count |
bool
|
should the service wait the whole read_timeout for batch_count messages to be read. 'False' means that it will read up-to batch_count messages, and process them immediately. 'True' means that it will wait until read_timeout is passed, or batch_count messages has reached. |
False
|
**kwargs |
passed to parent as is |
{}
|