Revert commitse5330641and0df41523which removed embedded Dolt mode from the beads codebase. The embedded Dolt removal was only intended for Gas Town, not for Beads. Restores: - dolthub/driver dependency and embedded connection path - Advisory flock (AccessLock) for concurrent process protection - Embedded connector lifecycle management in DoltStore - All CGO build tags across ~45 files - Vendored go-icu-regex library - nocgo stub files for non-CGO builds - Bootstrap and embedded_uow helpers - factory_dolt_test.go and dolt_singleprocess_test.go Merge conflict resolutions: - store.go: TCP fail-fast check wrapped inside if cfg.ServerMode - store.go: backtick-quoting for embedded CREATE DATABASE (prefix-based names) - perf_dolt.go: port references updated from 3306 to 3307 - ci.yml: restored continue-on-error for Nix (dolthub/driver requires Go 1.25.6+) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Executed-By: beads/crew/emma Rig: beads Role: crew
30 lines
995 B
Go
30 lines
995 B
Go
// Package doltutil provides shared utilities for embedded Dolt operations.
|
|
// This package exists to avoid import cycles between dolt and dolt/migrations.
|
|
package doltutil
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
// CloseTimeout is the maximum time to wait for close operations.
|
|
// Embedded Dolt can hang indefinitely on close; this prevents commands from hanging.
|
|
const CloseTimeout = 5 * time.Second
|
|
|
|
// CloseWithTimeout runs a close function with a timeout to prevent indefinite hangs.
|
|
// This is needed because embedded Dolt's engine can hang during shutdown.
|
|
// Returns an error if the close times out or if the close function returns an error.
|
|
func CloseWithTimeout(name string, closeFn func() error) error {
|
|
done := make(chan error, 1)
|
|
go func() {
|
|
done <- closeFn()
|
|
}()
|
|
|
|
select {
|
|
case err := <-done:
|
|
return err
|
|
case <-time.After(CloseTimeout):
|
|
// Close is hanging - log and continue rather than blocking forever
|
|
return fmt.Errorf("%s close timed out after %v", name, CloseTimeout)
|
|
}
|
|
}
|