leapp.messaging package¶
Submodules¶
leapp.messaging.inprocess module¶
-
class
leapp.messaging.inprocess.
InProcessMessaging
(stored=True, config_model=None, answer_store=None)¶ Bases:
leapp.messaging.BaseMessaging
This class implements the direct database access for the messaging.
-
command
(command)¶ Called to send a command to the workflow execution
Parameters: command (Instance of leapp.messaging.commands.WorkflowCommand
) – A command to send to the workflow execution.Returns: None
-
commands
¶ Returns: List of commands that have been sent to the workflow execution.
-
consume
(actor, *types)¶ Returns all consumable messages and filters them by types
Parameters: - types – Variable number of
leapp.models.Model
derived types to filter messages to be consumed - actor – Actor that consumes the data
Returns: Iterable with messages matching the criteria
- types – Variable number of
-
dialogs
()¶ Gets all dialogs actually encountered during workflow run
Returns: List of encountered dialogs
-
errors
()¶ Gets all produced errors.
Returns: List of newly produced errors
-
feed
(model, actor)¶ Called to pre-fill sent messages and make them available for other actors.
Parameters: - model (
leapp.models.Model
) – Model to send as message payload - actor (
leapp.actors.Actor
) – Actor that sends the message
Returns: the updated message dict
Return type: dict
- model (
-
get_answers
(dialog)¶
-
load
(consumes)¶ Loads all messages that are requested from the consumes attribute of
leapp.actors.Actor
Parameters: consumes – Tuple or list of leapp.models.Model
types to preloadReturns: None Raises: leapp.exceptions.CannotConsumeErrorMessages – When trying to consume ErrorModel
-
load_answers
(answer_file, workflow)¶ Loads answers from a given answer file
Parameters: - answer_file (str) – Path to file to load as answer file
- workflow (
leapp.workflows.Workflow
) –leapp.workflows.Workflow
instance to load the answers for.
Returns: None
-
messages
()¶ Gets all newly produced messages.
Returns: List of newly processed messages
-
produce
(model, actor)¶ Called to send a message available for other actors.
Parameters: - model (
leapp.models.Model
) – Model to send as message payload - actor (
leapp.actors.Actor
) – Actor that sends the message
Returns: the updated message dict
Return type: dict
- model (
-
register_dialog
(dialog, actor)¶
-
report_error
(message, severity, actor, details)¶ Reports an execution error
Parameters: - message (str) – Message to print the error
- severity (leapp.models.error_severity.ErrorSeverity) – Severity of the error
- actor (leapp.actors.Actor) – Actor name that produced the message
- details (dict) – A dictionary where additional context information can be passed along with the error
Returns: None
-
request_answers
(dialog)¶
-
request_stop_after_phase
()¶ If called, it will cause the workflow to stop the execution after the current phase ends.
-
show_message
(message)¶ Display a message in user interterface currently in use (CLI, GUI).
It uses one of the dialog renderers in
leapp.dialogs.renderer
.Parameters: message (str) – Message to show
-
stop_after_phase
¶ Returns True if execution stop was requested after the current
Returns: True if the executed was requested to be stopped.
-
stored
¶ Returns: If the messages are stored immediately, this function returns True, otherwise False.
-
Module contents¶
-
class
leapp.messaging.
BaseMessaging
(stored=True, config_model=None, answer_store=None)¶ Bases:
object
BaseMessaging is the Base class for all messaging implementations. It provides the basic interface that is supported within the framework. These are called the produce and consume methods.
-
command
(command)¶ Called to send a command to the workflow execution
Parameters: command (Instance of leapp.messaging.commands.WorkflowCommand
) – A command to send to the workflow execution.Returns: None
-
commands
¶ Returns: List of commands that have been sent to the workflow execution.
-
consume
(actor, *types)¶ Returns all consumable messages and filters them by types
Parameters: - types – Variable number of
leapp.models.Model
derived types to filter messages to be consumed - actor – Actor that consumes the data
Returns: Iterable with messages matching the criteria
- types – Variable number of
-
dialogs
()¶ Gets all dialogs actually encountered during workflow run
Returns: List of encountered dialogs
-
errors
()¶ Gets all produced errors.
Returns: List of newly produced errors
-
feed
(model, actor)¶ Called to pre-fill sent messages and make them available for other actors.
Parameters: - model (
leapp.models.Model
) – Model to send as message payload - actor (
leapp.actors.Actor
) – Actor that sends the message
Returns: the updated message dict
Return type: dict
- model (
-
get_answers
(dialog)¶
-
load
(consumes)¶ Loads all messages that are requested from the consumes attribute of
leapp.actors.Actor
Parameters: consumes – Tuple or list of leapp.models.Model
types to preloadReturns: None Raises: leapp.exceptions.CannotConsumeErrorMessages – When trying to consume ErrorModel
-
load_answers
(answer_file, workflow)¶ Loads answers from a given answer file
Parameters: - answer_file (str) – Path to file to load as answer file
- workflow (
leapp.workflows.Workflow
) –leapp.workflows.Workflow
instance to load the answers for.
Returns: None
-
messages
()¶ Gets all newly produced messages.
Returns: List of newly processed messages
-
produce
(model, actor)¶ Called to send a message available for other actors.
Parameters: - model (
leapp.models.Model
) – Model to send as message payload - actor (
leapp.actors.Actor
) – Actor that sends the message
Returns: the updated message dict
Return type: dict
- model (
-
register_dialog
(dialog, actor)¶
-
report_error
(message, severity, actor, details)¶ Reports an execution error
Parameters: - message (str) – Message to print the error
- severity (leapp.models.error_severity.ErrorSeverity) – Severity of the error
- actor (leapp.actors.Actor) – Actor name that produced the message
- details (dict) – A dictionary where additional context information can be passed along with the error
Returns: None
-
request_answers
(dialog)¶
-
request_stop_after_phase
()¶ If called, it will cause the workflow to stop the execution after the current phase ends.
-
show_message
(message)¶ Display a message in user interterface currently in use (CLI, GUI).
It uses one of the dialog renderers in
leapp.dialogs.renderer
.Parameters: message (str) – Message to show
-
stop_after_phase
¶ Returns True if execution stop was requested after the current
Returns: True if the executed was requested to be stopped.
-
stored
¶ Returns: If the messages are stored immediately, this function returns True, otherwise False.
-