Skip to content

Commit e52cdab

Browse files
xurui-cRachel Chen
andauthored
ref(cbrs): no more default routing decision (#7421)
Not sure what the vision was with having a default routing decision that gets passed into `get_routing_decision()` which gives you a new routing decision (and this fails open too so if things go wrong you get a sensible default routing decision anyways). Just keep track of routing context instead --------- Co-authored-by: Rachel Chen <[email protected]>
1 parent 6c487c6 commit e52cdab

File tree

2 files changed

+3
-38
lines changed

2 files changed

+3
-38
lines changed

snuba/web/rpc/__init__.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
RPCRequestException,
3232
convert_rpc_exception_to_proto,
3333
)
34-
from snuba.web.rpc.storage_routing.defaults import get_default_routing_decision
3534
from snuba.web.rpc.storage_routing.load_retriever import get_cluster_loadinfo
3635
from snuba.web.rpc.storage_routing.routing_strategies.storage_routing import (
3736
RoutingContext,
@@ -135,7 +134,6 @@ class RPCEndpoint(Generic[Tin, Tout], metaclass=RegisteredClass):
135134
def __init__(self, metrics_backend: MetricsBackend | None = None) -> None:
136135
self._timer = Timer("endpoint_timing")
137136
self._metrics_backend = metrics_backend or environment.metrics
138-
self.routing_decision = get_default_routing_decision(None)
139137

140138
@classmethod
141139
def request_class(cls) -> Type[Tin]:
@@ -193,7 +191,7 @@ def execute(self, in_msg: Tin) -> Tout:
193191
span = scope.span
194192
if span is not None:
195193
span.description = self.config_key()
196-
self.routing_decision.routing_context = RoutingContext(timer=self._timer, in_msg=in_msg)
194+
self.routing_context = RoutingContext(timer=self._timer, in_msg=in_msg)
197195

198196
self.__before_execute(in_msg)
199197
error: Exception | None = None
@@ -265,13 +263,8 @@ def __before_execute(self, in_msg: Tin) -> None:
265263
if state.get_config("storage_routing.enable_get_cluster_loadinfo", True):
266264
get_cluster_loadinfo()
267265

268-
selected_strategy = RoutingStrategySelector().select_routing_strategy(
269-
self.routing_decision.routing_context
270-
)
271-
self.routing_decision.strategy = selected_strategy
272-
self.routing_decision = selected_strategy.get_routing_decision(
273-
self.routing_decision.routing_context
274-
)
266+
selected_strategy = RoutingStrategySelector().select_routing_strategy(self.routing_context)
267+
self.routing_decision = selected_strategy.get_routing_decision(self.routing_context)
275268
self._timer.mark("rpc_start")
276269
self._before_execute(in_msg)
277270

snuba/web/rpc/storage_routing/defaults.py

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)