fix(dolt): server mode should support multi-process access
Code review fix: In server mode, Dolt connects to an external sql-server and should NOT be single-process-only. The whole point of server mode is to enable multi-writer access. Changes: - Add Config.GetCapabilities() method that considers server mode - Update daemon_guard, daemon_autostart, daemons, main to use GetCapabilities() - Add TestGetCapabilities test - Update init command help text to document server mode flags The existing CapabilitiesForBackend(string) is kept for backward compatibility but now includes a note to use Config.GetCapabilities() when the full config is available. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -338,6 +338,45 @@ func TestDoltServerMode(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
// TestGetCapabilities tests that GetCapabilities properly handles server mode
|
||||
func TestGetCapabilities(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
cfg *Config
|
||||
wantSingleProc bool
|
||||
}{
|
||||
{
|
||||
name: "sqlite is multi-process",
|
||||
cfg: &Config{Backend: BackendSQLite},
|
||||
wantSingleProc: false,
|
||||
},
|
||||
{
|
||||
name: "dolt embedded is single-process",
|
||||
cfg: &Config{Backend: BackendDolt, DoltMode: DoltModeEmbedded},
|
||||
wantSingleProc: true,
|
||||
},
|
||||
{
|
||||
name: "dolt default (empty) is single-process",
|
||||
cfg: &Config{Backend: BackendDolt},
|
||||
wantSingleProc: true,
|
||||
},
|
||||
{
|
||||
name: "dolt server mode is multi-process",
|
||||
cfg: &Config{Backend: BackendDolt, DoltMode: DoltModeServer},
|
||||
wantSingleProc: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := tt.cfg.GetCapabilities().SingleProcessOnly
|
||||
if got != tt.wantSingleProc {
|
||||
t.Errorf("GetCapabilities().SingleProcessOnly = %v, want %v", got, tt.wantSingleProc)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestDoltServerModeRoundtrip tests that server mode config survives save/load
|
||||
func TestDoltServerModeRoundtrip(t *testing.T) {
|
||||
tmpDir := t.TempDir()
|
||||
|
||||
Reference in New Issue
Block a user