Skip to content

Conversation

@matthewmcneely
Copy link
Contributor

Description

This PR introduces a pluggable hooks framework that abstracts Zero-related operations in the worker package, enabling Dgraph to run in embedded mode without a separate Zero process -- many "unit" tests that aren't reliant on a full networked cluster would be great candidates for the abstraction.

Motivation

To support embedded deployment scenarios where Dgraph runs as a library within another application or in testing, the tight coupling between the worker package and Zero network operations needed to be abstracted. This allows alternative implementations to provide UID assignment, timestamp allocation, and transaction coordination without requiring a running Zero cluster.

Changes

New Package: hooks/

File Description
hooks/config.go Defines ZeroHooks interface and configuration management
hooks/init.go Package documentation
hooks/config_test.go Comprehensive unit tests with race detection

Testing

  • 8 unit tests with -race flag covering:
    • Enable/Disable lifecycle
    • Custom vs default hooks precedence
    • Panic on missing configuration
    • ZeroHooksFns wrapper delegation
    • Concurrent access safety

Checklist

  • The PR title follows the
    Conventional Commits syntax, leading
    with fix:, feat:, chore:, ci:, etc.
  • Code compiles correctly and linting (via trunk) passes locally
  • Tests added for new functionality, or regression tests for bug fixes added as applicable

@matthewmcneely matthewmcneely requested a review from a team as a code owner January 26, 2026 22:38
@github-actions github-actions bot added area/testing Testing related issues area/core internal mechanisms go Pull requests that update Go code labels Jan 26, 2026
@matthewmcneely matthewmcneely marked this pull request as draft January 26, 2026 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core internal mechanisms area/testing Testing related issues go Pull requests that update Go code

Development

Successfully merging this pull request may close these issues.

2 participants