From 0aa265c5cc8ebe5de2dd3486b3da5d0ca68999fa Mon Sep 17 00:00:00 2001 From: Krithika Sundararajan Date: Thu, 3 Nov 2022 16:51:12 +0800 Subject: [PATCH] Send down the labels into the dispatch requests from the lazy router --- interceptor.go | 2 ++ lazy_router.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/interceptor.go b/interceptor.go index a300eea..fc9b30f 100644 --- a/interceptor.go +++ b/interceptor.go @@ -12,6 +12,8 @@ var ( CtxComponentIDKey CtxKey = "CTX_COMPONENT_ID" // CtxComponentKindKey is used to denote the component's kind in the request context CtxComponentKindKey CtxKey = "CTX_COMPONENT_KIND" + // CtxComponentLabelsKey is used to denote the component's labels in the request context + CtxComponentLabelsKey CtxKey = "CTX_COMPONENT_LABELS" ) // Interceptor is the interface for a structural interceptor diff --git a/lazy_router.go b/lazy_router.go index 55e5cd2..b3a29f0 100644 --- a/lazy_router.go +++ b/lazy_router.go @@ -75,7 +75,7 @@ func (r *LazyRouter) Dispatch(ctx context.Context, req Request) ResponseQueue { for _, route := range routes { copyReq, _ := req.Clone() responses := make([]Response, 0) - responseCh := route.Dispatch(ctx, copyReq).Iter() + responseCh := route.Dispatch(context.WithValue(ctx, CtxComponentLabelsKey, labels), copyReq).Iter() ok := true for ok { select {