At $WORK, we implement our own Store interface for reading existing db entities into a graph. This store only implements Read related interface functions of the Store interface and works nicely.
We now would like to implement a partial Store with only Write related Store interface and reuse existing implementation from the existing default memoryStore. For example, I would like to be able to write:
Note that generics were omitted in the following to lighten the code.
// myGraphWriter implements the graph.Store interface because it embeds a MemoryStore
type myGraphWriter struct {
graph.MemoryStore // this isn't possible because the memoryStore is private
}
// We selectively (or partially) implement writer related functions
func (g *myGraphWriter) AddVertex(hash K, value T, properties VertexProperties) error {
v := g.MemoryStore.AddVertex() // memory dispatch
// do proprietary db stuff here
}
Because the current memoryStore is private, we would need to reimplement our memory store just to override write-related functions. Embedding nicely fixes that - but memoryStore should be exposed.
I propose we make the memoryStore public: memoryStore -> MemoryStore. Fields of the MemoryStore may stay private.
At $WORK, we implement our own Store interface for reading existing db entities into a graph. This store only implements Read related interface functions of the Store interface and works nicely.
We now would like to implement a partial Store with only Write related Store interface and reuse existing implementation from the existing default memoryStore. For example, I would like to be able to write:
Because the current memoryStore is private, we would need to reimplement our memory store just to override write-related functions. Embedding nicely fixes that - but memoryStore should be exposed.
I propose we make the memoryStore public:
memoryStore
->MemoryStore
. Fields of the MemoryStore may stay private.