Skip to content

Commit

Permalink
Simplifying send() arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewjstanford committed Jan 25, 2024
1 parent 2e8c2fa commit 002fca9
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (p *processor) handle(ctx *fh.RequestCtx) {
// If there's metadata - just accept the request and drop it
if len(wrReqIn.Metadata) > 0 {
if p.cfg.Metadata && p.cfg.Tenant.Default != "" {
r := p.send(clientIP, reqID, tenantPrefix, p.cfg.Tenant.Default, wrReqIn)
r := p.send(clientIP, reqID, tenantPrefix+p.cfg.Tenant.Default, wrReqIn)
if r.err != nil {
ctx.Error(err.Error(), fh.StatusInternalServerError)
p.Errorf("src=%s req_id=%s: unable to proxy metadata: %s", clientIP, reqID, r.err)
Expand Down Expand Up @@ -321,12 +321,12 @@ func (p *processor) dispatch(clientIP net.Addr, reqID uuid.UUID, tenantPrefix st
for tenant, wrReq := range m {
wg.Add(1)

go func(idx int, tenantPrefix string, tenant string, wrReq *prompb.WriteRequest) {
go func(idx int, tenant string, wrReq *prompb.WriteRequest) {
defer wg.Done()

r := p.send(clientIP, reqID, tenantPrefix, tenant, wrReq)
r := p.send(clientIP, reqID, tenant, wrReq)
res[idx] = r
}(i, tenantPrefix, tenant, wrReq)
}(i, tenantPrefix+tenant, wrReq)

i++
}
Expand Down Expand Up @@ -369,7 +369,7 @@ func (p *processor) processTimeseries(ts *prompb.TimeSeries) (tenant string, err
return
}

func (p *processor) send(clientIP net.Addr, reqID uuid.UUID, tenantPrefix string, tenant string, wr *prompb.WriteRequest) (r result) {
func (p *processor) send(clientIP net.Addr, reqID uuid.UUID, tenant string, wr *prompb.WriteRequest) (r result) {
start := time.Now()
r.tenant = tenant

Expand All @@ -387,10 +387,6 @@ func (p *processor) send(clientIP net.Addr, reqID uuid.UUID, tenantPrefix string
return
}

if tenantPrefix != "" {
tenant = tenantPrefix + tenant
}

p.fillRequestHeaders(clientIP, reqID, tenant, req)

if p.auth.egressHeader != nil {
Expand Down

0 comments on commit 002fca9

Please sign in to comment.