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

Add empty param name support #10

Merged
merged 4 commits into from
Aug 23, 2023

Conversation

cofob
Copy link
Contributor

@cofob cofob commented Aug 19, 2023

Test code:

import asyncio

from taskiq import InMemoryBroker

from taskiq_pipelines import EMPTY_PARAM_NAME, Pipeline, PipelineMiddleware

broker = InMemoryBroker()
broker.add_middlewares(PipelineMiddleware())


@broker.task
async def add_one(value: int) -> int:
    return value + 1


@broker.task
async def do_nothing() -> None:
    print("I'm doing nothing.")


async def main() -> None:
    # Never forget to call startup in the beginning.
    await broker.startup()

    pipe = (
        Pipeline(broker, add_one).call_next(do_nothing, param_name=EMPTY_PARAM_NAME)
    )
    task = await pipe.kiq(2)

    await asyncio.sleep(2)


if __name__ == "__main__":
    asyncio.run(main())

@s3rius
Copy link
Member

s3rius commented Aug 20, 2023

@cofob, thanks you very much for contribution.

I have an Idea. I guess, it would be really nice to create a separate function that sets this parameter to EMPTY_PARAM_NAME and do not expose the constant to users. You may call it call_after and just remove param_name argument.

As I see it, it would be easier since you would not need to import anything and it would be easier to maintain backward compatibility.

async def main() -> None:
    # Never forget to call startup in the beginning.
    await broker.startup()

    pipe = Pipeline(broker, add_one).call_after(do_nothing)
    task = await pipe.kiq(2)

    await asyncio.sleep(2)

What do you think?

@cofob
Copy link
Contributor Author

cofob commented Aug 21, 2023

@s3rius added call_after. Please review.

@cofob cofob force-pushed the feature-empty-param branch from 6605d63 to ad62ed3 Compare August 23, 2023 11:59
@s3rius s3rius merged commit 367efa4 into taskiq-python:develop Aug 23, 2023
@cofob cofob deleted the feature-empty-param branch August 23, 2023 12:17
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.

2 participants