Callbags has three major layers.
Producer Layer Sources:
This layer is responsible for sending data.
Operator Layer Operators:
This layer is responsible for receiving data and do some operation, then sending data. So this layer is considered as producer layer too. The only difference is that it cannot send data without receiving them first.
Consumer Layer Sinkers:
This layer is responsible for receiving data.
Visually represented as:
required optional required
╭──────────────╮ ╭────────────╮ ╭────────────╮
│ │<──│ │<──│ │
│ Producer │ │ Operator │ │ Consumer │
│ │──>│ │──>│ │
╰──────────────╯ ╰────────────╯ ╰────────────╯
Note: each Callbags Layer has its own Architecture Design. However they share the following concept:
- Subscribe Stage:
╭────────────────────────╮ │ ╭────────────────────╮ │ <─┼─│ request Start │<┼── Handshake (required) │ ╰────────────────────╯ │ │ Only once │ │ ╭────────────────────╮ │ ──┼>│ receive Start ├─┼─> HandshakeBack (required) │ ╰────────────────────╯ │ ╰────────────────────────╯
- Request/Receive Items Stage:
╭────────────────────────╮ │ ╭────────────────────╮ │ <─┼─│ request Next │<┼── WantItem (required for pullables) │ ╰────────────────────╯ │ │ As many as possible │ │ ╭────────────────────╮ │ ──┼>│ receive Next ├─┼─> TakeItem (optional) │ ╰────────────────────╯ │ ╰────────────────────────╯
- Unsubscribe Stage:
╭────────────────────────╮ │ ╭────────────────────╮ │ <─┼─│ request Completion │<┼── Bye (optional) │ ╰────────────────────╯ │ │ Only once │ │ ╭────────────────────╮ │ ──┼>│ receive Completion ├─┼─> Bye/ByeBack (required) │ ╰────────────────────╯ │ ╰────────────────────────╯