lib/kwery/replication/raft.rb
# TODO: optimize for append only log writing
#       maybe keep two separate files and update the state (non-log)
#       one only when values change which should be infrequent enough
#       if we have a stable leader.
optimize for append only log writing
maybe keep two separate files and update the state (non-log)
one only when values change which should be infrequent enough
if we have a stable leader.
optimize for append only log writing maybe keep two separate files and update the state ( non - log ) one only when values change which should be infrequent enough if we have a stable leader .
def flush
          sent_hash = HashMarshalling.object_to_hash(@node.persistent_state, %w(current_term voted_for))
          sent_hash['log'] = @node.persistent_state.log.map { |entry|
            HashMarshalling.object_to_hash(entry, %w(term index command))
          }
          sent_json = JSON.dump(sent_hash)
          File.write(@filename, sent_json)
        end
def flush sent_hash = HashMarshalling . object_to_hash ( @node . persistent_state , %w( current_term voted_for ) ) sent_hash [ 'log' ] = @node . persistent_state . log . map { | entry | HashMarshalling . object_to_hash ( entry , %w( term index command ) ) } sent_json = JSON . dump ( sent_hash ) File . write ( @filename , sent_json ) end
TODO: optimize for append only log writing
maybe keep two separate files and update the state (non-log)
one only when values change which should be infrequent enough
if we have a stable leader.
TODO : optimize for append only log writing maybe keep two separate files and update the state ( non - log ) one only when values change which should be infrequent enough if we have a stable leader .