@@ -6,25 +6,23 @@ import (
66 "fmt"
77 "time"
88
9+ "github.com/cloudquery/plugin-sdk/v4/configtype"
910 "github.com/meilisearch/meilisearch-go"
1011 "github.com/valyala/fasthttp"
1112)
1213
13- const (
14- defaultBatchSize = 1000
15- defaultBatchSizeBytes = 4 * 1024 * 1024
16- )
17-
1814type Spec struct {
1915 // required
20- Host string `json:"host,omitempty"`
21- APIKey string `json:"api_key,omitempty"`
22- BatchSize int `json:"batch_size,omitempty"`
23- BatchSizeBytes int `json:"batch_size_bytes,omitempty"`
16+ Host string `json:"host,omitempty"`
17+ APIKey string `json:"api_key,omitempty"`
2418
2519 // optional
2620 Timeout time.Duration `json:"timeout,omitempty"`
2721 CACert string `json:"ca_cert,omitempty"`
22+
23+ BatchSize int `json:"batch_size,omitempty"`
24+ BatchSizeBytes int `json:"batch_size_bytes,omitempty"`
25+ BatchTimeout * configtype.Duration `json:"batch_timeout,omitempty"`
2826}
2927
3028func (s * Spec ) validate () error {
@@ -42,11 +40,18 @@ func (s *Spec) setDefaults() {
4240 if s .Timeout == 0 {
4341 s .Timeout = 5 * time .Minute
4442 }
43+
4544 if s .BatchSize == 0 {
46- s .BatchSize = defaultBatchSize
45+ s .BatchSize = 1000 // 1K
4746 }
47+
4848 if s .BatchSizeBytes == 0 {
49- s .BatchSizeBytes = defaultBatchSizeBytes
49+ s .BatchSizeBytes = 4 << 20 // 4 MiB
50+ }
51+
52+ if s .BatchTimeout == nil {
53+ d := configtype .NewDuration (20 * time .Second ) // 20s
54+ s .BatchTimeout = & d
5055 }
5156}
5257
0 commit comments