Why bazario?

Bazario addresses several limitations found in alternative libraries:

  1. Lack of support for both synchronous and asynchronous handlers: Most libraries require choosing between synchronous or asynchronous processing, limiting flexibility.
    Bazario addresses this issue by supporting both synchronous and asynchronous handling through the bazario.asyncio package for async operations. This allows the library to be used in various types of applications without limiting the developer’s choice of processing type.

  2. Control over IoC container and scope creation: This is often handled by the library itself, leading to bugs and side effects. It can also reduce performance, as multiple parallel containers could be created.
    Bazario allows the client to control the IoC container and scope creation, giving full control over the container’s lifecycle and preventing performance issues or side effects caused by redundant container instances.

  3. Lack of modularity: In other libraries, integrating different DI frameworks is challenging without rewriting significant portions of the logic.
    Bazario solves this problem by utilizing a modular resolvers system, allowing easy integration with any DI framework. This provides the ability to use Bazario in different environments without being tied to a specific DI framework.

  4. Violation of SOLID principles: Some libraries do not fully adhere to SOLID principles, making the code more complex and harder to maintain.
    Bazario fully adheres to SOLID principles, particularly ISP (Interface Segregation Principle). For example, instead of tightly coupling everything to a Dispatcher, Bazario separates responsibilities by introducing the Publisher protocol for event publication and the Sender protocol for sending requests, leading to better responsibility separation and reduced unnecessary dependencies.

  5. Dependency Separation: In traditional approaches, controllers often handle both request parsing and handler resolution, which increases their complexity and reduces testability.
    Bazario addresses this by delegating all handler routing responsibilities to Bazario, allowing controllers to focus solely on parsing requests. This improves responsibility separation and makes controller code cleaner and more testable.

  6. Powerful Pipeline System: Many libraries lack an effective way to implement cross-cutting concerns like logging, validation, or error handling, often forcing developers to modify the core logic of their handlers. Bazario addresses this by offering a sophisticated behavior pipeline system that allows developers to:

    • Implement cross-cutting concerns without modifying existing handler logic.
    • Create reusable middleware components that can be plugged into various parts of the system.
    • Configure different processing chains for various types of requests and notifications, ensuring flexibility.
    • Add centralized monitoring, logging, and error handling, ensuring consistency across the application without cluttering the core logic.

    This powerful pipeline system allows developers to manage complex workflows efficiently and with minimal code duplication.

  7. Flexible Processing Control: In many libraries, developers face challenges when trying to introduce new processing requirements, especially when they require changing existing handler logic. This can lead to code bloat and reduced maintainability. Bazario offers flexible control over how requests and notifications are processed through:

    • Custom pipeline behaviors that can be configured for specific types of requests or notifications, giving developers granular control.
    • Global behaviors that apply to all requests or notifications, making it easier to manage common concerns like logging or security.
    • Configurable execution order of pipeline behaviors, allowing developers to define precisely when and how each behavior should execute.
    • Easy integration of new processing requirements without altering existing handler logic, ensuring backward compatibility and scalability.

    This level of flexibility ensures that Bazario can adapt to evolving requirements without compromising the maintainability of the codebase.