Use one relay listener lane by default
This commit is contained in:
@@ -2839,9 +2839,9 @@ def gateway_listener_min_lanes():
|
||||
|
||||
def gateway_listener_max_lanes():
|
||||
try:
|
||||
configured = int(os.environ.get("NAPSEER_GATEWAY_RELAY_LISTENER_MAX_LANES", "3"))
|
||||
configured = int(os.environ.get("NAPSEER_GATEWAY_RELAY_LISTENER_MAX_LANES", "1"))
|
||||
except ValueError:
|
||||
configured = 3
|
||||
configured = 1
|
||||
return max(gateway_listener_min_lanes(), min(5, configured))
|
||||
|
||||
|
||||
@@ -4567,6 +4567,11 @@ def handle_gateway_relay_session(connect_request, listener_sock=None):
|
||||
"snapshot_truncated": len(snapshot_data) >= max_snapshot_bytes,
|
||||
"sent_at": iso_now(),
|
||||
})
|
||||
elif gateway_remote_should_run():
|
||||
# An explicitly configured spare lane stays silent while it is
|
||||
# outside the current target. It is not a readiness failure.
|
||||
closed_by_relay_streak = 0
|
||||
failure_streak = 0
|
||||
else:
|
||||
for chunk in attach.chunks:
|
||||
send_gateway_payload({
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import importlib.util
|
||||
import pathlib
|
||||
|
||||
|
||||
def load_module():
|
||||
script_path = pathlib.Path(__file__).resolve().parents[1] / "resources" / "scripts" / "napseer_mcp_server.py"
|
||||
spec = importlib.util.spec_from_file_location("napseer_gateway_listener_lanes_test", script_path)
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
assert spec and spec.loader
|
||||
spec.loader.exec_module(module)
|
||||
return module
|
||||
|
||||
|
||||
def test_gateway_relay_uses_one_listener_lane_by_default(monkeypatch):
|
||||
mod = load_module()
|
||||
monkeypatch.delenv("NAPSEER_GATEWAY_RELAY_LISTENER_MIN_LANES", raising=False)
|
||||
monkeypatch.delenv("NAPSEER_GATEWAY_RELAY_LISTENER_MAX_LANES", raising=False)
|
||||
|
||||
assert mod.gateway_listener_min_lanes() == 1
|
||||
assert mod.gateway_listener_max_lanes() == 1
|
||||
assert mod.gateway_listener_target_lanes() == 1
|
||||
assert mod.gateway_listener_lane_ids() == ["lane-1"]
|
||||
|
||||
|
||||
def test_gateway_relay_extra_lanes_require_explicit_configuration(monkeypatch):
|
||||
mod = load_module()
|
||||
monkeypatch.setenv("NAPSEER_GATEWAY_RELAY_LISTENER_MIN_LANES", "1")
|
||||
monkeypatch.setenv("NAPSEER_GATEWAY_RELAY_LISTENER_MAX_LANES", "3")
|
||||
|
||||
assert mod.gateway_listener_lane_ids() == ["lane-1", "lane-2", "lane-3"]
|
||||
Reference in New Issue
Block a user