Module balling_channels

Source
Expand description

Container for the channels of the Balling module A central container for all inter-thread communication channels used by the Balling module.

This module defines the BallingChannels struct, which acts as a dedicated “switchboard” for the Balling dosing thread. Its primary purpose is to aggregate all the mpsc::channel senders and receivers that the Balling thread needs to communicate with other concurrent parts of the application, such as the RelayManager, SignalHandler, ScheduleCheck, and the IPC Messaging thread.

§Key Components

  • BallingChannels Struct: A simple container struct that explicitly declares all the communication dependencies of the Balling thread.

  • Helper Methods: Provides convenient wrapper methods like send_to_relay_manager() and receive_from_schedule_check(). These methods offer a clean, consistent API for channel operations and abstract away the direct use of the sender/receiver fields.

§Design and Architecture

The BallingChannels struct is a key part of the application’s inter-thread communication strategy, promoting clean and decoupled code.

  • Centralization: By gathering all necessary channels into a single struct, it provides a clear and explicit declaration of the Balling thread’s communication dependencies. This makes the overall architecture easier to reason about.

  • Decoupling: The main Balling thread logic doesn’t need to manage a list of individual channels. It just needs this struct, which it can use to send and receive messages. This separates the core control logic from the communication infrastructure.

  • Testability: The struct’s channels can be used by mock implementation during unit testing, allowing for isolated testing of the Feed thread’s logic without needing to run the entire application.

Structs§

BallingChannels
Container for the channels used by Balling for inter-thread communication