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

Refactoring: cleanup, renaming and restructuring #70

Merged
merged 20 commits into from
Nov 28, 2024
Merged

Conversation

evlekht
Copy link
Member

@evlekht evlekht commented Nov 22, 2024

A lot of renaming, considerable amount of restructuring in messaging processor and responseHandler. Some cleanup.
Its quite hard to list every change, because its touching a lot of different places, but follows same general idea: make code more readable, more manageable.

@evlekht evlekht changed the title Evlekht/refactor Refactoring: cleanup, renaming and restructuring Nov 22, 2024
@evlekht evlekht marked this pull request as ready for review November 22, 2024 14:43
@havan
Copy link
Member

havan commented Nov 25, 2024

Tip

Adding AI generated summary and description of the changes to help with the review.

Message Processing Refactoring and Code Improvements

Overview

This PR introduces significant improvements to the messaging system implementation, focusing on better code organization, thread safety, and maintainability.

Key Changes

Message Processor

  • Renamed Processor interface to MessageProcessor for better clarity
  • Renamed implementation from processor to messageProcessor
  • Added CompressedContent field to Message type to better handle message content compression
  • Improved thread safety with RWMutex and encapsulated locking operations
  • Split message processing into more focused functions:
  • ProcessIncomingMessage (renamed from ProcessInbound)
  • SendRequestMessage (renamed from ProcessOutbound)

Response Handler

  • Refactored response handling logic into smaller, more maintainable functions
  • Split mint response handling into separate prepare/process stages
  • Added explicit error variable errMissingMintTxID
  • Improved error handling patterns throughout
  • Streamlined response processing flow

RPC Interface

  • Renamed ExternalRequestProcessor to RequestHandler for better clarity
  • Simplified interface methods
  • Updated all generated code to align with new interfaces

Matrix Messenger

  • Modified SendAsync signature to use pointer Message and remove separate content parameter
  • Added check to ignore own messages in matrix messenger
  • Improved message chunking and compression handling

Breaking Changes

  • SendAsync method signature changed from (msg types.Message, content [][]byte) to (msg *types.Message)
  • Interface renames may require updates to any external implementations
  • Response handler interface changes require implementation updates

Testing

All existing tests have been updated to accommodate these changes. Test coverage remains comprehensive.

Future Work

While this PR significantly improves the codebase, some potential future improvements could include:

  • Additional documentation for new patterns
  • More comprehensive integration tests
  • Performance benchmarking of new implementations

havan
havan previously approved these changes Nov 25, 2024
Copy link
Member

@havan havan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

internal/messaging/mint.go Outdated Show resolved Hide resolved
pkg/cm_accounts/cm_accounts.go Outdated Show resolved Hide resolved
pkg/cm_accounts/cm_accounts.go Show resolved Hide resolved
@evlekht evlekht merged commit c1d8e19 into dev Nov 28, 2024
3 checks passed
@evlekht evlekht deleted the evlekht/refactor branch November 28, 2024 13:19
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.

4 participants