Skip to content

Commit f8e2855

Browse files
committed
Disable SSL by default
The microgrid API does not use SSL by default, so it makes sense to disable it by default in the client. This was the behavior in previous versions and it was changed by mistake in a previous commit. Also prepare the release notes for the next patch release. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent c632970 commit f8e2855

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

RELEASE_NOTES.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
# Frequenz Microgrid API Client Release Notes
22

3-
## Summary
4-
5-
<!-- Here goes a general summary of what this release is about -->
6-
7-
## Upgrading
8-
9-
<!-- Here goes notes on how to upgrade from previous versions, including deprecations and what they should be replaced with -->
10-
11-
## New Features
12-
13-
<!-- Here goes the main new features and examples or instructions on how to use them -->
14-
153
## Bug Fixes
164

17-
<!-- Here goes notable bug fixes that are worth a special mention or explanation -->
5+
- Fix a bug where SSL was enabled by default. It is now disabled by default as in previous versions.

src/frequenz/client/microgrid/_client.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import asyncio
77
import logging
88
from collections.abc import AsyncIterator, Awaitable, Callable, Iterable, Set
9+
from dataclasses import replace
910
from typing import Any, TypeVar, cast
1011

1112
import grpc.aio
@@ -44,13 +45,24 @@
4445
_logger = logging.getLogger(__name__)
4546

4647

48+
DEFAULT_CHANNEL_OPTIONS = replace(
49+
channel.ChannelOptions(), ssl=channel.SslOptions(enabled=False)
50+
)
51+
"""The default channel options for the microgrid API client.
52+
53+
These are the same defaults as the common default options but with SSL disabled, as the
54+
microgrid API does not use SSL by default.
55+
"""
56+
57+
4758
class ApiClient:
4859
"""A microgrid API client."""
4960

5061
def __init__(
5162
self,
5263
server_url: str,
5364
*,
65+
channel_options: channel.ChannelOptions = DEFAULT_CHANNEL_OPTIONS,
5466
retry_strategy: retry.Strategy | None = None,
5567
) -> None:
5668
"""Initialize the class instance.
@@ -62,14 +74,18 @@ def __init__(
6274
where the `port` should be an int between 0 and 65535 (defaulting to
6375
9090) and `ssl` should be a boolean (defaulting to `false`).
6476
For example: `grpc://localhost:1090?ssl=true`.
77+
channel_options: The default options use to create the channel when not
78+
specified in the URL.
6579
retry_strategy: The retry strategy to use to reconnect when the connection
6680
to the streaming method is lost. By default a linear backoff strategy
6781
is used.
6882
"""
6983
self._server_url = server_url
7084
"""The location of the microgrid API server as a URL."""
7185

72-
self.api = microgrid_pb2_grpc.MicrogridStub(channel.parse_grpc_uri(server_url))
86+
self.api = microgrid_pb2_grpc.MicrogridStub(
87+
channel.parse_grpc_uri(server_url, defaults=channel_options)
88+
)
7389
"""The gRPC stub for the microgrid API."""
7490

7591
self._broadcasters: dict[int, streaming.GrpcStreamBroadcaster[Any, Any]] = {}

0 commit comments

Comments
 (0)