Skip to content

Idea to improve code quality: implement a clean architecture #2

@Celeborn2BeAlive

Description

@Celeborn2BeAlive

This package could be implemented as a clean architecture, providing benefits to testing, maintenance, separation of concerns and re-usability

The main domain use case is: Decode events from an input EVM log stream according to user specified rules (which events & inputs should be retrieved, how to output them through dynamic projection)

This use case is implemented by the service fetch_decode which is the main entry point, with utilities provided to build and inject the rules.

In current state, several infrastructure components are directly instantiated during the executing. A possible improvement would be the dependency injection of these components to the domain use case.

In a clean architecture, the domain part would only take care of the orchestration & decoding logic, take all input data from abstract data providers (interfaces: IEvmLogsProvider, IEventRegistryProvider, ...), and output data to abstract output repositories (interfaces: IManifestRepository, IEventShardsRepository, ...)

The providers and repositories interfaces would be implemented by concrete classes that already exist (RPC, ShardsWriter, LiveManifest) that would be injected to domain services.

The benefits of such architecture would be:

  • Integration testing of domain services by injection of test implementations of providers & repositories
  • Facilitate integration of new providers & repositories implementations to change the behavior without changing the implementation of domain services (for example: output Events in a DB instead of parquets, read ABI from etherscan instead of file, write manifest to remote logging service instead of files, etc.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions