// WithRequestId sets the correlation id on the context
975957
func WithRequestId(ctx context.Context, correlationId string) context.Context {
	return context.WithValue(ctx, RequestIdKey, correlationId)
}
106965
func (o *GetServiceIDParams) WithID(id int64) *GetServiceIDParams {
	o.SetID(id)
	return o
}
96964
func WithRequest(h http.Handler) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		ctx := r.Context()

		ctx = httpx.WithRequest(ctx, r)

		// Add the request to the context.
		reporter.AddRequest(ctx, r)

		// Add the request id
		reporter.AddContext(ctx, "request_id", httpx.RequestID(ctx))

		h.ServeHTTP(w, r.WithContext(ctx))
	})
}
820754
func GetRequestID(ctx context.Context) (uint64, bool) {
	var (
		szID   []string
		szIDOK bool
	)

	// Prefer the incoming context, but look in both types.
	if md, ok := metadata.FromIncomingContext(ctx); ok {
		szID, szIDOK = md[RequestIDKey]
	} else if md, ok := metadata.FromOutgoingContext(ctx); ok {
		szID, szIDOK = md[RequestIDKey]
	}

	if szIDOK && len(szID) == 1 {
		if id, err := strconv.ParseUint(szID[0], 10, 64); err == nil {
			return id, true
		}
	}

	return 0, false
}
508109
func (s *DeleteGroupOutput) SetRequestId(v string) *DeleteGroupOutput {
	s.RequestId = &v
	return s
}
449645
func (s *ListGroupMembershipsOutput) SetRequestId(v string) *ListGroupMembershipsOutput {
	s.RequestId = &v
	return s
}
996171
func RequestIDWithConfig(config RequestIDConfig) echo.MiddlewareFunc {
	// Defaults
	if config.Skipper == nil {
		config.Skipper = DefaultRequestIDConfig.Skipper
	}
	if config.Generator == nil {
		config.Generator = generator
	}

	return func(next echo.HandlerFunc) echo.HandlerFunc {
		return func(c echo.Context) error {
			if config.Skipper(c) {
				return next(c)
			}

			req := c.Request()
			res := c.Response()
			rid := req.Header.Get(echo.HeaderXRequestID)
			if rid == "" {
				rid = config.Generator()
			}
			res.Header().Set(echo.HeaderXRequestID, rid)

			return next(c)
		}
	}
}
903691
func (s *UpdateTrustOutput) SetRequestId(v string) *UpdateTrustOutput {
	s.RequestId = &v
	return s
}
1130528
func (s *DescribeUserOutput) SetRequestId(v string) *DescribeUserOutput {
	s.RequestId = &v
	return s
}
74899
func GetRequestID(req *http.Request) string {
	return req.Header.Get(common.RequestHeaderKey)
}
190440
func (o *UpdateTaskParams) WithID(id int64) *UpdateTaskParams {
	o.SetID(id)
	return o
}
319082
func (o *PutEndpointIDParams) WithID(id string) *PutEndpointIDParams {
	o.SetID(id)
	return o
}
628292
func (q *pendingCallRegistry) WithReservedRequestID(ctx context.Context) (context.Context, int) {
	q.mutex.Lock()
	defer q.mutex.Unlock()
	q.callIDSeq++
	id := q.callIDSeq
	newContext := context.WithValue(ctx, reservedRequestIDKey{}, id)
	return newContext, id
}
1198079
func (o *GetTaskDetailsParams) WithID(id int64) *GetTaskDetailsParams {
	o.SetID(id)
	return o
}
546830
func (s *PurchaseOfferingInput) SetRequestId(v string) *PurchaseOfferingInput {
	s.RequestId = &v
	return s
}
964282
func (nc *Conn) RequestWithContext(ctx context.Context, subj string, data []byte) (*Msg, error) {
	if ctx == nil {
		return nil, ErrInvalidContext
	}
	if nc == nil {
		return nil, ErrInvalidConnection
	}
	// Check whether the context is done already before making
	// the request.
	if ctx.Err() != nil {
		return nil, ctx.Err()
	}

	nc.mu.Lock()
	// If user wants the old style.
	if nc.Opts.UseOldRequestStyle {
		nc.mu.Unlock()
		return nc.oldRequestWithContext(ctx, subj, data)
	}

	// Do setup for the new style.
	if nc.respMap == nil {
		nc.initNewResp()
	}
	// Create literal Inbox and map to a chan msg.
	mch := make(chan *Msg, RequestChanLen)
	respInbox := nc.newRespInbox()
	token := respToken(respInbox)
	nc.respMap[token] = mch
	createSub := nc.respMux == nil
	ginbox := nc.respSub
	nc.mu.Unlock()

	if createSub {
		// Make sure scoped subscription is setup only once.
		var err error
		nc.respSetup.Do(func() { err = nc.createRespMux(ginbox) })
		if err != nil {
			return nil, err
		}
	}

	err := nc.PublishRequest(subj, respInbox, data)
	if err != nil {
		return nil, err
	}

	var ok bool
	var msg *Msg

	select {
	case msg, ok = <-mch:
		if !ok {
			return nil, ErrConnectionClosed
		}
	case <-ctx.Done():
		nc.mu.Lock()
		delete(nc.respMap, token)
		nc.mu.Unlock()
		return nil, ctx.Err()
	}

	return msg, nil
}
1251932
func (e *Environment) GoWithID(f func(ctx context.Context) error) {
	e.Go(func(ctx context.Context) error {
		return f(WithRequestID(ctx, e.generator.Generate()))
	})
}