This version of the driver uses plain files to store the gitty data. It
consists of a nested directory structure with files named after the
hash. Objects and hash computation is the same as for git
. The heads
(files) are computed on startup by scanning all objects. There is a file
ref/head
that is updated if a head is updated. Other clients can watch
this file and update their notion of the head. This implies that the
store can handle multiple clients that can access a shared file system,
optionally shared using NFS from different machines.
The store is simple and robust. The main disadvantages are long startup times as the store holds more objects and relatively high disk usage due to rounding the small objects to disk allocation units.
swish
.@tdb Possibly we need to maintain a cached version of this index to avoid having to open all objects of the gitty store.
head(Store,File,Ext,Hash)
relation by reading all
objects and adding a fact for the most recent commit.-
.
This operation can fail because another writer has updated the head. This can both be in-process or another process.
We could improve on this two ways: (1) put the hash published in a short-lived key on Redis and make others check that. That is likely to avoid many nodes sending the same object or (2) see how many nodes are in the pool and switch to a consumer group based approach if this number is high (and thus we are unlikely to be asked ourselves for the missing hash).
discover
request for the hash. The replies are picked up by
gitty_message/1 above.
The code may be subject to various race conditions, but fortunately objects are immutable. It also seems possible that the Redis stream gets lost. Not sure when and how. For now, we restart if we get no reply, but nore more than once per minute.
This realized eager replication as opposed to the above code (redis_replicate_get/2) which performs lazy replication. Eager replication ensure the object is on multiple places in the event that the node on which it was saved dies shortly after.
Note that we also receive the object we just saved. That is unavoidable in a network where all nodes are equal.