rmediator


Namermediator JSON
Version 0.2.1 PyPI version JSON
download
home_pagehttps://github.com/ffekirnew/rmediator
SummaryRequest Mediator PyPI (Python Package Index) Package
upload_time2024-06-06 15:18:29
maintainerNone
docs_urlNone
authorFikernew Birhanu
requires_python>=3.6
licenseNone
keywords rmediator pypi package
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # RmediatoR

<div style="text-align: left; padding: 1rem 0;">
<img src="./docs/assets/images/logo-dark.png" width="500" aspect-ration="1/1" style="padding: 0.8rem 0;">
<p align="left">
  <a href="#introduction">Introduction</a> •
  <a href="#demonstration">Demonstration</a> •
  <a href="#how-to-use">How to Use</a> •
  <a href="#how-to-use">Contributing</a> •
  <a href="#how-to-use">License</a>
</p>
</div>

## [Introduction](#introduction)

RmediatoR is a Python package inspired by the MediatR library available on NuGet. It allows developers to implement the mediator design pattern in their applications, promoting a clean separation of concerns by centralizing request/response logic and eliminating direct dependencies between components. This package simplifies the communication between different parts of your application, making your code more maintainable and scalable.

## [Demonstration](#demonstration)

Here's a quick example to demonstrate how RmediatoR works:

1. Define a Request and Handler: Create a request class and a handler class that processes the request.
```py
from rmediator.decorators import request, request_handler

# Define a response
class SomeResponse:
    def __init__(self, message):
        self.message = message

# Define a request
@request(SomeResponse)
class SomeRequest:
    pass

# Define a handler for the request
@request_handler(SomeRequest, SomeResponse)
class SomeRequestHandler:
    def handle(self, request: SomeRequest) -> SomeResponse:
        return SomeResponse("Handled!")
```
2. Initialize the mediator and register the handlers
```py
from rmediator import Mediator

mediator = Mediator()

mediator.register_handler(SomeRequest, SomeRequestHandler())
```
3. Send a Request: Use the mediator to send a request and get a response.
```py
# Create a request instance
request = SomeRequest()

# Send the request through the mediator
response = mediator.send(request)

# Output the response
print(response.message)  # Output: Handled!
```
## [How to Use](#how-to-use)

To start using RmediatoR, follow these steps:
1. Installation: First, install the package using pip (or use other options like poetry).
```bash
pip install rmediator
```
2. Creating Requests and Handlers: Define your request and handler classes as shown in the demonstration above. Each request should inherit from the Request class, and each handler should inherit from the Handler class.

3. Registering Handlers: Register your handlers with the mediator. This tells the mediator which handler to use for each request type.

```py
mediator.register_handler(YourRequestClass, YourHandlerClass)
```
4. Sending Requests: Use the mediator to send requests. The mediator will find the appropriate handler and return the response.

```py
response = mediator.send(your_request_instance)
```

## [License](#license)
RmediatoR is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.

## [Contributing](#contributing)
Contributions are welcome! Please read the [CONTRIBUTING](CONTRIBUTING.md) guidelines for more information on how to get started.

