// NewHub creates a new hub instance. It doesn't start it.
187623
func NewHub(c EventConnections) *eventHub {
	return &eventHub{
		connections: c,
		register:    make(chan *Client),
		unregister:  make(chan *Client),
		broadcast:   make(chan Message),
	}
}
857598
func NewConnection(host string, port string) *Connection {
	return &Connection{host, port, http.DefaultClient}
}
391789
func newCluster() *cluster {
	return &cluster{
		Hasher:     &jmphasher{},
		partitionN: defaultPartitionN,
		ReplicaN:   1,

		joiningLeavingNodes: make(chan nodeAction, 10), // buffered channel
		jobs:                make(map[int64]*resizeJob),
		closing:             make(chan struct{}),
		joining:             make(chan struct{}),

		InternalClient: newNopInternalClient(),

		logger: logger.NopLogger,
	}
}
241464
func NewBusSocket() (*BusSocket, error) {
	s, err := NewSocket(AF_SP, BUS)
	return &BusSocket{s}, err
}
580904
func NewConnector(n net.Conn, h Headers) (STOMPConnector, error) {
	return Connect(n, h)
}
1120773
func NewWebsocketHub() *WebsocketHub {
	return &WebsocketHub{
		clients:          make(map[*hubSpoke]*clientHubSpoke),
		Register:         make(chan *clientHubSpoke),
		Unregister:       make(chan *hubSpoke),
		HubRelay:         make(chan hubMessage),
		newTxBuffer:      make([]*types.MempoolTx, 0, newTxBufferSize),
		bufferTickerChan: make(chan int, clientSignalSize),
		sendBufferChan:   make(chan int, clientSignalSize),
		quitWSHandler:    make(chan struct{}),
		xcChan:           make(exchangeChannel, 16),
	}
}
711096
func NewGithubIssuesLogger(name string, opts *GithubOptions) (Sender, error) {
	s := &githubLogger{
		Base: NewBase(name),
		opts: opts,
		gh:   &githubClientImpl{},
	}

	ctx := context.TODO()
	s.gh.Init(ctx, opts.Token)

	fallback := log.New(os.Stdout, "", log.LstdFlags)
	if err := s.SetErrorHandler(ErrorHandlerFromLogger(fallback)); err != nil {
		return nil, err
	}

	if err := s.SetFormatter(MakeDefaultFormatter()); err != nil {
		return nil, err
	}

	s.reset = func() {
		fallback.SetPrefix(fmt.Sprintf("[%s] [%s/%s] ", s.Name(), opts.Account, opts.Repo))
	}

	return s, nil
}
435753
func (b *BigIP) CreateBGPNeighbor(instance, name string, remoteAS int) error {
	config := &BGPNeighbor{
		Name:     name,
		RemoteAS: remoteAS,
	}

	return b.post(config, uriNet, uriRouting, uriBGP, instance, uriNeighbor)
}
547466
func NewPub(op Handler) *Pub {
	fr := Pub{
		op:       op,
		branches: newMapReact(),
		enders:   newMapReact(),
		roots:    newMapReact(),
		csignal:  make(chan bool),
	}

	return &fr
}
1291536
func (c *Client) NewEvent() *Event {
	c.ensureTransmission()
	c.ensureBuilder()
	return c.builder.NewEvent()
}
1245955
func (c *Cluster) CreateNewHost(serial string) (*Host, error) {
	serial = strings.ToLower(serial)
	hostDir := path.Join(c.baseDir, strings.ToLower(serial))
	newHost, err := createHost(serial, hostDir)
	if err != nil {
		return nil, microerror.Mask(err)
	}

	if predef, exists := c.predefinedVals[serial]; exists {
		c.logger.Log("level", "info", "message", fmt.Sprintf("found predefined values for '%s'", serial))

		if s, exists := predef["ipmiaddr"]; exists {
			newHost.IPMIAddr = net.ParseIP(s)
			c.logger.Log("level", "info", "message", fmt.Sprintf("setting IPMIAdddress for '%s': %s", serial, newHost.IPMIAddr.String()))

		}
		if s, exists := predef["internaladdr"]; exists {
			newHost.InternalAddr = net.ParseIP(s)
			c.logger.Log("level", "info", "message", fmt.Sprintf("setting internal address for '%s': %s", serial, newHost.InternalAddr.String()))

			newHost.Hostname = strings.Replace(newHost.InternalAddr.String(), ".", "-", 4)
		}
		if s, exists := predef["etcdclustertoken"]; exists {
			newHost.EtcdClusterToken = s
		}
	} else {
		c.logger.Log("level", "info", "message", fmt.Sprintf("no predefined values for '%s'", serial))
	}

	machineID := genMachineID()
	newHost.MachineID = machineID
	if newHost.InternalAddr != nil {
		newHost.Hostname = strings.Replace(newHost.InternalAddr.String(), ".", "-", 4)
	}
	c.logger.Log("level", "info", "message", fmt.Sprintf("hostname for  '%s' is %s", newHost.InternalAddr.String(), newHost.Hostname))
	newHost.Commit("updated with predefined settings")

	err = c.reindex()
	if err != nil {
		return nil, microerror.Mask(err)
	}
	return newHost, nil
}
1173313
func newHub(scheme string, vendorID uint16, productIDs []uint16, usageID uint16, endpointID int, makeDriver func(log.Logger) driver) (*Hub, error) {
	if !hid.Supported() {
		return nil, errors.New("unsupported platform")
	}
	hub := &Hub{
		scheme:     scheme,
		vendorID:   vendorID,
		productIDs: productIDs,
		usageID:    usageID,
		endpointID: endpointID,
		makeDriver: makeDriver,
		quit:       make(chan chan error),
	}
	hub.refreshWallets()
	return hub, nil
}
918474
func (s *IdentityService) CreateGithubConnector(connector services.GithubConnector) error {
	if err := connector.CheckAndSetDefaults(); err != nil {
		return trace.Wrap(err)
	}
	value, err := services.GetGithubConnectorMarshaler().Marshal(connector)
	if err != nil {
		return trace.Wrap(err)
	}
	item := backend.Item{
		Key:     backend.Key(webPrefix, connectorsPrefix, githubPrefix, connectorsPrefix, connector.GetName()),
		Value:   value,
		Expires: connector.Expiry(),
	}
	_, err = s.Create(context.TODO(), item)
	if err != nil {
		return trace.Wrap(err)
	}
	return nil
}
458293
func NewGithubConnector(name string, spec GithubConnectorSpecV3) GithubConnector {
	return &GithubConnectorV3{
		Kind:    KindGithubConnector,
		Version: V3,
		Metadata: Metadata{
			Name:      name,
			Namespace: defaults.Namespace,
		},
		Spec: spec,
	}
}
92850
func (m *MockContext) Hub() facade.Hub {
	ret := m.ctrl.Call(m, "Hub")
	ret0, _ := ret[0].(facade.Hub)
	return ret0
}
1311519
func NewWithClientInfluxDBHook(host, database string, tags []string, client influxdb.Client, batching ...bool) (hook *InfluxDBHook, err error) {
	if len(batching) == 1 && batching[0] {
		return NewInfluxDB(&Config{Host: host, Database: database, Tags: tags}, client)
	}
	return NewInfluxDB(&Config{Host: host, Database: database, Tags: tags, BatchCount: 0}, client)
}
384622
func (factory *RSSBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface {
	bee := RSSBee{
		Bee: bees.NewBee(name, factory.ID(), description, options),
	}
	bee.ReloadOptions(options)

	return &bee
}