Create limiters
This commit is contained in:
@@ -11,7 +11,10 @@ import "os"
|
|||||||
import "github.com/firestuff/automana/headers"
|
import "github.com/firestuff/automana/headers"
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
client *http.Client
|
client *http.Client
|
||||||
|
rateLimit *RateLimit
|
||||||
|
concurrencyLimitRead *ConcurrencyLimit
|
||||||
|
concurrencyLimitWrite *ConcurrencyLimit
|
||||||
}
|
}
|
||||||
|
|
||||||
type errorDetails struct {
|
type errorDetails struct {
|
||||||
@@ -34,7 +37,10 @@ type nextPage struct {
|
|||||||
|
|
||||||
func NewClient(token string) *Client {
|
func NewClient(token string) *Client {
|
||||||
c := &Client{
|
c := &Client{
|
||||||
client: &http.Client{},
|
client: &http.Client{},
|
||||||
|
rateLimit: NewRateLimitPerMinute(1500, 1500),
|
||||||
|
concurrencyLimitRead: NewConcurrencyLimit(50),
|
||||||
|
concurrencyLimitWrite: NewConcurrencyLimit(15),
|
||||||
}
|
}
|
||||||
|
|
||||||
hdrs := headers.NewHeaders(c.client)
|
hdrs := headers.NewHeaders(c.client)
|
||||||
|
|||||||
@@ -20,8 +20,9 @@ func (c *Client) InWorkspace(name string) (*WorkspaceClient, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return &WorkspaceClient{
|
return &WorkspaceClient{
|
||||||
client: c,
|
client: c,
|
||||||
workspace: wrk,
|
workspace: wrk,
|
||||||
|
rateLimitSearch: NewRateLimitPerMinute(60, 60),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package client
|
package client
|
||||||
|
|
||||||
type WorkspaceClient struct {
|
type WorkspaceClient struct {
|
||||||
client *Client
|
client *Client
|
||||||
workspace *Workspace
|
workspace *Workspace
|
||||||
|
rateLimitSearch *RateLimit
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user