-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoption.go
More file actions
39 lines (33 loc) · 1.06 KB
/
option.go
File metadata and controls
39 lines (33 loc) · 1.06 KB
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
36
37
38
39
package captchasolve
import captchatoolsgo "github.com/Matthew17-21/Captcha-Tools/captchatools-go"
type ClientOption func(c *config)
// WithMaxCapacity sets the maximum number of tokens to be saved in the underlying data structure
func WithMaxCapacity(i int) ClientOption {
return func(c *config) {
c.maxCapacity = i
}
}
// WithHarvester uses a given captcha harvester in the client
func WithHarvester(h captchatoolsgo.Harvester) ClientOption {
return func(c *config) {
c.harvesters = append(c.harvesters, h)
}
}
// WithMaxGoroutines sets the max number of goroutines to be used while getting captcha tokens
func WithMaxGoroutines(max int) ClientOption {
// Make sure it is a valid amount
if max < 1 {
max = 1
}
return func(c *config) {
c.maxCapacity = max
}
}
// WithLogger is a functional option for configuring a client with a custom logger.
// It accepts a Logger instance and returns a ClientOption function that sets the
// provided Logger in the client's configuration.
func WithLogger(l Logger) ClientOption {
return func(c *config) {
c.logger = l
}
}