Documentation
¶
Overview ¶
Example 23_bolt_server drives the GoGraph Bolt v5 server end to end: it starts the embedded bolt/server over an in-memory labelled property graph, connects the official neo4j-go-driver/v5 as a real client, runs a battery of Cypher queries over driver sessions, and shuts everything down cleanly with no goroutine left behind.
Unlike a hello-world round-trip, this example seeds the served graph from a seeded, scale-parametrised generator and then puts the wire path under load, so it doubles as a Bolt-throughput benchmark. It reports the evidence that matters for the Bolt/Cypher subject — query throughput, a p50/p95/p99 latency distribution, and live Go heap — as volatile telemetry, while the deterministic results (a label-scan count equal to the known node count and the number of queries that succeeded) are printed as bare facts a regression test can pin.
Model ¶
(:Person {id, name}) // id is a 24-char hex string
(:Person)-[:KNOWS {since}]->(:Person) // knowsMin..knowsMax per person
The graph is a directed social network: every person is given a random out-degree in [knowsMin, knowsMax] to distinct other people (no self-loops, no duplicate targets). Every KNOWS edge carries a mandatory since date, stored as an ISO-8601 (YYYY-MM-DD) string drawn from the seeded RNG and anchored to a fixed reference date, so it is reproducible for a given -seed and the cypher.Engine reads it back as a non-null, chronologically sortable value (lpg.TimeValue is not used: the Cypher reader maps it to null, whereas the tagged date strings round-trip).
Scale and load ¶
Run with no flags, the example seeds a small deterministic graph (2000 people) and fires 2000 read queries from a pool of driver sessions, fast enough to stay well under the 60 s short-test budget. Every dimension is a flag, so the same binary scales the dataset and the query load up to where the Bolt path's behaviour is actually observable:
go run ./examples/23_bolt_server -nodes 200000 -queries 50000 -sessions 16 -seed 7
The deterministic facts are reproducible for a fixed -seed; only the telemetry (lines prefixed with "# ") — throughput, latency percentiles, and heap — varies between runs and machines.
Teardown ¶
The listener binds to 127.0.0.1:0 so the kernel assigns a free port and a test run never collides. Serve runs under a cancellable context; on completion the client driver is closed, the server is gracefully shut down, and the serve goroutine is drained. Serve only returns after every per-connection goroutine has finished, so the drain guarantees no goroutine leaks — the same teardown discipline as bolt/server/example_test.go.