forked from opus-domini/fast-shot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.go
35 lines (29 loc) · 1.06 KB
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package fastshot
// ClientBuilder serves as the main entry point for configuring HTTP clients.
type ClientBuilder struct {
client Client
}
// NewClient initializes a new ClientBuilder with a given baseURL.
func NewClient(baseURL string) *ClientBuilder {
return &ClientBuilder{
client: newClientConfigBase(baseURL),
}
}
// NewClientLoadBalancer initializes a new ClientBuilder with a given baseURLs.
func NewClientLoadBalancer(baseURLs []string) *ClientBuilder {
return &ClientBuilder{
client: newBalancedClientConfigBase(baseURLs),
}
}
// DefaultClient initializes a new default ClientConfig with a given baseURL.
func DefaultClient(baseURL string) ClientHttpMethods {
return NewClient(baseURL).Build()
}
// DefaultClientLoadBalancer initializes a new default ClientConfig with a given baseURLs.
func DefaultClientLoadBalancer(baseURLs []string) ClientHttpMethods {
return NewClientLoadBalancer(baseURLs).Build()
}
// Build finalizes the ClientBuilder configurations and returns a new ClientConfig.
func (b *ClientBuilder) Build() ClientHttpMethods {
return b.client
}