// NewChannelClient constructs and returns a Client that can send
// directly into a span receiver channel. It provides an alternative
// interface to NewBackendClient for constructing internal and
// test-only clients.
491532
func NewChannelClient(spanChan chan<- *ssf.SSFSpan, opts ...ClientParam) (*Client, error) {
	cl := &Client{}
	cl.flushBackends = []flushNotifier{}
	cl.spans = spanChan

	for _, opt := range opts {
		if err := opt(cl); err != nil {
			return nil, err
		}
	}

	ctx := context.Background()
	ctx, cl.cancel = context.WithCancel(ctx)

	cl.run(ctx)
	return cl, nil
}
1130339
func NewClient(url string, protocols []string) (*Client, error) {

	dialer := &websocket.Dialer{
		Proxy:             http.ProxyFromEnvironment,
		Subprotocols:      protocols,
		EnableCompression: true,
	}

	con, _, err := dialer.Dial(url, nil)
	if err != nil {
		return nil, err
	}

	return &Client{con}, nil

}
567370
func NewClient(addrStr string, opts ...ClientParam) (*Client, error) {
	n, err := crand.Int(crand.Reader, big.NewInt(math.MaxInt64))
	if err != nil {
		return nil, err
	}
	rand.Seed(n.Int64())

	addr, err := protocol.ResolveAddr(addrStr)
	if err != nil {
		return nil, err
	}
	cl := &Client{}
	cl.backendParams = &backendParams{}
	cl.backendParams.addr = addr
	cl.cap = DefaultCapacity
	cl.nBackends = DefaultParallelism
	for _, opt := range opts {
		if err = opt(cl); err != nil {
			return nil, err
		}
	}
	ch := make(chan *recordOp, cl.cap)
	cl.records = ch

	var ctx context.Context
	ctx, cl.cancel = context.WithCancel(context.Background())

	fb := []flushNotifier{}
	for i := uint(0); i < cl.nBackends; i++ {
		switch addr := addr.(type) {
		case *net.UDPAddr:
			be := &packetBackend{backendParams: *cl.backendParams}
			fb = append(fb, newFlushNofifier(be))
		case *net.UnixAddr:
			be := &streamBackend{backendParams: *cl.backendParams}
			fb = append(fb, newFlushNofifier(be))
		default:
			return nil, fmt.Errorf("can not connect to %v addresses", addr.Network())
		}
	}
	cl.flushBackends = fb
	cl.run(ctx)

	return cl, nil
}
1041127
func NewClient(consumerKey string, consumerSecret string) *Client {
	c := Client{}
	c.SetConsumer(consumerKey, consumerSecret)
	return &c
}
86752
func NewClient(accessKeyId, accessKeySecret string) *Client {
	return &Client{
		AccessKeyId:     accessKeyId,
		AccessKeySecret: accessKeySecret,
		endpoint:        CSDefaultEndpoint,
		Version:         CSAPIVersion,
		httpClient:      &http.Client{},
	}
}
495408
func NewClient() *Client {
	c := &Client{
		Pods:   make(map[string]*client.Pod),
		events: make(chan watch.Event),
	}

	// broadcast events to watchers
	go func() {
		for e := range c.events {
			for _, w := range c.watchers {
				w.results <- e
			}
		}
	}()

	return c
}
1179008
func NewClient(appID, apiKey string) *Client {
	return NewClientWithConfig(
		Configuration{
			AppID:  appID,
			APIKey: apiKey,
		},
	)
}
1208948
func NewClient(apikey string) *Client {
	c := &Client{}
	c.Client = http.DefaultClient
	c.apiKey = apikey
	c.baseURL = defaultBaseURL
	c.Team = &TeamService{client: c}
	c.Stats = &StatsService{client: c}
	c.Post = &PostService{client: c}
	c.Comment = &CommentService{client: c}
	c.Members = &MembersService{client: c}

	return c
}
396656
func NewClient(config *triton.ClientConfig) (*ServiceGroupClient, error) {
	// TODO: Utilize config interface within the function itself
	client, err := client.New(
		config.TritonURL,
		config.MantaURL,
		config.AccountName,
		config.Signers...,
	)
	if err != nil {
		return nil, err
	}
	return newServiceGroupClient(client), nil
}
629550
func NewClient(p *Pool) *Client {
	return &Client{p: p, sent: make(chan *bytes.Buffer, p.cnt)}
}
1111977
func NewClient(opts ...ClientOpt) *Client {
	c := &Client{
		run:          run,
		declarations: make([]Declaration, 0),
		consumers:    make(map[*Consumer]struct{}),
		publishers:   make(map[*Publisher]struct{}),
		errs:         make(chan error, 100),
		blocking:     make(chan amqp.Blocking, 10),
	}

	for _, o := range opts {
		o(c)
	}
	return c
}
863965
func NewClient(conf ClientConfig) (*Client, error) {
	if conf.SampleRate == 0 {
		conf.SampleRate = defaultSampleRate
	}
	if conf.APIHost == "" {
		conf.APIHost = defaultAPIHost
	}
	if conf.Dataset == "" {
		conf.Dataset = defaultDataset
	}

	c := &Client{
		logger: conf.Logger,
	}
	c.ensureLogger()

	if conf.Transmission == nil {
		c.transmission = &transmission.Honeycomb{
			MaxBatchSize:         DefaultMaxBatchSize,
			BatchTimeout:         DefaultBatchTimeout,
			MaxConcurrentBatches: DefaultMaxConcurrentBatches,
			PendingWorkCapacity:  DefaultPendingWorkCapacity,
			UserAgentAddition:    UserAgentAddition,
			Logger:               c.logger,
			Metrics:              sd,
		}
	} else {
		c.transmission = conf.Transmission
	}
	if err := c.transmission.Start(); err != nil {
		c.logger.Printf("transmission client failed to start: %s", err.Error())
		return nil, err
	}

	c.builder = &Builder{
		WriteKey:   conf.APIKey,
		Dataset:    conf.Dataset,
		SampleRate: conf.SampleRate,
		APIHost:    conf.APIHost,
		dynFields:  make([]dynamicField, 0, 0),
		fieldHolder: fieldHolder{
			data: make(map[string]interface{}),
		},
		client: c,
	}

	return c, nil
}
57445
func NewChannel(clientProvider context.ClientProvider, channelID string) (*Channel, error) {

	client, err := clientProvider()
	if err != nil {
		return nil, errors.WithMessage(err, "failed to get client context to create channel client")
	}

	channelService, err := client.ChannelProvider().ChannelService(client, channelID)
	if err != nil {
		return nil, errors.WithMessage(err, "failed to get channel service to create channel client")
	}

	channel := &Channel{
		Client:         client,
		channelService: channelService,
		channelID:      channelID,
		metrics:        client.GetMetrics(),
	}
	if pi, ok := channelService.(serviceInit); ok {
		if err := pi.Initialize(channel); err != nil {
			return nil, err
		}
	}
	return channel, nil
}
563137
func NewClient(rootPath string) *Client {
	client := &Client{
		RootPath:    rootPath,
		NodeVersion: DefaultNodeVersion,
		NpmVersion:  DefaultNpmVersion,
	}

	return client
}
631840
func NewClient(dialTimeout time.Duration, allowV2 bool) Client {
	return &client{
		dialTimeout: dialTimeout,
		connections: make(map[string]*connection),
		allowV2:     allowV2,
	}
}
835790
func NewClient(url string) *Client {
	return &Client{
		URL:    url,
		client: http.DefaultClient,
	}
}
1089051
func NewClient() (*Client, error) {
	c, err := neptulon.NewConn()
	if err != nil {
		return nil, err
	}

	r := middleware.NewRouter()
	c.Middleware(r)

	return &Client{
		ID:      c.ID,
		Session: c.Session,
		conn:    c,
		router:  r,
	}, nil
}