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

Adding combine algebra on the Decider, View and Saga #13

Merged
merged 5 commits into from
Dec 3, 2023

Conversation

idugalic
Copy link
Member

@idugalic idugalic commented Dec 3, 2023

Decider

/// Combine two deciders into one bigger decider
/// Creates a new instance of a Decider by combining two deciders of type `C1`, `S1`, `E1` and `C2`, `S2`, `E2` into a new decider of type `Sum<C, C2>`, `(S, S2)`, `Sum<E, E2>`
pub fn combine<'a, C1, S1: Clone, E1, C2, S2: Clone, E2>(
    decider1: Decider<'a, C1, S1, E1>,
    decider2: Decider<'a, C2, S2, E2>,
) -> Decider<'a, Sum<C1, C2>, (S1, S2), Sum<E1, E2>>

View

/// Combine two views into one.
/// Creates a new instance of a View by combining two views of type `S1`, `E1` and `S2`, `E2` into a new view of type `(S1, S2)`, `Sum<E1, E2>`
pub fn combine<'a, S1: Clone, E1, S2: Clone, E2>(
    view1: View<'a, S1, E1>,
    view2: View<'a, S2, E2>,
) -> View<'a, (S1, S2), Sum<E1, E2>>

Saga

/// Combine two sagas into one.
/// Creates a new instance of a Saga by combining two sagas of type `AR1`, `A1` and `AR2`, `A2` into a new saga of type `Sum<AR1, AR2>`, `Sum<A1, A2>`
pub fn combine<'a, AR1, A1, AR2, A2>(
    saga1: Saga<'a, AR1, A1>,
    saga2: Saga<'a, AR2, A2>,
) -> Saga<'a, Sum<AR1, AR2>, Sum<A1, A2>>

Combined decider/view/saga would allow you to create single aggregate/materialized view/saga manager to handle all the commands/events of your system. Could you check the tests?

@idugalic idugalic merged commit 4a1facb into main Dec 3, 2023
1 check passed
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.

1 participant