ezmobius / nanite

self assembling fabric of ruby daemons
Apache License 2.0
735 stars 64 forks source link

load average / status function not updated with heartbeat messages when using Redis #6

Open joshwilsdon opened 15 years ago

joshwilsdon commented 15 years ago

When using redis the nanite- key gets set with the load_average when the node registers but it is not updated after that by heartbeat messages. It seems that the intention is that the heartbeat/ping sends the load average so that the load average will be put in Redis. This is not happening because the code in cluster.rb (handle_ping) is doing:

if nanite = nanites[ping.identity]
    nanite[:status] = ping.status

but nanites[ping.identity] returns an anonymous Hash, so updating it here does nothing. As such this value is never sent to Redis. I have confirmed that hacking in a update_status function to the Nanite::State class (which just updates the nanite- key in redis) and then calling it in the handle_ping as:

nanites.update_status(ping.identity, ping.status)

causes the value in Redis to be updated at every heartbeat. Was it the intended behavior for this function (handle_ping) to update Redis? The comment seems to indicate that is the case.

roidrage commented 15 years ago

I can confirm this issue, and I've taken your idea to update the Redis store accordingly.