Skip to content

v14.2.0

Compare
Choose a tag to compare
@gavin-norman-sociomantic gavin-norman-sociomantic released this 02 May 10:21
· 270 commits to v15.x.x since this release

https://github.com/sociomantic-tsunami/dhtproto/milestone/20?closed=1

Inherited changes from v13.4.0

Features

New handshake helper with built-in task support

dhtproto.client.legacy.internal.helper.Handshake

The new DhtHandshake class wraps the existing RetryHandshake with
easy support for a task-based workflow. This should make it easy for
applications to support a partial handshake, e.g.:

auto retry_delay_seconds = 3;
auto handshake = new DhtHandshake(dht_client, retry_delay_seconds);

// block on at least one node connecting
theScheduler.await(handshake.oneNodeConnected());
Stdout.formatln("At least one node is now connected!");

// wait until either all nodes have connected, or 60 seconds
// have passed, whichever comes sooner (N.B. `awaitOrTimeout`
// is only available for more recent ocean releases)
auto timeout_microsec = 60_000_000;

auto handshake_timed_out =   // true if timeout is reached
    theScheduler.awaitOrTimeout(
        handshake.allNodesConnected(),
        timeout_microsec);

if (handshake_timed_out)
{
    Stdout.formatln(
        "DHT handshake did not succeed within {} seconds!",
        timeout_microsec / 1_000_000);
}
else
{
    Stdout.formatln(
        "DHT handshake reached all nodes before timeout!");
}

// if we timed out, the `DhtHandshake` instance will still
// keep working in the background to connect to the missing
// DHT nodes, so all nodes should be reached eventually

RetryHandshake now has built-in logging

dhtproto.client.legacy.internal.helper.RetryHandshake

The helper logs the following events:

  • Each time it starts a handshake. (info)
  • When the handshake succeeds for a node. (info)
  • When the handshake succeeds for all nodes. (info)
  • When the handshake finished but did not succeed for all nodes and will be
    retried. (info)
  • Whenever the handshake notifier is called. (trace)

Applications that already use this helper may have implemented their own logging
behaviour in the handshake callbacks. It is recommended that this logging is
removed. You should be able to rely on the standard logging output of
RetryHandshake now.