bidirectional
frequenz.channels.bidirectional
¤
An abstraction to provide bi-directional communication between actors.
Classes¤
frequenz.channels.bidirectional.Bidirectional
¤
Bases: Generic[T, U]
A wrapper class for simulating bidirectional channels.
Source code in frequenz/channels/bidirectional.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
Functions¤
__init__(client_id, service_id)
¤
Create a Bidirectional
instance.
PARAMETER | DESCRIPTION |
---|---|
client_id |
A name for the client, used to name the channels.
TYPE:
|
service_id |
A name for the service end of the channels.
TYPE:
|
Source code in frequenz/channels/bidirectional.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
client_handle()
property
¤
Get a BidirectionalHandle for the client to use.
RETURNS | DESCRIPTION |
---|---|
BidirectionalHandle[T, U]
|
Object to send/receive messages with. |
Source code in frequenz/channels/bidirectional.py
39 40 41 42 43 44 45 46 |
|
service_handle()
property
¤
Get a BidirectionalHandle
for the service to use.
RETURNS | DESCRIPTION |
---|---|
BidirectionalHandle[U, T]
|
Object to send/receive messages with. |
Source code in frequenz/channels/bidirectional.py
48 49 50 51 52 53 54 55 |
|
frequenz.channels.bidirectional.BidirectionalHandle
¤
A handle to a Bidirectional instance.
It can be used to send/receive values between the client and service.
Source code in frequenz/channels/bidirectional.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
|
Functions¤
__init__(sender, receiver)
¤
Create a BidirectionalHandle
instance.
PARAMETER | DESCRIPTION |
---|---|
sender |
A sender to send values with.
TYPE:
|
receiver |
A receiver to receive values from.
TYPE:
|
Source code in frequenz/channels/bidirectional.py
64 65 66 67 68 69 70 71 72 |
|
receive()
async
¤
Receive a value from the other side.
RETURNS | DESCRIPTION |
---|---|
Optional[U]
|
Received value, or |
Source code in frequenz/channels/bidirectional.py
85 86 87 88 89 90 91 |
|
send(msg)
async
¤
Send a value to the other side.
PARAMETER | DESCRIPTION |
---|---|
msg |
The value to send.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bool
|
Whether the send was successful or not. |
Source code in frequenz/channels/bidirectional.py
74 75 76 77 78 79 80 81 82 83 |
|