Skip to content

Commit

Permalink
FIX: Fix sending of heartbeat_interval_s
Browse files Browse the repository at this point in the history
  • Loading branch information
nmacholl committed Jun 6, 2024
1 parent d8df535 commit 9d97a0b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 0.35.1 - TBD

#### Bug fixes
- Fixed an issue where heartbeat_interval_s was not being sent to the gateway

## 0.35.0 - 2024-06-04

#### Enhancements
Expand Down
2 changes: 1 addition & 1 deletion databento/live/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def __init__(
ts_out: bool = False,
heartbeat_interval_s: int | None = None,
):
super().__init__(api_key, dataset, ts_out)
super().__init__(api_key, dataset, ts_out, heartbeat_interval_s)

self._dbn_queue = dbn_queue
self._loop = loop
Expand Down
33 changes: 33 additions & 0 deletions tests/test_live_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,39 @@ async def test_live_connect_auth(
assert message.encoding == Encoding.DBN


async def test_live_connect_auth_with_heartbeat_interval(
mock_live_server: MockLiveServerInterface,
test_live_api_key: str,
) -> None:
"""
Test that setting `heartbeat_interval_s` on a Live client sends that field
to the gateway.
"""
# Arrange
live_client = client.Live(
key=test_live_api_key,
gateway=mock_live_server.host,
port=mock_live_server.port,
heartbeat_interval_s=10,
)

live_client.subscribe(
dataset=Dataset.GLBX_MDP3,
schema=Schema.MBO,
)

# Act
message = await mock_live_server.wait_for_message_of_type(
message_type=gateway.AuthenticationRequest,
)

# Assert
assert message.auth.endswith(live_client.key[-BUCKET_ID_LENGTH:])
assert message.dataset == live_client.dataset
assert message.encoding == Encoding.DBN
assert message.heartbeat_interval_s == "10"


async def test_live_connect_auth_two_clients(
mock_live_server: MockLiveServerInterface,
test_live_api_key: str,
Expand Down

0 comments on commit 9d97a0b

Please sign in to comment.