Skip to content

Commit a2b4462

Browse files
committed
Add the user guide structure
These are mainly pages including docstrings from the source code. There are only a few pages with content of their own, and they are usually just glue to put some related docstrings together. There is one notable exception, the general channel concepts, that don't have a better home. The content of the docstring will be improved later to make the user guide more cohesive. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 2907ef5 commit a2b4462

File tree

13 files changed

+278
-0
lines changed

13 files changed

+278
-0
lines changed

docs/user-guide/SUMMARY.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
* [Quick Start](quick-start.md)
22
* [Installation](installation.md)
3+
* [Channels](channels/)
4+
* [Sending](sending.md)
5+
* [Receiving](receiving/)
6+
* [Error Handling](error-handling.md)
7+
* [Utilities](utilities/)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Anycast
2+
3+
::: frequenz.channels._anycast.Anycast
4+
options:
5+
inherited_members: []
6+
members: []
7+
show_bases: false
8+
show_root_heading: false
9+
show_root_toc_entry: false
10+
show_source: false
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Broadcast
2+
3+
::: frequenz.channels._broadcast.Broadcast
4+
options:
5+
inherited_members: []
6+
members: []
7+
show_bases: false
8+
show_root_heading: false
9+
show_root_toc_entry: false
10+
show_source: false

docs/user-guide/channels/index.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Channels
2+
3+
A channel is a communication mechanism that allows data (messages) to be
4+
transmitted between different coroutines. It consists of
5+
[senders](../sending.md), which send messages, and
6+
[receivers](../receiving/index.md), which receive those messages. The channel itself
7+
acts as a conduit for these messages.
8+
9+
Conceptually, a channel looks like this:
10+
11+
<center>
12+
```bob
13+
.---------. Message .----------. Message .-----------.
14+
| Sender +------------>| Channel +------------>| Receiver |
15+
'---------' '----------' '-----------'
16+
```
17+
</center>
18+
19+
Besides this simple model, there are many variations of channels depending on
20+
various factors:
21+
22+
* How many senders and receivers can a channel have?
23+
24+
* Do all receivers receive all messages from all senders?
25+
26+
* How many messages can a channel hold (buffered), or can it hold any messages
27+
at all (unbuffered)?
28+
29+
* What happens if a sender tries to send a message to a full channel?
30+
31+
* Does the send operation block until the channel has space again?
32+
* Does it fail?
33+
* Does it silently drop the message?
34+
35+
Because these questions can have many answers, there are different types of
36+
channels. Frequenz Channels offers a few of them:
37+
38+
* [Anycast](anycast.md)
39+
* [Broadcast](broadcast.md)
40+
41+
More might be added in the future, and you can also create your own.

docs/user-guide/error-handling.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Error Handling
2+
3+
::: frequenz.channels._exceptions
4+
options:
5+
inherited_members: []
6+
members: []
7+
show_bases: false
8+
show_root_heading: false
9+
show_root_toc_entry: false
10+
show_source: false

docs/user-guide/receiving/index.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Receiving
2+
3+
::: frequenz.channels._receiver
4+
options:
5+
inherited_members: []
6+
members: []
7+
show_bases: false
8+
show_root_heading: false
9+
show_root_toc_entry: false
10+
show_source: false
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Multiple Sources
2+
3+
If you need to receive values from multiple sources it can be complicated, as
4+
you probably want to get the first message of each receiver as soon as it is
5+
available. A naive approach like this will not work:
6+
7+
```python
8+
receiver1: Receiver[int] = channel1.new_receiver()
9+
receiver2: Receiver[int] = channel2.new_receiver()
10+
11+
msg = await receiver1.receive()
12+
print(f"Received from channel1: {msg}")
13+
14+
msg = await receiver2.receive()
15+
print(f"Received from channel2: {msg}")
16+
```
17+
18+
The problem is that if the first message is not available in `channel1` but in
19+
`channel2`, the program will be blocked until a message is available in
20+
`channel1`, but you probably want to receive the first message from `channel2`
21+
as soon as it is available.
22+
23+
Frequenz Channels provides two tools to solve this issue:
24+
[`merge()`][frequenz.channels.merge] and
25+
[`select()`][frequenz.channels.select].
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Merging
2+
3+
::: frequenz.channels._merge
4+
options:
5+
inherited_members: []
6+
members: []
7+
show_bases: false
8+
show_root_heading: false
9+
show_root_toc_entry: false
10+
show_source: false
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Selecting
2+
3+
::: frequenz.channels._select
4+
options:
5+
inherited_members: []
6+
members: []
7+
show_bases: false
8+
show_root_heading: false
9+
show_root_toc_entry: false
10+
show_source: false
11+

docs/user-guide/sending.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Sending
2+
3+
::: frequenz.channels._sender
4+
options:
5+
inherited_members: []
6+
members: []
7+
show_bases: false
8+
show_root_heading: false
9+
show_root_toc_entry: false
10+
show_source: false

0 commit comments

Comments
 (0)