January 2020
Intermediate to advanced
640 pages
16h 56m
English
The in-memory graph implementation will serve as a gentle introduction to writing a complete graph store implementation. By virtue of maintaining the graph in memory, this implementation is simple, self-contained, and safe for concurrent access. This makes it an ideal candidate for writing unit tests that require access to the link graph component.
Let's take a look at its implementation, starting with the definition of the InMemoryGraph type:
type edgeList []uuid.UUID type InMemoryGraph struct { mu sync.RWMutex links map[uuid.UUID]*graph.Link edges map[uuid.UUID]*graph.Edge linkURLIndex map[string]*graph.Link linkEdgeMap map[uuid.UUID]edgeList }
The InMemoryGraph struct defines two maps (links and