// NewReq creates a new Req. pass cons=0 to leave consolidator undefined,
// leaving up to the caller (in graphite's case, it would cause a lookup into storage-aggregation.conf)
774838
func NewReq(query string, from, to uint32, cons consolidation.Consolidator) Req {
	return Req{
		Query: query,
		From:  from,
		To:    to,
		Cons:  cons,
	}
}
1083213
func NewRequest(q string) *Request {
	req := &Request{
		q:      q,
		Header: make(map[string][]string),
	}
	return req
}
386476
func (c *central) handleReq(b []byte) []byte {
	var resp []byte
	switch reqType, req := b[0], b[1:]; reqType {
	case attOpMtuReq:
		resp = c.handleMTU(req)
	case attOpFindInfoReq:
		resp = c.handleFindInfo(req)
	case attOpFindByTypeValueReq:
		resp = c.handleFindByTypeValue(req)
	case attOpReadByTypeReq:
		resp = c.handleReadByType(req)
	case attOpReadReq:
		resp = c.handleRead(req)
	case attOpReadBlobReq:
		resp = c.handleReadBlob(req)
	case attOpReadByGroupReq:
		resp = c.handleReadByGroup(req)
	case attOpWriteReq, attOpWriteCmd:
		resp = c.handleWrite(reqType, req)
	case attOpReadMultiReq, attOpPrepWriteReq, attOpExecWriteReq, attOpSignedWriteCmd:
		fallthrough
	default:
		resp = attErrorRsp(reqType, 0x0000, attEcodeReqNotSupp)
	}
	return resp
}
1248613
func newReqList() *requestHeaderList {
	ret := &requestHeaderList{List: map[string]([]byte){}}
	go func() {
		for {
			time.Sleep(reqListRefreshTime)
			ret.Refresh()
		}
	}()
	return ret
}
317337
func (h *Handler) NewRequest(ctx context.Context, feed *Feed) (request *Request, err error) {
	if feed == nil {
		return nil, NewError(ErrInvalidValue, "feed cannot be nil")
	}

	now := TimestampProvider.Now().Time
	request = new(Request)
	request.Header.Version = ProtocolVersion

	query := NewQueryLatest(feed, lookup.NoClue)

	feedUpdate, err := h.Lookup(ctx, query)
	if err != nil {
		if err.(*Error).code != ErrNotFound {
			return nil, err
		}
		// not finding updates means that there is a network error
		// or that the feed really does not have updates
	}

	request.Feed = *feed

	// if we already have an update, then find next epoch
	if feedUpdate != nil {
		request.Epoch = lookup.GetNextEpoch(feedUpdate.Epoch, now)
	} else {
		request.Epoch = lookup.GetFirstEpoch(now)
	}

	return request, nil
}
1015227
func (mock *HTTPMock) NewRequest(method, url string, body io.Reader) (*http.Response, error) {
	req, err := http.NewRequest(method, url, body)
	if err != nil {
		return nil, err
	}

	recorder := httptest.NewRecorder()
	mock.handler.ServeHTTP(recorder, req)
	return recorder.Result(), nil
}
1077108
func NewRequest(method, path string) *Request {
	return &Request{Method: method, Filepath: cleanPath(path),
		state: state{RWMutex: new(sync.RWMutex)}}
}
995572
func NewRequireOnce(Expression node.Node) *RequireOnce {
	return &RequireOnce{
		FreeFloating: nil,
		Expr:         Expression,
	}
}
79993
func (c *Client) NewRequest(urlStr string) (req *Request, err error) {
	req, err = newRequest(c, urlStr)
	if err != nil {
		return
	}

	c.applyRequestHeaders(req)

	return
}
156828
func New(r *NetIDRange, allocatorFactory allocator.AllocatorFactory) *Allocator {
	return &Allocator{
		netIDRange: r,
		alloc:      allocatorFactory(int(r.Size), r.String()),
	}
}
13116
func NewContext(req *Request, res *Response, f *Fibre) *Context {
	return &Context{
		fibre:    f,
		request:  req,
		response: res,
	}
}
1155140
func (rt *DefaultRequestDoer) NewRequest(method, path string,
	query *url.Values, body interface{}) (*http.Request, error) {

	b := &bytes.Buffer{}
	if body != nil {
		enc := json.NewEncoder(b)
		err := enc.Encode(body)
		if err != nil {
			return nil, err
		}
	}

	if query == nil {
		query = &url.Values{}
	}

	if q := query.Encode(); q != "" {
		path += "?" + q
	}

	req, err := http.NewRequest(method, rt.Host+path, b)
	if err != nil {
		return nil, err
	}

	req.Header.Set("Host", rt.Host)

	if body != nil {
		req.Header.Set("Content-type", "application/json")
	}

	return req, nil
}
844518
func NewRequest() *Request {
	return &Request{
		Counter:    1,
		URLStruct:  &url.URL{},
		Header:     make(http.Header),
		PathParams: make(map[string]string),
	}
}
1097315
func (co *Consolidator) Create(query string) (r *Result, created bool) {
	co.mu.Lock()
	defer co.mu.Unlock()
	if r, ok := co.queries[query]; ok {
		return r, false
	}
	r = &Result{consolidator: co, query: query}
	r.executing.Lock()
	co.queries[query] = r
	return r, true
}
81016
func New(logger log.Logger) storage.Storage {
	return &memStorage{
		clients:         make(map[string]storage.Client),
		authCodes:       make(map[string]storage.AuthCode),
		refreshTokens:   make(map[string]storage.RefreshToken),
		authReqs:        make(map[string]storage.AuthRequest),
		passwords:       make(map[string]storage.Password),
		offlineSessions: make(map[offlineSessionID]storage.OfflineSessions),
		connectors:      make(map[string]storage.Connector),
		logger:          logger,
	}
}
1354384
func (c *Codec) NewRequest(r *http.Request) rpc.CodecRequest {
	return newCodecRequest(r)
}
1109092
func NewAggregateConstructor(aggDescription string, aggFunc crossSeriesAggFunc) func() GraphiteFunc {
	return func() GraphiteFunc {
		return &FuncAggregate{agg: seriesAggregator{function: aggFunc, name: aggDescription}}
	}
}