Files
beads/cmd/bd/dolt_server_cgo.go
emma f91bbf3a03 fix(build): add CGO build constraints for Dolt-dependent files
The dolthub/gozstd dependency requires CGO. Several files were importing
the dolt package without build constraints, causing CI failures when
building with CGO_ENABLED=0 for Linux, FreeBSD, and Android.

Changes:
- Add //go:build cgo to federation.go and doctor/federation.go
- Create dolt_server_cgo.go/nocgo.go to abstract dolt.Server usage
- Create federation_nocgo.go with stub command explaining CGO requirement
- Create doctor/federation_nocgo.go with stub health checks
- Update daemon.go to use the dolt server abstraction

Federation and Dolt-specific features are unavailable in non-CGO builds.
Users are directed to pre-built binaries from GitHub releases.

Fixes v0.49.0 CI failure.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 00:01:37 -08:00

75 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
}