story(issue-78): add dgraph daggerverse module with plaintext cluster + dgo client#81
Open
Zaba505 wants to merge 3 commits into
Open
story(issue-78): add dgraph daggerverse module with plaintext cluster + dgo client#81Zaba505 wants to merge 3 commits into
Zaba505 wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new daggerverse/dgraph module that provisions a plaintext Dgraph (Zero + N Alpha) topology and exposes a pure-Go dgo client, along with a dedicated tests/ module and CI wiring so the suite runs as part of the repo’s ci module.
Changes:
- Introduces
daggerverse/dgraphmodule (cluster + client + plaintext security profiles) pinned todgraph/dgraph:v24.0.4. - Adds
daggerverse/dgraph/testswith acceptance-style checks and anAll()aggregator. - Wires the new tests module into
ci/main.goand the rootdagger.jsondependencies.
Reviewed changes
Copilot reviewed 16 out of 18 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| daggerverse/dgraph/main.go | Defines the module root type and user-facing module documentation. |
| daggerverse/dgraph/security.go | Adds plaintext server/client security profile constructors. |
| daggerverse/dgraph/cluster.go | Implements the Zero+Alpha cluster topology, endpoint helpers, binding helpers, and teardown. |
| daggerverse/dgraph/client.go | Implements a stateless-per-call dgo-backed client targeting local or remote clusters. |
| daggerverse/dgraph/README.md | Documents scope (plaintext-only), topology constraints, caching behavior, and follow-ups. |
| daggerverse/dgraph/dagger.json | Declares the dgraph module and its dependency on random. |
| daggerverse/dgraph/go.mod | Adds the module’s Go dependencies (including dgo/v240). |
| daggerverse/dgraph/go.sum | Locks module dependency checksums. |
| daggerverse/dgraph/.gitignore | Ignores generated Dagger Go bindings and related artifacts. |
| daggerverse/dgraph/.gitattributes | Marks generated bindings as linguist-generated. |
| daggerverse/dgraph/tests/main.go | Adds the dgraph module test suite and All() aggregation. |
| daggerverse/dgraph/tests/dagger.json | Declares the tests module and depends on .. and random. |
| daggerverse/dgraph/tests/go.mod | Adds the tests module Go dependencies. |
| daggerverse/dgraph/tests/go.sum | Locks tests module dependency checksums. |
| daggerverse/dgraph/tests/.gitignore | Ignores generated Dagger Go bindings and related artifacts for tests. |
| daggerverse/dgraph/tests/.gitattributes | Marks generated bindings as linguist-generated for tests. |
| ci/main.go | Adds a CI job to run dag.DgraphTests().All(ctx). |
| dagger.json | Registers the new dgraph-tests module at the repo root for CI consumption. |
Comments suppressed due to low confidence (1)
daggerverse/dgraph/tests/main.go:219
- HttpEndpointsShouldNotBeCached similarly never stops the cluster and only compares list lengths, so it can’t catch a cached result. Add a Stop(ctx) between calls and validate the endpoint(s) are serving again after the restart to ensure
+cache="never"is effective.
cluster := freshCluster(ctx, 1, 1)
eps1, err := cluster.HTTPEndpoints(ctx)
if err != nil {
return fmt.Errorf("endpoints 1: %w", err)
}
… + dgo client Adds `daggerverse/dgraph/` end-to-end: a Zero-coordinator + N-Alpha topology built from `dgraph/dgraph` images and a pure-Go dgo-based Client that can target either the local cluster or any reachable remote cluster (Dgraph Cloud, self-hosted). Plaintext-only on every listener; TLS/mTLS, multi-Zero HA, ACL, Ratel, and RDF/delete mutations are explicit follow-ups. Deviations from the story spec (all documented in README): - `+cache="session"` on `Dgraph.Cluster` / `Dgraph.Client` (not `"never"`). Chained `Mutate -> RunQuery` loses graph state under `never` because each method call re-spawns the cluster. Methods on *Cluster / *Client stay `+cache="never"`. - `Client.Query` renamed to `Client.RunQuery` to avoid the Dagger Go SDK codegen collision with the always-present `query` querybuilder field on every generated object type. - `Client.QueryWithVars(vars map[string]string)` becomes `(varsJson string)` because Dagger function signatures don't support Go map params. - Adds odd-replicas validation (Dgraph Raft requirement). - Adds `Cluster.Stop`, `Cluster.ZeroHosts`, `Cluster.AlphaHostNames` helpers needed for teardown and bind-aware tests. All 15 acceptance-criterion tests pass individually via `dagger -m daggerverse/dgraph/tests call <name>`. The `All()` aggregator defaults to `--parallel=1` because session-cached clusters with the default shape collide across parallel tests. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Zero is internal to a Dgraph cluster (Alpha↔Zero coordination and admin/loader tools per dgraph docs); clients only talk to Alpha. The spec does not expose admin tooling, so user containers never need Zero reachable. The bind-zeros test was the only consumer of these methods and conflicted with `+cache="session"` on Cluster: Dagger's `WithServiceBinding(alias, svc)` only registers the alias for the first consumer that lazy-starts svc, and the cluster's Alphas already claim it. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
74edb02 to
a0a0ce6
Compare
- main.go / cluster.go: file-map and Cluster doc reference RunQuery (the actual exported method), not the renamed-away Query. - tests/freshCluster: drop the misleading "defer Stop" instruction — Dgraph.Cluster is +cache="session", so Stop in one test would kill the shared cluster for any peer test still running. - tests/Grpc|HttpEndpointsShouldNotBeCached: a length check can't distinguish a real re-execution from cached strings, so now Stop the cluster between calls and follow the second call with a real AlterSchema — proves start() actually ran instead of returning a cached endpoint list pointing at dead services. - tests/MutateShouldNotBeCached: replace hardcoded "cache-probe" payload with a randName-generated value so re-runs never collide on a probe name across sessions. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Comment on lines
+112
to
+115
| // derived from random material at construction time so distinct | ||
| // Cluster() calls within one engine session also get distinct | ||
| // service DNS, even though +cache="session" lets identical args | ||
| // share one service. |
| // +private | ||
| AlphaHosts []string | ||
| // +private | ||
| ClientSecurityMode string |
|
|
||
| Cluster.GrpcEndpoints(ctx) ([]string, error) | ||
| Cluster.HttpEndpoints(ctx) ([]string, error) | ||
| Cluster.AlphaHostNames(ctx) ([]string, error) |
Comment on lines
+105
to
+113
| // randName returns a short, DNS- and DQL-safe random identifier suitable | ||
| // for use as a schema-indexed value, blank-node name, or query fixture. | ||
| func randName(ctx context.Context, prefix string) (string, error) { | ||
| h, err := dag.Random().Sha256(ctx, dagger.RandomSha256Opts{N: 16}) | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
| return prefix + h[:12], nil | ||
| } |
Comment on lines
+223
to
+224
| // OK or the deadline passes. endpoint is the host:port pair returned | ||
| // by Service.Endpoint(ctx, port=8080). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #78.
daggerverse/dgraph/withmain.go,security.go,cluster.go,client.go,README.md,dagger.json. Spins up a single Zero + N Alpha topology fromdgraph/dgraph:v24.0.4images and exposes a pure-Go dgo-based*Clientthat targets either the local cluster or any reachable remote cluster.ci/main.goand the top-leveldagger.json.Deviations from the story spec (all documented in README)
+cache="session"onDgraph.Cluster/Dgraph.Client(not"never") — chainedMutate → RunQueryloses graph state underneverbecause each method call re-spawns the cluster. Methods on*Cluster/*Clientstay+cache="never".Client.Queryrenamed toClient.RunQuery— Dagger Go SDK codegen allocates a struct field named after the lowercase method name to cache the result, andquerycollides with the always-presentquery *querybuilder.Selectionfield.runQuerysidesteps the collision.Client.QueryWithVars(vars map[string]string)becomes(varsJson string)— Dagger function signatures don't support Go map parameters.alphas % replicas == 0rule (Dgraph's Raft consensus requires odd replica counts).Cluster.Stop,Cluster.ZeroHosts,Cluster.AlphaHostNameshelpers needed for cluster teardown and bind-aware tests.Test plan
cd daggerverse/dgraph && dagger functionslistsplaintext-client-securityandplaintext-server-security(cluster + client are registered but filtered from the listing, matching kafka's behavior).dagger -m daggerverse/dgraph/tests call <name>and confirm exit 0:defaults-produce-working-single-node-clustergrpc-endpoints-should-not-be-cachedhttp-endpoints-should-not-be-cachedmutate-should-not-be-cachedcluster-rejects-multiple-zeroscluster-rejects-invalid-alphas-replicas-ratiocluster-rejects-nil-securitybind-zeros-resolves-from-user-containermulti-alpha-single-group-all-reachablemulti-alpha-sharded-topologyclient-alter-schema-round-tripclient-mutate-then-query-round-tripclient-mutate-without-commit-does-not-persistclient-query-with-vars-round-tripremote-client-can-target-existing-clusterdagger -m daggerverse/dgraph/tests call all(defaults to--parallel=1because session-cached clusters with the default shape collide across parallel tests).dagger -m ci call testcontinues to pass.🤖 Generated with Claude Code