## [Contact](#contact)
For questions or issues, please open an issue on GitHub or contact me on my channels.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ffekirnew/rmediator",
    "name": "rmediator",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "rmediator, pypi, package",
    "author": "Fikernew Birhanu",
    "author_email": "fikernew.birhanu.waju@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/f0/96/846e1b459a6af734cc9e12c4a63a73be4a53a9545de601e8d663b3a067a8/rmediator-0.2.1.tar.gz",
    "platform": null,
    "description": "# RmediatoR\n\n<div style=\"text-align: left; padding: 1rem 0;\">\n<img src=\"./docs/assets/images/logo-dark.png\" width=\"500\" aspect-ration=\"1/1\" style=\"padding: 0.8rem 0;\">\n<p align=\"left\">\n  <a href=\"#introduction\">Introduction</a> \u2022\n  <a href=\"#demonstration\">Demonstration</a> \u2022\n  <a href=\"#how-to-use\">How to Use</a> \u2022\n  <a href=\"#how-to-use\">Contributing</a> \u2022\n  <a href=\"#how-to-use\">License</a>\n</p>\n</div>\n\n## [Introduction](#introduction)\n\nRmediatoR is a Python package inspired by the MediatR library available on NuGet. It allows developers to implement the mediator design pattern in their applications, promoting a clean separation of concerns by centralizing request/response logic and eliminating direct dependencies between components. This package simplifies the communication between different parts of your application, making your code more maintainable and scalable.\n\n## [Demonstration](#demonstration)\n\nHere's a quick example to demonstrate how RmediatoR works:\n\n1. Define a Request and Handler: Create a request class and a handler class that processes the request.\n```py\nfrom rmediator.decorators import request, request_handler\n\n# Define a response\nclass SomeResponse:\n    def __init__(self, message):\n        self.message = message\n\n# Define a request\n@request(SomeResponse)\nclass SomeRequest:\n    pass\n\n# Define a handler for the request\n@request_handler(SomeRequest, SomeResponse)\nclass SomeRequestHandler:\n    def handle(self, request: SomeRequest) -> SomeResponse:\n        return SomeResponse(\"Handled!\")\n```\n2. Initialize the mediator and register the handlers\n```py\nfrom rmediator import Mediator\n\nmediator = Mediator()\n\nmediator.register_handler(SomeRequest, SomeRequestHandler())\n```\n3. Send a Request: Use the mediator to send a request and get a response.\n```py\n# Create a request instance\nrequest = SomeRequest()\n\n# Send the request through the mediator\nresponse = mediator.send(request)\n\n# Output the response\nprint(response.message)  # Output: Handled!\n```\n## [How to Use](#how-to-use)\n\nTo start using RmediatoR, follow these steps:\n1. Installation: First, install the package using pip (or use other options like poetry).\n```bash\npip install rmediator\n```\n2. Creating Requests and Handlers: Define your request and handler classes as shown in the demonstration above. Each request should inherit from the Request class, and each handler should inherit from the Handler class.\n\n3. Registering Handlers: Register your handlers with the mediator. This tells the mediator which handler to use for each request type.\n\n```py\nmediator.register_handler(YourRequestClass, YourHandlerClass)\n```\n4. Sending Requests: Use the mediator to send requests. The mediator will find the appropriate handler and return the response.\n\n```py\nresponse = mediator.send(your_request_instance)\n```\n\n## [License](#license)\nRmediatoR is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.\n\n## [Contributing](#contributing)\nContributions are welcome! Please read the [CONTRIBUTING](CONTRIBUTING.md) guidelines for more information on how to get started.\n\n## [Contact](#contact)\nFor questions or issues, please open an issue on GitHub or contact me on my channels.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Request Mediator PyPI (Python Package Index) Package",
    "version": "0.2.1",
    "project_urls": {
        "Bug Reports": "https://github.com/ffekirnew/rmediator/issues",
        "Documentation": "https://github.com/ffekirnew/rmediator",
        "Homepage": "https://github.com/ffekirnew/rmediator",
        "Source Code": "https://github.com/ffekirnew/rmediator"
    },
    "split_keywords": [
        "rmediator",
        " pypi",
        " package"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2e9762a6f67830b51ce6771a25a9aed68a9051d78e69ecabbfba3540631b45de",
                "md5": "651650011eb96f32815a750c86c110b5",
                "sha256": "c59fd1092b2eae6e5b01710b766d4f21976cc4b52d368db080287057edcf1aa5"
            },
            "downloads": -1,
            "filename": "rmediator-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "651650011eb96f32815a750c86c110b5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 8450,
            "upload_time": "2024-06-06T15:18:27",
            "upload_time_iso_8601": "2024-06-06T15:18:27.185100Z",
            "url": "https://files.pythonhosted.org/packages/2e/97/62a6f67830b51ce6771a25a9aed68a9051d78e69ecabbfba3540631b45de/rmediator-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f096846e1b459a6af734cc9e12c4a63a73be4a53a9545de601e8d663b3a067a8",
                "md5": "ac7d42500d5c792a5bb6844ae69a5fff",
                "sha256": "01ae2b1be54bd5cbf9e2245264a4657e0c665d81a718e219af404daadba4f8dc"
            },
            "downloads": -1,
            "filename": "rmediator-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "ac7d42500d5c792a5bb6844ae69a5fff",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 107726,
            "upload_time": "2024-06-06T15:18:29",
            "upload_time_iso_8601": "2024-06-06T15:18:29.047227Z",
            "url": "https://files.pythonhosted.org/packages/f0/96/846e1b459a6af734cc9e12c4a63a73be4a53a9545de601e8d663b3a067a8/rmediator-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-06 15:18:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ffekirnew",
    "github_project": "rmediator",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "rmediator"
}
        
Elapsed time: 0.41648s