MCPcopy Create free account
hub / github.com/GetStream/stream-go2 / New

Function New

client.go:39–56  ·  view source on GitHub ↗

New builds a new Client with the provided API key and secret. It can be configured further by passing any number of ClientOption parameters.

(key, secret string, opts ...ClientOption)

Source from the content-addressed store, hash-verified

37// New builds a new Client with the provided API key and secret. It can be
38// configured further by passing any number of ClientOption parameters.
39func New(key, secret string, opts ...ClientOption) (*Client, error) {
40 if key == "" || secret == "" {
41 return nil, errMissingCredentials
42 }
43 c := &Client{
44 key: key,
45 timeout: time.Second * 6,
46 authenticator: authenticator{secret: secret},
47 }
48 for _, opt := range opts {
49 opt(c)
50 }
51 if c.requester == nil {
52 c.requester = newRequester(c.timeout)
53 }
54 c.urlBuilder = newAPIURLBuilder(c.addr, c.region, c.version)
55 return c, nil
56}
57
58func newRequester(timeout time.Duration) Requester {
59 tr := http.DefaultTransport.(*http.Transport).Clone()

Callers 2

TestConfigFunction · 0.85
NewFromEnvFunction · 0.85

Calls 2

newRequesterFunction · 0.85
newAPIURLBuilderFunction · 0.85

Tested by 1

TestConfigFunction · 0.68