forked from redpanda-data/connect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mongodb.go
39 lines (34 loc) · 1.49 KB
/
mongodb.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
package processor
import (
"github.com/dafanshu/benthos/v3/internal/impl/mongodb/client"
"github.com/dafanshu/benthos/v3/lib/util/retries"
)
// MongoDBConfig contains configuration fields for the MongoDB processor.
type MongoDBConfig struct {
MongoDB client.Config `json:",inline" yaml:",inline"`
WriteConcern client.WriteConcern `json:"write_concern" yaml:"write_concern"`
Parts []int `json:"parts" yaml:"parts"`
Operation string `json:"operation" yaml:"operation"`
FilterMap string `json:"filter_map" yaml:"filter_map"`
DocumentMap string `json:"document_map" yaml:"document_map"`
Upsert bool `json:"upsert" yaml:"upsert"`
HintMap string `json:"hint_map" yaml:"hint_map"`
RetryConfig retries.Config `json:",inline" yaml:",inline"`
JSONMarshalMode client.JSONMarshalMode `json:"json_marshal_mode" yaml:"json_marshal_mode"`
}
// NewMongoDBConfig returns a MongoDBConfig with default values.
func NewMongoDBConfig() MongoDBConfig {
rConf := retries.NewConfig()
rConf.MaxRetries = 3
rConf.Backoff.InitialInterval = "1s"
rConf.Backoff.MaxInterval = "5s"
rConf.Backoff.MaxElapsedTime = "30s"
return MongoDBConfig{
MongoDB: client.NewConfig(),
Parts: []int{},
Operation: "insert-one",
RetryConfig: rConf,
WriteConcern: client.WriteConcern{},
JSONMarshalMode: client.JSONMarshalModeCanonical,
}
}