forked from samber/go-quickwit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
62 lines (48 loc) · 1.26 KB
/
config.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package quickwit
import (
"net/http"
"time"
)
type CommitMode string
const (
Auto CommitMode = "auto"
WaitFor CommitMode = "wait_for"
Force CommitMode = "force"
)
const (
DefaultBatchWait time.Duration = 3 * time.Second
DefaultBatchBytes int = 10 * 1024 * 1024 // 10 MB
DefautCommitMode = Auto
DefaultMinBackoff time.Duration = 500 * time.Millisecond
DefaultMaxBackoff time.Duration = 5 * time.Minute
DefaultMaxRetries int = 5
DefaultTimeout time.Duration = 10 * time.Second
)
// Config describes configuration for a HTTP pusher client.
type Config struct {
URL string
Client http.Client
IndexID string
BatchWait time.Duration
BatchBytes int
Commit CommitMode
BackoffConfig BackoffConfig
Timeout time.Duration
}
// NewDefaultConfig creates a default configuration for a given Quickwit cluster.
func NewDefaultConfig(url string, indexID string) Config {
return Config{
URL: url,
Client: http.Client{},
IndexID: indexID,
BatchWait: DefaultBatchWait,
BatchBytes: DefaultBatchBytes,
Commit: DefautCommitMode,
BackoffConfig: BackoffConfig{
MinBackoff: DefaultMinBackoff,
MaxBackoff: DefaultMaxBackoff,
MaxRetries: DefaultMaxRetries,
},
Timeout: DefaultTimeout,
}
}