refactor(broker): carry NoDaemon on the wire without compatibility shims
- commit
- 26fe86a4807909dfd76556815335b7eee34779bb
- author
- brice · · 2026-09-23 08:21 UTC
- parent
- 1d7fc8e
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
3 files · +12 -1
M internal/adapters/brokeripc/limits_test.go +1 -0
| @@ -223,6 +223,7 @@ func TestErrorDetailMapping(t *testing.T) { | |||
| 223 | 223 | admission uint32 | |
| 224 | 224 | }{ | |
| 225 | 225 | {"typed", ports.BrokerError{Code: ports.BrokerErrorIncompatible, Text: "no"}, ports.BrokerErrorIncompatible, 0}, | |
| 226 | + | {"no daemon", ports.BrokerError{Code: ports.BrokerErrorNoDaemon, Text: "remote daemon is absent"}, ports.BrokerErrorNoDaemon, 0}, | |
| 226 | 227 | {"limit", ports.BrokerAdmissionLimit, ports.BrokerErrorUnavailable, 1}, | |
| 227 | 228 | {"closed", ports.BrokerAdmissionClosed, ports.BrokerErrorUnavailable, 2}, | |
| 228 | 229 | {"stale", ports.BrokerAdmissionStale, ports.BrokerErrorUnavailable, 3}, | |
| @@ -223,6 +223,7 @@ func TestErrorDetailMapping(t *testing.T) { | |||||
| 223 | admission uint32 | 223 | admission uint32 | ||
| 224 | }{ | 224 | }{ | ||
| 225 | {"typed", ports.BrokerError{Code: ports.BrokerErrorIncompatible, Text: "no"}, ports.BrokerErrorIncompatible, 0}, | 225 | {"typed", ports.BrokerError{Code: ports.BrokerErrorIncompatible, Text: "no"}, ports.BrokerErrorIncompatible, 0}, | ||
| 226 | + | {"no daemon", ports.BrokerError{Code: ports.BrokerErrorNoDaemon, Text: "remote daemon is absent"}, ports.BrokerErrorNoDaemon, 0}, | |||
| 226 | {"limit", ports.BrokerAdmissionLimit, ports.BrokerErrorUnavailable, 1}, | 227 | {"limit", ports.BrokerAdmissionLimit, ports.BrokerErrorUnavailable, 1}, | ||
| 227 | {"closed", ports.BrokerAdmissionClosed, ports.BrokerErrorUnavailable, 2}, | 228 | {"closed", ports.BrokerAdmissionClosed, ports.BrokerErrorUnavailable, 2}, | ||
| 228 | {"stale", ports.BrokerAdmissionStale, ports.BrokerErrorUnavailable, 3}, | 229 | {"stale", ports.BrokerAdmissionStale, ports.BrokerErrorUnavailable, 3}, | ||
M internal/adapters/brokerwire/codec.go +1 -1
| @@ -1239,7 +1239,7 @@ func snapshotDaemonFromWire(message *wire.SnapshotDaemon) (ports.BrokerDaemonObs | |||
| 1239 | 1239 | if err != nil { | |
| 1240 | 1240 | return daemon, 0, 0, ErrInvalidMessage | |
| 1241 | 1241 | } | |
| 1242 | - | if availability < domain.RemoteAvailabilityUnknown || availability > domain.RemoteAvailabilityInvalidResponse { | |
| 1242 | + | if availability < domain.RemoteAvailabilityUnknown || availability > domain.RemoteAvailabilityNoDaemon { | |
| 1243 | 1243 | return daemon, 0, 0, ErrInvalidMessage | |
| 1244 | 1244 | } | |
| 1245 | 1245 | failureKind, err := brokerEnum8[domain.RemoteFailureKind](message.GetFailureKind()) | |
| @@ -1239,7 +1239,7 @@ func snapshotDaemonFromWire(message *wire.SnapshotDaemon) (ports.BrokerDaemonObs | |||||
| 1239 | if err != nil { | 1239 | if err != nil { | ||
| 1240 | return daemon, 0, 0, ErrInvalidMessage | 1240 | return daemon, 0, 0, ErrInvalidMessage | ||
| 1241 | } | 1241 | } | ||
| 1242 | - | if availability < domain.RemoteAvailabilityUnknown || availability > domain.RemoteAvailabilityInvalidResponse { | 1242 | + | if availability < domain.RemoteAvailabilityUnknown || availability > domain.RemoteAvailabilityNoDaemon { |
| 1243 | return daemon, 0, 0, ErrInvalidMessage | 1243 | return daemon, 0, 0, ErrInvalidMessage | ||
| 1244 | } | 1244 | } | ||
| 1245 | failureKind, err := brokerEnum8[domain.RemoteFailureKind](message.GetFailureKind()) | 1245 | failureKind, err := brokerEnum8[domain.RemoteFailureKind](message.GetFailureKind()) | ||
M internal/adapters/sessionwire/picker_interaction_test.go +10 -0
| @@ -106,6 +106,16 @@ func TestPickerServerMessagesEncodeWithTypes(t *testing.T) { | |||
| 106 | 106 | } | |
| 107 | 107 | } | |
| 108 | 108 | ||
| 109 | + | func TestPickerSnapshotNoDaemonStatusRoundTrips(t *testing.T) { | |
| 110 | + | line := protocol.PickerLine{Status: protocol.PickerLineStatusNoDaemon, StatusDetail: "no daemon — Enter to create a session"} | |
| 111 | + | encoded := pickerLineToWire(line) | |
| 112 | + | require.Equal(t, uint32(protocol.PickerLineStatusNoDaemon), encoded.GetStatus()) | |
| 113 | + | require.Equal(t, line.StatusDetail, encoded.GetStatusDetail()) | |
| 114 | + | decoded, err := pickerLineFromWire(encoded) | |
| 115 | + | require.NoError(t, err) | |
| 116 | + | require.Equal(t, line, decoded) | |
| 117 | + | } | |
| 118 | + | ||
| 109 | 119 | func TestPickerSnapshotNormalizesIntoProjections(t *testing.T) { | |
| 110 | 120 | snapshot := pickerWireSnapshot() | |
| 111 | 121 | raw := &scriptedTransport{} | |
| @@ -106,6 +106,16 @@ func TestPickerServerMessagesEncodeWithTypes(t *testing.T) { | |||||
| 106 | } | 106 | } | ||
| 107 | } | 107 | } | ||
| 108 | 108 | ||||
| 109 | + | func TestPickerSnapshotNoDaemonStatusRoundTrips(t *testing.T) { | |||
| 110 | + | line := protocol.PickerLine{Status: protocol.PickerLineStatusNoDaemon, StatusDetail: "no daemon — Enter to create a session"} | |||
| 111 | + | encoded := pickerLineToWire(line) | |||
| 112 | + | require.Equal(t, uint32(protocol.PickerLineStatusNoDaemon), encoded.GetStatus()) | |||
| 113 | + | require.Equal(t, line.StatusDetail, encoded.GetStatusDetail()) | |||
| 114 | + | decoded, err := pickerLineFromWire(encoded) | |||
| 115 | + | require.NoError(t, err) | |||
| 116 | + | require.Equal(t, line, decoded) | |||
| 117 | + | } | |||
| 118 | + | ||||
| 109 | func TestPickerSnapshotNormalizesIntoProjections(t *testing.T) { | 119 | func TestPickerSnapshotNormalizesIntoProjections(t *testing.T) { | ||
| 110 | snapshot := pickerWireSnapshot() | 120 | snapshot := pickerWireSnapshot() | ||
| 111 | raw := &scriptedTransport{} | 121 | raw := &scriptedTransport{} | ||