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

Passing parameters to the async saga #1

Open
jairoguerra89 opened this issue May 22, 2021 · 0 comments
Open

Passing parameters to the async saga #1

jairoguerra89 opened this issue May 22, 2021 · 0 comments

Comments

@jairoguerra89
Copy link

jairoguerra89 commented May 22, 2021

Hey guys

This is probably a dumb question, I was wondering how can I pass a parameter or a dict or whatever to an AsyncSaga? check this out

`

class CreatePropertySaga(AsyncSaga):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.steps = [
            AsyncStep(
                name="create_property",
                action=self.create_property,
                base_task_name=create_property_message.TASK_NAME,
                queue=messaging.COMMANDS_QUEUE,
                on_success=self.create_property_on_success,
                on_failure=self.create_property_on_failure,
            ),
        ]
    
    def create_property(self, current_step: AsyncStep):
        self.send_message_to_other_service(
            current_step,
            asdict(
                create_property_message.Payload(
                    street_address=self.request_data["streetAddres"],
                    city=self.request_data["city"],
                    state=self.request_data["state"],
                    zip_code=self.request_data["zipCode"]
                )
            ),
        )

    def create_property_on_success(self, current_step: BaseStep, payload: dict):
        logger.info("Created the property successfully.")
        logger.info(f"Result = {payload}")

    def create_property_on_failure(self, current_step: BaseStep, payload: dict):
        logger.info("An error ocurred while trying to create the property.")
        logger.info(f"Result = {payload}")`
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

No branches or pull requests

1 participant