Skip to main content

pyline core

Project description

PyLine Core

CI License: MIT Python 3.10+

A lightweight Python framework for implementing the Command Query Responsibility Segregation (CQRS) pattern with pipeline orchestration capabilities.

🚀 Key Features

  • CQRS Implementation: Strong separation between Commands (write) and Queries (read).
  • Mediator Pattern: Decouple components with a centralized handler registration.
  • Pipeline Orchestration: Execute sequences of steps with a shared context and automatic parameter mapping.
  • Type-Safe: Modern Python type hints with @overload support for superior developer experience.
  • Micro-Framework: Ultra-lightweight with zero external dependencies in core.

📦 Installation

pip install pyline-core

🚥 Quick Start

1. Define Components

from pyline import Command, Query, CommandHandler, QueryHandler
from dataclasses import dataclass

@dataclass
class CreateUserCommand(Command):
    name: str

class CreateUserCommandHandler(CommandHandler):
    async def handle(self, command: CreateUserCommand) -> None:
        print(f"Creating user: {command.name}")

@dataclass
class GetUserQuery(Query):
    name: str

class GetUserQueryHandler(QueryHandler):
    async def handle(self, query: GetUserQuery):
        return {"id": 1, "name": query.name}

2. Register and Execute

from pyline import mediator

# Registration
mediator.register_handler(CreateUserCommand, CreateUserCommandHandler())
mediator.register_handler(GetUserQuery, GetUserQueryHandler())

# Execution
async def main():
    await mediator.send(CreateUserCommand(name="Alp"))
    user = await mediator.send(GetUserQuery(name="Alp"))
    print(user)

🛠 Advanced: Pipeline Orchestration

Chain multiple commands and queries into a single workflow with shared context:

from pyline.pipe import Pipe

pipe = Pipe(
    name="Registration Flow",
    context={"name": "John Doe"},
    steps=[CreateUserCommand, GetUserQuery]
)

await pipe.run()

📖 Documentation

For detailed guides and full API reference, visit our documentation site (coming soon).

🤝 Contributing

Contributions are welcome! Please see CONTRIBUTING.md for local development setup and standards.

📄 License

MIT. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyline_core-2.2.1.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyline_core-2.2.1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file pyline_core-2.2.1.tar.gz.

File metadata

  • Download URL: pyline_core-2.2.1.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for pyline_core-2.2.1.tar.gz
Algorithm Hash digest
SHA256 0aa2368f3106a839555c76168af7e78a858881ed618ce69f2e7f1c0c52fdc91e
MD5 c0737dc55bc9d1d2b2a49df0eb735f37
BLAKE2b-256 37b09fc80fa19f0da6042a4aaeaf81d7481ae690c38acae7bf0d9814b20a6e44

See more details on using hashes here.

File details

Details for the file pyline_core-2.2.1-py3-none-any.whl.

File metadata

  • Download URL: pyline_core-2.2.1-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for pyline_core-2.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 afcd074abe6327f4d45ff5182b8092072705b2be22c178f33a86da3ad25cab76
MD5 7df68d049f3443f3b832deec380f45af
BLAKE2b-256 1e5d3ee1868a11ab2164e2958749e2a63601693b6f0350a91ba393725ac8edbb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page