// NewCookieMatcher creates a new cookie matcher. The cookie value will
// be randomly generated using the functions from the standard library.
541607
func NewCookieMatcher(j CookieJar) *CookieMatcher {
	var cookies uint64

	// The default random generator does not allow to create unsigned
	// 64-bit integers, therefore, we will glue that type from the
	// two 32-bit pieces.
	cookiesLow := rand.Uint32()
	cookiesHigh := rand.Uint32()

	cookies = (uint64(cookiesHigh) << 32) | uint64(cookiesLow)

	// Set the generated cookies to the given cookie jar and also
	// put this value to the matcher.
	j.SetCookies(cookies)
	return &CookieMatcher{cookies, CookieReaderOf(j)}
}
670869
func CookiesHandler(w http.ResponseWriter, r *http.Request) {
	if err := writeJSON(w, cookiesResponse{getCookies(r.Cookies())}); err != nil {
		writeErrorJSON(w, errors.Wrap(err, "failed to write json"))
	}
}
747400
func NewMockInstanceBroker(ctrl *gomock.Controller) *MockInstanceBroker {
	mock := &MockInstanceBroker{ctrl: ctrl}
	mock.recorder = &MockInstanceBrokerMockRecorder{mock}
	return mock
}
1222347
func NewMatcher(match string, matchType MatchType, log Log) Matcher {
	return Matcher{match: match, matchType: matchType, log: log}
}
773500
func NewConsumer(cfg *config.VentConfig, log *logger.Logger, eventChannel chan types.EventData) *Consumer {
	return &Consumer{
		Config:        cfg,
		Log:           log,
		Closing:       false,
		EventsChannel: eventChannel,
	}
}
1186577
func newConfigWatcher(
	keys []string, cache *hashCache, hub *pubsub.SimpleHub, topic string, res *Resident,
) *ConfigWatcher {
	sort.Strings(keys)

	w := &ConfigWatcher{
		notifyWatcherBase: newNotifyWatcherBase(),

		keys: keys,
		hash: cache.getHash(keys),
	}

	deregister := res.registerWorker(w)
	unsub := hub.Subscribe(topic, w.configChanged)
	w.tomb.Go(func() error {
		<-w.tomb.Dying()
		unsub()
		deregister()
		return nil
	})

	return w
}
444720
func NewHandler(cfg Config) (*Handler, error) {
	if err := cfg.CheckAndSetDefaults(); err != nil {
		return nil, trace.Wrap(err)
	}

	h := &Handler{
		Entry: log.WithFields(log.Fields{
			trace.Component: teleport.Component(teleport.SchemeFile),
		}),
		Config: cfg,
	}
	return h, nil
}
964691
func NewSimpleCookieMapper(appName string) CookieMapper {
	result := &SimpleCookieMapper{
		cook: fmt.Sprintf(SESSION_COOKIE, appName),
	}
	return result
}
305965
func NewWorker(config Config) (worker.Worker, error) {
	if err := config.Validate(); err != nil {
		return nil, errors.Trace(err)
	}
	u := &updaterWorker{
		config: config,
	}
	err := catacomb.Invoke(catacomb.Plan{
		Site: &u.catacomb,
		Work: u.loop,
	})
	if err != nil {
		return nil, errors.Trace(err)
	}
	return u, nil
}
1368278
func NewEqualMatcher(name, value string) Matcher {
	return &EqualMatcher{name: name, value: value}
}
1066648
func NewCookieManagerOptions(store Store, o *CookieMngrOptions) Manager {
	m := &CookieManager{
		store:            store,
		cookieSecure:     !o.AllowHTTP,
		sessIDCookieName: o.SessIDCookieName,
		cookiePath:       o.CookiePath,
	}

	if m.sessIDCookieName == "" {
		m.sessIDCookieName = "sessid"
	}
	if o.CookieMaxAge == 0 {
		m.cookieMaxAgeSec = 30 * 24 * 60 * 60 // 30 days max age
	} else {
		m.cookieMaxAgeSec = int(o.CookieMaxAge.Seconds())
	}
	if m.cookiePath == "" {
		m.cookiePath = "/"
	}

	return m
}
860060
func NewMockTransactional(ctrl *gomock.Controller) *MockTransactional {
	mock := &MockTransactional{ctrl: ctrl}
	mock.recorder = &MockTransactionalMockRecorder{mock}
	return mock
}
1067565
func NewHandlerSwitcher(newHandler http.Handler) (hs *HTTPHandlerSwitcher) {
	return &HTTPHandlerSwitcher{
		handler: safe.New(newHandler),
	}
}
822586
func NewKafkaLogEmitter(config *KafkaLogEmitterConfig) (*KafkaLogEmitter, error) {
	encoder := kafkaavro.NewKafkaAvroEncoder(config.SchemaRegistryUrl)
	connector, err := siesta.NewDefaultConnector(config.ConnectorConfig)
	if err != nil {
		return nil, err
	}
	emitter := &KafkaLogEmitter{
		config:   config,
		producer: producer.NewKafkaProducer(config.ProducerConfig, producer.ByteSerializer, encoder.Encode, connector),
	}

	return emitter, nil
}
655772
func NewConsumer(s *SQSService, handler MessageHandlerFunc) *Consumer {
	return &Consumer{
		s:                              s,
		handler:                        handler,
		delayAfterReceiveError:         defaultDelayAfterReceiveError,
		WaitSeconds:                    defaultReceiveMessageWaitSeconds,
		ReceiveVisibilityTimoutSeconds: defaultReceiveVisibilityTimeoutSeconds,
		Logger: NoopLogger,

		ExtendVisibilityTimeoutBySeconds: defaultExtendVisibilityBySeconds,
		ExtendVisibilityTimeoutEvery:     defaultExtendVisibilityEvery,
		DeleteMessageAccumulatorTimeout:  defaultDeleteAccumulatorTimeout,
		DeleteMessageDrainTimeout:        defaultDeleteMessageDrainTimeout,
	}
}
154838
func NewClient(requrl string, transport http.RoundTripper) (*Client, error) {
	if transport == nil {
		transport = http.DefaultTransport
	}

	httpClient := &http.Client{Transport: transport}

	jar, err := cookiejar.New(nil)

	if err != nil {
		return nil, err
	}

	u, err := url.Parse(requrl)

	if err != nil {
		return nil, err
	}

	codec := clientCodec{
		url:        u,
		httpClient: httpClient,
		close:      make(chan uint64),
		ready:      make(chan uint64),
		responses:  make(map[uint64]*http.Response),
		cookies:    jar,
	}

	return &Client{rpc.NewClientWithCodec(&codec)}, nil
}
1004395
func NewNKeeper(n int) *NKeeper {
	k := NKeeper{make(Heap, 1, n)}
	k.Heap[0].Dist = inf
	return &k
}