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
73 lines
1.7 KiB
Go
73 lines
1.7 KiB
Go
//go:build cgo
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/steveyegge/beads/internal/storage/dolt"
|
|
)
|
|
|
|
// DoltServerHandle wraps a dolt.Server for CGO builds
|
|
type DoltServerHandle struct {
|
|
server *dolt.Server
|
|
}
|
|
|
|
// DoltDefaultSQLPort is the default SQL port for dolt server
|
|
const DoltDefaultSQLPort = dolt.DefaultSQLPort
|
|
|
|
// DoltDefaultRemotesAPIPort is the default remotesapi port for dolt server
|
|
const DoltDefaultRemotesAPIPort = dolt.DefaultRemotesAPIPort
|
|
|
|
// StartDoltServer starts a dolt sql-server for federation mode
|
|
func StartDoltServer(ctx context.Context, dataDir, logFile string, sqlPort, remotePort int) (*DoltServerHandle, error) {
|
|
server := dolt.NewServer(dolt.ServerConfig{
|
|
DataDir: dataDir,
|
|
SQLPort: sqlPort,
|
|
RemotesAPIPort: remotePort,
|
|
Host: "127.0.0.1",
|
|
LogFile: logFile,
|
|
})
|
|
|
|
if err := server.Start(ctx); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &DoltServerHandle{server: server}, nil
|
|
}
|
|
|
|
// Stop stops the dolt server
|
|
func (h *DoltServerHandle) Stop() error {
|
|
if h.server != nil {
|
|
return h.server.Stop()
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// SQLPort returns the SQL port the server is listening on
|
|
func (h *DoltServerHandle) SQLPort() int {
|
|
if h.server != nil {
|
|
return h.server.SQLPort()
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// RemotesAPIPort returns the remotesapi port the server is listening on
|
|
func (h *DoltServerHandle) RemotesAPIPort() int {
|
|
if h.server != nil {
|
|
return h.server.RemotesAPIPort()
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// Host returns the host the server is listening on
|
|
func (h *DoltServerHandle) Host() string {
|
|
if h.server != nil {
|
|
return h.server.Host()
|
|
}
|
|
return ""
|
|
}
|
|
|
|
// DoltServerAvailable returns true when CGO is available
|
|
func DoltServerAvailable() bool {
|
|
return true
|
|
}
|