// NewClient returns a new Hook with the given configuration using the slack.Client c.
// It ensures that the cfg is valid by calling SetConfigDefaults on the cfg.
358695
func NewClient(cfg Config, client slack.Client) *Hook {
	SetConfigDefaults(&cfg)

	c := &Hook{Config: cfg, client: client}
	if cfg.Limit != 0 {
		c.limiter = rate.NewLimiter(cfg.Limit, cfg.Burst)
	}

	return c
}
559543
func NewClient(host string, port int) (client *Client, err error) {
	client = new(Client)
	client.Host = host
	client.Port = port
	client.Connection, err = net.Dial("tcp", fmt.Sprintf("%v:%v", client.Host, client.Port))
	return
}
710920
func (a Authenticator) NewClient(token *oauth2.Token) Client {
	client := a.config.Client(a.context, token)
	return Client{
		http:    client,
		baseURL: baseAddress,
	}
}
1047449
func NewClient(config Config) *Client {
	userAgent := fmt.Sprintf("%s/%s (%s; %s %s)",
		config.BinaryName(),
		config.BinaryVersion(),
		runtime.Version(),
		runtime.GOARCH,
		runtime.GOOS,
	)

	client := Client{
		config: config,

		connection: NewConnection(config.SkipSSLValidation(), config.UAADisableKeepAlives(), config.DialTimeout()),
		userAgent:  userAgent,
	}
	client.WrapConnection(NewErrorWrapper())

	return &client
}
6023
func NewClient(name string, b func(...client.Option) client.Client) Option {
	return func(o *Options) {
		o.Clients[name] = b
	}
}
569154
func NewClient(cfg *Config) (*Client, error) {
	pk, err := PrivateKeyFromString([]byte(cfg.Key))
	if err != nil {
		return nil, err
	}

	baseUrl, _ := url.Parse(cfg.BaseURL)

	tr := &http.Transport{
		Proxy: http.ProxyFromEnvironment,
		Dial: (&net.Dialer{
			Timeout:   30 * time.Second,
			KeepAlive: 30 * time.Second,
		}).Dial,
		TLSClientConfig:     &tls.Config{InsecureSkipVerify: cfg.SkipSSL},
		TLSHandshakeTimeout: 10 * time.Second,
	}

	c := &Client{
		Auth: &AuthConfig{
			PrivateKey: pk,
			ClientName: cfg.Name,
		},
		client: &http.Client{
			Transport: tr,
			Timeout:   cfg.Timeout * time.Second,
		},
		BaseURL: baseUrl,
	}
	c.ACLs = &ACLService{client: c}
	c.Clients = &ApiClientService{client: c}
	c.Cookbooks = &CookbookService{client: c}
	c.DataBags = &DataBagService{client: c}
	c.Environments = &EnvironmentService{client: c}
	c.Nodes = &NodeService{client: c}
	c.Principals = &PrincipalService{client: c}
	c.Roles = &RoleService{client: c}
	c.Sandboxes = &SandboxService{client: c}
	c.Search = &SearchService{client: c}
	return c, nil
}
1126099
func NewClient() (*Client, error) {
	cc := ClientConfig{
		ChunkSize:   1420,
		Compression: COMP_GZIP,
	}
	return NewClientWithConfig(cc)
}
967847
func NewClient(opts ClientOptions) (*Client, error) {
	err := opts.ensure()
	if err != nil {
		return nil, err
	}

	return &Client{
		logger: log.Get(PkgName),
		opts:   opts,
	}, nil
}
100165
func NewClient(cfg *Config) (*Client, error) {
	c, err := NewMiniClient(
		&MiniConfig{
			Logplex:    cfg.Logplex,
			HTTPClient: cfg.HTTPClient,
		})

	if err != nil {
		return nil, err
	}

	m := Client{
		c:                  c,
		bucket:             make(chan struct{}),
		requestSizeTrigger: cfg.RequestSizeTrigger,
	}

	// Handle determining m.timeTrigger.  This complexity seems
	// reasonable to allow the user to get some input checking
	// (negative Periods) and to get TimeTriggerImmediate by
	// passing a zero-duration period (TimeTriggerImmediate is
	// still useful for internal bookkeeping).
	switch cfg.TimeTrigger {
	case TimeTriggerPeriodic:
		if cfg.Period < 0 {
			return nil, errors.New(
				"logplexc.Client: negative target " +
					"latency not allowed")
		} else if cfg.Period == 0 {
			// Rewrite a zero-duration period into an
			// immediate flush.
			m.timeTrigger = TimeTriggerImmediate
		} else if cfg.Period > 0 {
			m.timeTrigger = TimeTriggerPeriodic
		} else {
			panic("bug")
		}
	default:
		m.timeTrigger = cfg.TimeTrigger
	}

	// Supply tokens to do work with bounded concurrency.
	m.bucketDepth = cfg.Concurrency
	go func() {
		for i := 0; i < m.bucketDepth; i++ {
			m.bucket <- struct{}{}
		}
	}()

	// Set up the time-based log flushing, if requested.
	if m.timeTrigger == TimeTriggerPeriodic {
		m.ticker = time.NewTicker(cfg.Period)
		m.tickerShutdown = make(chan struct{})

		go func() {
			for {
				// Wait for a while to do work, or to
				// exit when the ticker is stopped
				// when Close is called on the client.
				select {
				case <-m.ticker.C:
					m.maybeWork()
				case <-m.tickerShutdown:
					return
				}
			}
		}()
	}

	return &m, nil
}
779954
func NewClient(opts ClientOpts) *Client {
	if opts.HTTPClient == nil {
		opts.HTTPClient = &http.Client{}
	}

	return &Client{
		token:      opts.Token,
		baseURL:    opts.BaseURL,
		httpClient: opts.HTTPClient,
		userAgent:  opts.UserAgent,
	}
}
520756
func NewClient(opts ...Option) *Client {
	client := Client{
		timeout:    defaultHTTPTimeout,
		retryCount: defaultRetryCount,
		retrier:    heimdall.NewNoRetrier(),
	}

	for _, opt := range opts {
		opt(&client)
	}

	if client.client == nil {
		client.client = &http.Client{
			Timeout: client.timeout,
		}
	}

	return &client
}
563137
func NewClient(rootPath string) *Client {
	client := &Client{
		RootPath:    rootPath,
		NodeVersion: DefaultNodeVersion,
		NpmVersion:  DefaultNpmVersion,
	}

	return client
}
409127
func NewClient(cfg *config.Config) *Client {
	rt := &apiRoundTripper{
		DefaultRequestDoer: registry.DefaultRequestDoer{
			Client: &http.Client{
				Transport: newTransport(cfg),

				// The client can trust the daemon to do the right thing and
				// cancel appropriately. Therefore, we only care about a
				// connection timeout, not a request timeout.
				Timeout: 0,
			},
			Host: "http://localhost",
		},
	}

	c := &Client{Client: *registry.NewClientWithRoundTripper(rt)}

	c.Users = newUsersClient(c.Client.Users, rt)
	c.Machines = newMachinesClient(c.Client.Machines, rt)
	c.KeyPairs = newKeyPairsClient(c.Client.KeyPairs, rt)
	c.OrgInvites = newOrgInvitesClient(c.Client.OrgInvites, rt)
	c.Version = newVersionClient(c.Client.Version, rt)

	c.Session = &SessionClient{client: rt}
	c.Credentials = &CredentialsClient{client: rt}
	c.Worklog = &WorklogClient{client: rt}
	c.Updates = &UpdatesClient{client: rt}

	return c
}
4909
func NewClient(params ClientParams) Client {
	return newClient(params.ServiceName, params.ClientConfig, params.Options...)
}
1025196
func NewClient(cfg *Configuration, httpClient *http.Client) *Client {

	httpClient = generateHttpClient(cfg, httpClient)

	baseURL, _ := url.Parse(cfg.Server)

	c := &Client{
		client: httpClient,
		params: &ClientParameters{
			BaseURL:   baseURL,
			UserAgent: userAgent,
			Username:  cfg.Username,
			Password:  cfg.Password,
		},
		Log: logrus.New(),
	}

	c.common.client = c
	c.common.log = c.Log

	attachServices(c)

	SetupLogging(c.Log)

	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
}
882170
func newClient(config Config, hosts []string) *Client {

	if config.ConnectionsPerHost <= 0 {
		config.ConnectionsPerHost = 5
	}

	if config.Timeout <= 0 {
		config.Timeout = 5 * time.Second
	}

	if config.User == "" {
		config.User = "anonymous"
	}

	if config.Password == "" {
		config.Password = "anonymous"
	}

	if config.ServerLocation == nil {
		config.ServerLocation = time.UTC
	}

	if config.ActiveListenAddr == "" {
		config.ActiveListenAddr = ":0"
	}

	return &Client{
		config:          config,
		freeConnCh:      make(chan *persistentConn, len(hosts)*config.ConnectionsPerHost),
		t0:              time.Now(),
		hosts:           hosts,
		allCons:         make(map[int]*persistentConn),
		numConnsPerHost: make(map[string]int),
	}
}