Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement support for heartbeats #84

Merged
merged 3 commits into from
Nov 3, 2022
Merged

Conversation

achilleasa
Copy link
Owner

@achilleasa achilleasa commented Nov 3, 2022

To enable heartbeats, the client must create a new TuningSettings object
with a >= 1sec Duration value for the heartbeatPeriod field. The
TuningSettings must then be passed to the client's constructor via the
ConnectionSettings object.

During the initial connection handshake, the client will calculate the
effective heartbeat period (in seconds) by taking the minimum of the
heartbeat period values suggested by the client and the server.

Once a heartbeat interval has been negotiated between the client and the
server, the client will start sending heartbeat messages to the server
(approximately) twice within each heartbeat period. In addition, the
client also monitors incoming messages from the server. If no message
(heartbeat or not) has been received by the server within the heartbeat
period, the client will raise a HeartbeatFailedException.

The following example illustrates how heartbeats can be enabled when creating a new client:

Client client = Client(
  settings: ConnectionSettings(
    tuningSettings: TuningSettings(
      heartbeatPeriod: const Duration(seconds: 60),
    ),
  ),
);

Fixes #71
Fixes #21

This change will make it easier to write tests for the heartbeat
feature.
To enable heartbeats, the client must create a new TuningSettings object
with a >= 1sec Duration value for the `heartbeatPeriod` field. The
TuningSettings must then be passed to the client's constructor via the
ConnectionSettings object.

During the initial connection handshake, the client will calculate the
effective heartbeat period (in seconds) by taking the minimum of the
heartbeat period values suggested by the client and the server.

Once a heartbeat interval has been negotiated between the client and the
server, the client will start sending heartbeat messages to the server
(approximately) twice within each heartbeat period. In addition, the
client also monitors incoming messages from the server. If no message
(heartbeat or not) has been received by the server within the heartbeat
period, the client will raise a HeartbeatFailedException.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.5%) to 93.552% when pulling cf0a8c8 on implement-heartbeats into 40f3fc1 on master.

@achilleasa achilleasa merged commit 68eb94d into master Nov 3, 2022
@achilleasa achilleasa deleted the implement-heartbeats branch November 3, 2022 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Any plans to implement heartbeats? heartbeat support
2 participants