Skip to content

CBG-5460 move hlc implementation to sg-bucket - #146

Merged
torcolvin merged 3 commits into
mainfrom
CBG-5460
Jun 25, 2026
Merged

CBG-5460 move hlc implementation to sg-bucket#146
torcolvin merged 3 commits into
mainfrom
CBG-5460

Conversation

@torcolvin

@torcolvin torcolvin commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

This review was already done in an earlier stage of couchbase/sync_gateway#8375 - this just collapses the code into the sg-bucket repo from the sync_gateway and rosmar repos. This moves hlc files into sg-bucket from sync_gateway as they were done in the upstream sync gateway PR.

Blocks couchbaselabs/rosmar#79 and couchbase/sync_gateway#8375

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a Hybrid Logical Clock (HLC) implementation into the sg-bucket module (moved from Sync Gateway / Rosmar), including platform-specific wall-clock handling and accompanying unit tests.

Changes:

  • Added HybridLogicalClock implementation for generating CAS-comparable HLC timestamps.
  • Added Windows-specific high-resolution wall clock implementation (via GetSystemTimePreciseAsFileTime) with a non-Windows fallback.
  • Added unit tests covering monotonicity, masking, flooring behavior, reverse-time behavior, and concurrency safety; updated module dependencies to include golang.org/x/sys.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
hlc.go Core HLC implementation and exported helpers/constants.
hlc_nonwindows.go Non-Windows wall-clock source using time.Now().UnixNano().
hlc_windows.go Windows wall-clock source using high-resolution system time.
hlc_test.go Test suite for HLC correctness and concurrency behavior.
go.mod Adds golang.org/x/sys and bumps Go version directive.
go.sum Adds checksums for the new golang.org/x/sys dependency.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread go.mod
module github.com/couchbase/sg-bucket

go 1.24.0
go 1.25.0
Comment thread hlc_test.go
Comment thread hlc.go
@torcolvin torcolvin mentioned this pull request Jun 24, 2026
@torcolvin
torcolvin merged commit d9dd0c0 into main Jun 25, 2026
19 checks passed
@torcolvin
torcolvin deleted the CBG-5460 branch June 25, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants