PeerNet.Discovery.Manual (PeerNet v0.1.0)

Copy Markdown View Source

No-op discovery implementation — exposes inject points so tests and manually-configured setups can drive discovery events at will.

Use this when:

  • You're testing the Registry's auto-connect logic without involving the network.
  • Your deployment uses a static peer list (config-driven, hand-typed, or distributed via your own mechanism — pre-shared mob.exs, etc.) and doesn't need automatic detection.
  • You need to drive a controlled scenario for debugging.

Production peer-to-peer use will typically swap this out for PeerNet.Discovery.MDNS (planned).

Driving discovery events

# Tell the registry a peer is now reachable:
PeerNet.Discovery.Manual.announce_peer(disc_pid, peer_pubkey,
  %{ip: {127, 0, 0, 1}, port: 7100, source: :manual})

# Tell the registry a peer disappeared:
PeerNet.Discovery.Manual.lose_peer(disc_pid, peer_pubkey)

Summary

Functions

Push a discovery event for pubkey at address to the Registry.

Returns a specification to start this module under a supervisor.

Push a peer-lost event for pubkey to the Registry.

Functions

announce_peer(server, pubkey, address)

@spec announce_peer(GenServer.server(), binary(), PeerNet.Discovery.address()) :: :ok

Push a discovery event for pubkey at address to the Registry.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

lose_peer(server, pubkey)

@spec lose_peer(GenServer.server(), binary()) :: :ok

Push a peer-lost event for pubkey to the Registry.