8000 Expose MemoryStore · Issue #164 · dominikbraun/graph · GitHub
[go: up one dir, main page]

Skip to content

Expose MemoryStore #164

Open
Open

Description

@davidovich

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.

Activity

  1. dominikbraun commented on Feb 28, 2024

    @dominikbraun
    Owner

    Sorry for the late response, I had a busy time at work and I'm back now. This sounds reasonable, going to review the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0