Commit Graph

23 Commits (0c9570889bd63fc345906ca15921aef7101c1634)

Author SHA1 Message Date
Dom Dwyer adad6bb631
refactor: must_use annotation for gossip::Builder
Not all use cases will involve sending messages (some will only want to
subscribe to messages) which might result in someone dropping the handle
they're not expecting to use.
2023-08-02 13:36:36 +02:00
Dom Dwyer 117d70d807
docs: GossipHandle::broadcast() blocking semantics
Document what happens when the gossip message queue is full.
2023-08-02 13:36:36 +02:00
Dom Dwyer 901839d66b
refactor: debug log for no-op payload dispatcher
Emit a debug log when the NopDispatcher receives a payload over gossip.
2023-07-31 11:01:29 +02:00
Dom Dwyer fc866ebe92
feat(gossip): peer exchange
This commit implements peer exchange (abbreviated PEX) between peers
of the gossip cluster.

This allows using a set of fixed seeds and dynamic node membership -
nodes can come and go without having to be manually configured across
all peers in order to communicate.

"Dead" peers are periodically cleaned from the local list of active
peers, ensuring the list of peers doesn't grow forever as node churn
occurs. This is a best-effort, conservative process, biasing towards
reliability/deliverability rather than accuracy and fast removal - it's
not a health check!
2023-07-25 15:14:19 +02:00
dependabot[bot] faa8d44492
chore(deps): Bump thiserror from 1.0.43 to 1.0.44 (#8315)
Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.43 to 1.0.44.
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.43...1.0.44)

---
updated-dependencies:
- dependency-name: thiserror
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-07-24 10:18:44 +00:00
dependabot[bot] cd31492e5b
chore(deps): Bump async-trait from 0.1.71 to 0.1.72 (#8317)
Bumps [async-trait](https://github.com/dtolnay/async-trait) from 0.1.71 to 0.1.72.
- [Release notes](https://github.com/dtolnay/async-trait/releases)
- [Commits](https://github.com/dtolnay/async-trait/compare/0.1.71...0.1.72)

---
updated-dependencies:
- dependency-name: async-trait
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-07-24 10:07:18 +00:00
dependabot[bot] 4c4c9f731c
chore(deps): Bump uuid from 1.4.0 to 1.4.1 (#8256)
Bumps [uuid](https://github.com/uuid-rs/uuid) from 1.4.0 to 1.4.1.
- [Release notes](https://github.com/uuid-rs/uuid/releases)
- [Commits](https://github.com/uuid-rs/uuid/compare/1.4.0...1.4.1)

---
updated-dependencies:
- dependency-name: uuid
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-07-18 12:30:42 +00:00
Dom Dwyer c2273e6488
docs: remove outdated comment 2023-07-10 14:27:08 +02:00
Dom Dwyer 701da1363c
refactor: remove panic on impossible error
Remove the logical complexity of error handling for an error that cannot
occur.

This was an artifact of pre-PR refactoring - the error being returned
SHOULD never be reached, as the only error returned is the "your message
is too big" error, and that's not possible because the message size is
validated in the GossipHandle::broadcast() method before it reaches the
reactor.
2023-07-10 14:10:03 +02:00
Dom Dwyer a686580ffa
test: multiple messages in single test
This ensures various reused scratch buffers are wiped between uses.
2023-07-10 14:03:57 +02:00
Dom Dwyer 71625043e2
test: remove dbg!() 2023-07-10 14:02:57 +02:00
Dom Dwyer 060f1b2ed6
docs: unwrap correctness docs
Describe the possible reasons a socket recvfrom() would cause a panic.
2023-07-10 14:01:11 +02:00
Dom Dwyer 991692d2fb
refactor: short/long panic message 2023-07-10 13:51:40 +02:00
Dom Dwyer bee1b45c13
build: reuse path var
DRY the path var.
2023-07-10 13:48:01 +02:00
Dom Dwyer 118aefe2d2
chore: use workspace crate config
Inherit version/authors/edition from the workspace.
2023-07-10 13:39:52 +02:00
Dom Dwyer 7880f9287f
chore: add license 2023-07-10 12:11:16 +02:00
Dom Dwyer 58c4874880
chore: workspace_hack support
Add workspace_hack and whitelist the import.
2023-07-10 12:11:15 +02:00
Dom Dwyer 48466bfa89
feat(metrics): bytes/frames sent/received & peers
Emit metrics tracking the number of bytes sent / received, and number of
frames sent / received by the local node.

Track the number of discovered peers to record peer discovery rate and
current number of known peers per node.
2023-07-10 12:11:15 +02:00
Dom Dwyer 93789d7abb
feat: refuse oversized gossip payloads
Calculate the available byte size for a user payload sent via gossip,
and pro-actively check this limit earlier, when the caller is attempting
to send the frame, rather than later in the reactor where there's no
feedback to the caller.

DRY frame serialisation to simplify enforcement, and validate/refuse
oversized frames in the reactor so that frames are unlikely to be
truncated by receivers.
2023-07-10 12:11:14 +02:00
Dom Dwyer bc9ebc9c66
feat: gossip primitive
Adds a simple "gossip" implementation (more accurately described as a
pub/sub primitive currently) that supports broadcasting
application-level messages to the set of active peers.

This implementation uses UDP as a transport for best-effort delivery,
and enables zero-copy use of the payload using the Bytes crate.

Only peers explicitly provided as "seeds" when initialising will be
known to a gossip node - there's currently no peer exchange mechanism.
This implementation tolerates seeds changing their DNS entries when
restarting to point at new socket addresses (such as within Kubernetes
when pods move around).
2023-07-10 12:11:14 +02:00
Dom Dwyer 48aa4a5e33
feat(gossip): frame proto definitions
Adds a proto definition and configures prost to build the rust types
from it.

The gossip framing is intended to be flexible and decoupled - the gossip
library will batch together one or more opaque application messages
and/or control frames, and uniquely identify each peer with a
per-instance UUID to detect crashes/restarts and track peers.
2023-07-10 12:11:13 +02:00
Dom Dwyer 5c191ce6cf
ci: enable standard lint set
Adds the somewhat "standard" lint set we use to the gossip lib.
2023-07-10 12:11:12 +02:00
Dom Dwyer 69ab70ce99
feat: init gossip package
Adds a new empty "gossip" package to the workspace.
2023-07-10 12:11:12 +02:00