channel
frequenz.client.base.channel ¤
Handling of gRPC channels.
Classes¤
frequenz.client.base.channel.ChannelOptions
dataclass
¤
Options for a gRPC channel.
Source code in frequenz/client/base/channel.py
Attributes¤
keep_alive
class-attribute
instance-attribute
¤
keep_alive: KeepAliveOptions = KeepAliveOptions()
HTTP2 keep-alive options for the channel.
ssl
class-attribute
instance-attribute
¤
ssl: SslOptions = SslOptions()
SSL options for the channel.
frequenz.client.base.channel.KeepAliveOptions
dataclass
¤
Options for HTTP2 keep-alive pings.
Source code in frequenz/client/base/channel.py
frequenz.client.base.channel.SslOptions
dataclass
¤
SSL options for a gRPC channel.
Source code in frequenz/client/base/channel.py
Attributes¤
certificate_chain
class-attribute
instance-attribute
¤
The PEM-encoded certificate chain.
This can be a path to a file containing the chain, a byte string, or None if no chain should be used.
private_key
class-attribute
instance-attribute
¤
The PEM-encoded private key.
This can be a path to a file containing the key, a byte string, or None if no key should be used.
Functions¤
frequenz.client.base.channel.parse_grpc_uri ¤
parse_grpc_uri(
uri: str, /, defaults: ChannelOptions = ChannelOptions()
) -> Channel
Create a client channel from a URI.
The URI must have the following format:
A few things to consider about URI components:
- If any other components are present in the URI, a
ValueError
is raised. - If the port is omitted, the
default_port
is used unless it isNone
, in which case aValueError
is raised - If a query parameter is passed many times, the last value is used.
- Boolean query parameters can be specified with the following values
(case-insensitive):
true
,1
,on
,false
,0
,off
.
Supported query parameters:
ssl
(bool): Enable or disable SSL. Defaults todefault_ssl
.ssl_root_certificates_path
(str): Path to the root certificates file. Only valid if SSL is enabled. Will raise aValueError
if the file cannot be read.ssl_private_key_path
(str): Path to the private key file. Only valid if SSL is enabled. Will raise aValueError
if the file cannot be read.ssl_certificate_chain_path
(str): Path to the certificate chain file. Only valid if SSL is enabled. Will raise aValueError
if the file cannot be read.keep_alive
(bool): Enable or disable HTTP2 keep-alive. Defaults toTrue
.keep_alive_interval_s
(float): The interval between HTTP2 pings in seconds. Defaults to 60.keep_alive_timeout_s
(float): The time to wait for a HTTP2 keep-alive response in seconds
PARAMETER | DESCRIPTION |
---|---|
uri
|
The gRPC URI specifying the connection parameters.
TYPE:
|
defaults
|
The default options use to create the channel when not specified in the URI.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Channel
|
A client channel object. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the URI is invalid or contains unexpected components. |
Source code in frequenz/client/base/channel.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|