Skip to content

Commit

Permalink
Rename new handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph-blessing committed Nov 9, 2023
1 parent 3e09b9d commit 0c9f0e4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions link/infrastructure/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
from link.service.handlers import (
delete,
delete_entity,
inform_of_finished_process,
inform_of_started_process,
inform_batch_processing_finished,
inform_batch_processing_started,
inform_current_process_finished,
inform_next_process_started,
list_idle_entities,
log_state_change,
pull,
pull_entity,
start_displaying_progress,
stop_displaying_progress,
)
from link.service.messagebus import CommandHandlers, EventHandlers, MessageBus
from link.service.uow import UnitOfWork
Expand Down Expand Up @@ -74,10 +74,10 @@ def inner(obj: type) -> Any:
)
progress_view = TQDMProgressView()
display = DJProgressDisplayAdapter(translator, progress_view)
event_handlers[events.ProcessStarted] = [partial(inform_of_started_process, display=display)]
event_handlers[events.ProcessFinished] = [partial(inform_of_finished_process, display=display)]
event_handlers[events.BatchProcessingStarted] = [partial(start_displaying_progress, display=display)]
event_handlers[events.BatchProcessingFinished] = [partial(stop_displaying_progress, display=display)]
event_handlers[events.ProcessStarted] = [partial(inform_next_process_started, display=display)]
event_handlers[events.ProcessFinished] = [partial(inform_current_process_finished, display=display)]
event_handlers[events.BatchProcessingStarted] = [partial(inform_batch_processing_started, display=display)]
event_handlers[events.BatchProcessingFinished] = [partial(inform_batch_processing_finished, display=display)]
event_handlers[events.StateChanged] = [
partial(log_state_change, log=create_state_change_logger(translator, logger.info))
]
Expand Down
16 changes: 8 additions & 8 deletions link/service/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,21 @@ def log_state_change(event: events.StateChanged, log: Callable[[events.StateChan
log(event)


def start_displaying_progress(event: events.BatchProcessingStarted, *, display: ProgessDisplay) -> None:
"""Start displaying progress to the user."""
def inform_batch_processing_started(event: events.BatchProcessingStarted, *, display: ProgessDisplay) -> None:
"""Inform the user that batch processing started."""
display.start(event.process, event.identifiers)


def inform_of_started_process(event: events.ProcessStarted, *, display: ProgessDisplay) -> None:
"""Update the display with the entity whose process started."""
def inform_next_process_started(event: events.ProcessStarted, *, display: ProgessDisplay) -> None:
"""Inform the user that the next entity started processing."""
display.update_current(event.identifier)


def inform_of_finished_process(event: events.ProcessFinished, *, display: ProgessDisplay) -> None:
"""Inform the user of an entity finishing its process."""
def inform_current_process_finished(event: events.ProcessFinished, *, display: ProgessDisplay) -> None:
"""Inform the user that the current entity finished processing."""
display.finish_current()


def stop_displaying_progress(event: events.BatchProcessingFinished, *, display: ProgessDisplay) -> None:
"""Stop displaying progress to the user."""
def inform_batch_processing_finished(event: events.BatchProcessingFinished, *, display: ProgessDisplay) -> None:
"""Inform the user that batch processing finished."""
display.stop()

0 comments on commit 0c9f0e4

Please sign in to comment.