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 data context to message trait #8

Open
Kilerd opened this issue Feb 22, 2023 · 0 comments
Open

add data context to message trait #8

Kilerd opened this issue Feb 22, 2023 · 0 comments
Labels
enhancement New feature or request gotcha

Comments

@Kilerd
Copy link
Owner

Kilerd commented Feb 22, 2023

add MessageContext, so the message handler can use the app data, like connecting to database, can send MQ message.etc.

struct HelloWorldMessage;

#[async_trait]
impl Message for HelloWorldMessage {
    type Output = String;
    async fn handle(self, messager: Arc<Messager>, context: MessageContext) -> Self::Output {
        let conn = context.get::<DatabasePool>();
        // do something
    }
}
@Kilerd Kilerd added enhancement New feature or request gotcha labels Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request gotcha
Projects
None yet
Development

No branches or pull requests

1 participant