gossip.core
create-node
(create-node ip port & {:keys [in-view partial-view heartbeat-counter forward-counters received-messages], :or {in-view [], partial-view [], heartbeat-counter 5, forward-counters {}, received-messages #{}}})
Create a node that will be part of the Gossip network.
forward
(forward socket subscriber-id node-id)
Send a ForwardSubscription message containing the subscriber-id to a node.
forward-prob-accept
(forward-prob-accept socket forwarded-to-ref subscriber-id)
Accept a ForwardSubscription request with probablity
(p = 1 / 1+ size of partial-view) or forward it to a
random node in the partial-view and update the
forward-counters map.
get-id
(get-id node)
Get the id of a node map e.g. {:ip "192.168.1.1" :port 1024}
as a string "ip:port".gossip
(gossip socket gossiper-ref message)
Send a message to all nodes in the partial-view.
handle-message
(handle-message socket receiving-node-ref pkt)
Handle received messages.
handle-receive-forward
(handle-receive-forward socket forwarded-to-ref subscriber-id)
Handle a ForwardSubscription request, if the request has been received more than
10 times, simply discard the thread.
handle-receive-gossip
(handle-receive-gossip socket receiving-node-ref message)
If the node has received the message before, don't do anything.
If it's the first time that the node has received the message,
add the message to `received-messages' and gossip it.
handle-receive-heartbeat
(handle-receive-heartbeat receiving-node-ref)
Update the heartbeat-counter.
handle-receive-initial
(handle-receive-initial socket receiving-node-ref subscriber-id)
Forward subscriber-id to all nodes in receiving-node's partial-view.
Forward `c' additional copies of subscriber-id
to random nodes in receiving-node's partial-view.
Add subscriber id to receiving-node's in-view.
handle-receive-remove
(handle-receive-remove receiving-node-ref to-remove-id)
handle-receive-replace
(handle-receive-replace receiving-node-ref original-id surrogate-id)
post-send-initial
(post-send-initial subscriber-ref contact-id)
Add contact-id to subscriber's partial-view.
schedule-heartbeat-dec
(schedule-heartbeat-dec socket node-ref interval)
Decrease the value of the heartbeat-counter after every "interval",
if the counter reaches zero, send an InitialSubscription request to
a random node from the partial-view.
schedule-heartbeat-send
(schedule-heartbeat-send socket sender-ref interval)
Send a heartbeat to all nodes in the partial-view after every "interval".
send-heartbeat
(send-heartbeat socket node-id)
send-initial
(send-initial socket subscriber-ref contact-id)
Send an initial subscription message to a contact node.
send-remove
(send-remove socket node-id)
send-replace
(send-replace socket node-id surrogate-id)
unsubscribe
(unsubscribe socket unsubscriber-ref)