class

Swim::Core

Inherits Reference < Object

In-memory SWIM engine. Pass now from the caller so tests control time. The hot path writes packets into one buffer and does not allocate.

Constants

GC_EVERY = 60
HELPERS = 3
MAX_HEALTH = 5
PROBE_SLOTS = 64

Constructors

new(local : Endpoint, *, incarnation : UInt64 = 1_u64, now : Time::Instant = Time.instant, timeout : Time::Span = 500.milliseconds, tombstone : Time::Span = 24.hours, random : Random = Random.new)
Source

Instance methods

add(endpoint : Endpoint, incarnation : UInt64, status : Status, now : Time::Instant) : Nil

Adds a peer, or ignores the update when the current row wins.

Source
alive?(endpoint : Endpoint) : Bool
Source
each
Source
each_deadline
Source
expire(now : Time::Instant, & : Endpoint, Bytes -> ) : Nil

Fires due probes. A direct timeout yields ping-req packets.

Source
get(endpoint : Endpoint) : Peer | Nil
Source
health
Source
incarnation
Source
pending
Source
receive(bytes : Bytes, now : Time::Instant, & : Endpoint, Bytes -> ) : Bool

Applies one datagram. Yields at most one reply. Returns false for a bad packet.

Source
size
Source
tick(now : Time::Instant, & : Endpoint, Bytes -> ) : Nil

One probe period. Yields one ping when another peer can be probed.

Source
timeout_span
Source

Nested types