// New creates a new round robin peer list.
345733
func New(transport peer.Transport, opts ...ListOption) *List {
	cfg := defaultListConfig
	for _, o := range opts {
		o(&cfg)
	}

	plOpts := []peerlist.ListOption{
		peerlist.Capacity(cfg.capacity),
		peerlist.Seed(cfg.seed),
	}
	if !cfg.shuffle {
		plOpts = append(plOpts, peerlist.NoShuffle())
	}

	return &List{
		List: peerlist.New(
			"roundrobin",
			transport,
			newPeerRing(),
			plOpts...,
		),
	}
}
381868
func NewPeer(pid PeerIdentifier, transport peer.Transport) *Peer {
	p := &Peer{
		PeerIdentifier: pid,
		transport:      transport,
		subscribers:    make(map[peer.Subscriber]struct{}),
	}
	p.connectionStatus.Store(int32(peer.Unavailable))
	return p
}
287189
func New(c *client.Client, id string, pubKey string) (api.Key, error) {
	req := api.KeyCreateRequest{ID: id, Public: pubKey}
	body, err := json.Marshal(req)

	resBody, err := c.BasicRequest("POST", "/v1/keys/", body)

	if err != nil {
		return api.Key{}, err
	}

	key := api.Key{}
	if err = json.Unmarshal([]byte(resBody), &key); err != nil {
		return api.Key{}, err
	}

	return key, nil
}
283987
func New(local *Params, pm Payment, proto Protocol) (swap *Swap, err error) {

	swap = &Swap{
		local:   local,
		Payment: pm,
		proto:   proto,
	}

	swap.SetParams(local)

	return
}
1326284
func New(config fab.EndpointConfig, opts ...Option) (*Peer, error) {
	peer := &Peer{
		config:      config,
		commManager: &defCommManager{},
	}

	for _, opt := range opts {
		err := opt(peer)

		if err != nil {
			return nil, err
		}
	}

	if peer.processor == nil {
		// TODO: config is declaring TLS but cert & serverHostOverride is being passed-in...
		endorseRequest := peerEndorserRequest{
			target:             peer.url,
			certificate:        peer.certificate,
			serverHostOverride: peer.serverName,
			config:             peer.config,
			kap:                peer.kap,
			failFast:           peer.failFast,
			allowInsecure:      peer.inSecure,
			commManager:        peer.commManager,
		}
		processor, err := newPeerEndorser(&endorseRequest)

		if err != nil {
			return nil, err
		}
		peer.processor = processor
	}

	return peer, nil
}
1226978
func New(addr string, reqHeaders, respHeaders []string) (*Trace, error) {
	if _, err := newWriter(addr); err != nil {
		return nil, err
	}
	return &Trace{
		ReqHeaders:  reqHeaders,
		RespHeaders: respHeaders,
		Addr:        addr,
	}, nil
}
191485
func New(constructorsAndValues ...interface{}) *Psyringe {
	p := newPsyringe()
	if err := p.addErr(constructorsAndValues...); err != nil {
		panic(err)
	}
	return p
}
818662
func New(scheduler Scheduler, storage Storage, caPath string, nodes ...Node) (*Cluster, error) {
	var (
		c   Cluster
		err error
	)
	if storage == nil {
		return nil, errStorageMandatory
	}
	c.stor = storage
	c.scheduler = scheduler
	if caPath != "" {
		tlsConfig, errTLS := readTLSConfig(caPath)
		if errTLS != nil {
			return nil, errTLS
		}
		c.tlsConfig = tlsConfig
	}
	c.Healer = DefaultHealer{}
	if scheduler == nil {
		c.scheduler = &roundRobin{lastUsed: -1}
	}
	if len(nodes) > 0 {
		for _, n := range nodes {
			err = c.Register(n)
			if err != nil {
				return &c, err
			}
		}
	}
	return &c, err
}
180484
func New(dispatcher service.Dispatcher, context context.Client, channelID string, opts ...options.Opt) *PeerResolver {
	params := defaultParams(context, channelID)
	options.Apply(params, opts)

	mspID := context.Identifier().MSPID

	logger.Debugf("Creating new PreferOrg peer resolver with options: MSP ID [%s]", mspID)

	return &PeerResolver{
		params:              params,
		mspID:               mspID,
		blockHeightResolver: minblockheight.New(dispatcher, context, channelID, opts...),
	}
}
177915
func New(logger *log.Logger, shutdownCh chan struct{}, clusterInfo ManagerSerfCluster, connPoolPinger Pinger) (m *Manager) {
	m = new(Manager)
	m.logger = logger
	m.clusterInfo = clusterInfo       // can't pass *consul.Client: import cycle
	m.connPoolPinger = connPoolPinger // can't pass *consul.ConnPool: import cycle
	m.rebalanceTimer = time.NewTimer(clientRPCMinReuseDuration)
	m.shutdownCh = shutdownCh
	atomic.StoreInt32(&m.offline, 1)

	l := serverList{}
	l.servers = make([]*metadata.Server, 0)
	m.saveServerList(l)
	return m
}
492181
func New(capacity int) *PubSub {
	ps := &PubSub{make(chan cmd), capacity}
	go ps.start()
	return ps
}
481812
func New(endpoint string, transport *gohttp.Transport) *Target {
	h := Target{
		endpoint: endpoint,
		client: gohttp.Client{
			Transport: transport,
		},
		logCh: make(chan interface{}, 10000),
	}

	h.startHTTPLogger()
	return &h
}
1339906
func New(n noder.Noder) (*Frame, error) {
	children, err := n.Children()
	if err != nil {
		return nil, err
	}

	sort.Sort(sort.Reverse(byName(children)))
	return &Frame{
		stack: children,
	}, nil
}
304940
func New(n int, l int) *PriorityQueue {
	var queues = make([]chan interface{}, n)
	for i := range queues {
		queues[i] = make(chan interface{}, l)
	}
	return &PriorityQueue{
		Queues: queues,
		wakeup: make(chan struct{}, 1),
	}
}
947291
func New(ctx context.Context, next http.Handler, config config.IPWhiteList, name string) (http.Handler, error) {
	logger := middlewares.GetLogger(ctx, name, typeName)
	logger.Debug("Creating middleware")

	if len(config.SourceRange) == 0 {
		return nil, errors.New("sourceRange is empty, IPWhiteLister not created")
	}

	checker, err := ip.NewChecker(config.SourceRange)
	if err != nil {
		return nil, fmt.Errorf("cannot parse CIDR whitelist %s: %v", config.SourceRange, err)
	}

	strategy, err := config.IPStrategy.Get()
	if err != nil {
		return nil, err
	}

	logger.Debugf("Setting up IPWhiteLister with sourceRange: %s", config.SourceRange)
	return &ipWhiteLister{
		strategy:    strategy,
		whiteLister: checker,
		next:        next,
		name:        name,
	}, nil
}
916091
func New(in io.Reader, out, errOut io.Writer) *Pollster {
	return &Pollster{
		scanner: bufio.NewScanner(byteAtATimeReader{in}),
		out:     out,
		errOut:  errOut,
		in:      in,
	}
}
571799
func New(p Protocol, in io.Writer, out io.Reader) (ContainerIO, error) {
	switch p {
	case HTTP:
		return &HTTPProtocol{in, out}, nil
	case Default, Empty:
		return &DefaultProtocol{}, nil
	default:
		return nil, errInvalidProtocol
	}
}