graft.log module

exception graft.log.AppendError[source]

Bases: ValueError

Raised by append() when an invalid graft.model.Index is passed

graft.log.append(log, after, *entries)[source]

Append entries to log after the given index.

Parameters
  • log (Map) – Log object to append entries to.

  • after (Index) – Log index after which entries will be appended.

Raises

AppendError

If the operation is unsuccessful, which can happen if after index does not exist in the given log. Unless index.key is 0 (the origin). For example:

>>> index = model.Index(key=2, term=4)
>>> assert log[2].term == index.term  # index and term match existing entry
>>> index = model.Index(key=0, term=4)  # will work since index it's origin

Return type

Map

graft.log.new()[source]

Create a new, empty log.

Return type

Map