Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: invert dependency between Message and Connection #457

Merged
merged 1 commit into from
Oct 2, 2024

Conversation

sangelovic
Copy link
Collaborator

@sangelovic sangelovic commented Oct 1, 2024

This reorganizes the layers of abstraction in the sense how Message depends on Connection and vice versa. Now, Message has a link to the Connection. This replaces the shortcut link to the low-level SdBus interface that the Message kept. The interactions from Message now go through Connection which forwards them to SdBus. Connection is now a sole owner of the low-level SdBus interface. This allows for future changes around SdBus (e.g. a change from virtual functions back to non-virtual functions) without affecting the rest of the library. Proxys and Objects can now send messages directly without having to go through Connection. The Connection no more depends on Message business-logic methods; it serves only as a factory for messages.

The flow for creating messages: Proxy/Object -> Connection -> SdBus
The flow for sending messages: (Proxy/Object ->) Message -> Connection -> SdBus

This also better reflects how dependencies are managed in the underlying sd-bus library.

Additionally, getSdBusInterface() methods are removed which was anyway planned, and improves the design by "Tell, don't ask" principle.

This refactoring is the necessary enabler for other upcoming improvements (regarding sending long messages, or creds refactoring, for example).

@sangelovic sangelovic requested a review from Oxymoron79 October 1, 2024 11:07
@sangelovic sangelovic force-pushed the refactor/message-connection branch from e6d1d25 to 5ae3916 Compare October 1, 2024 11:23
@sangelovic sangelovic force-pushed the refactor/message-connection branch from 5ae3916 to 497939e Compare October 1, 2024 11:28
@sangelovic sangelovic merged commit 107c6a1 into master Oct 2, 2024
6 checks passed
@sangelovic sangelovic deleted the refactor/message-connection branch October 2, 2024 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant