github.com/Jeffail/benthos/v3@v3.65.0/lib/output/mongodb.go (about)

     1  package output
     2  
     3  import (
     4  	"github.com/Jeffail/benthos/v3/internal/impl/mongodb/client"
     5  	"github.com/Jeffail/benthos/v3/lib/message/batch"
     6  	"github.com/Jeffail/benthos/v3/lib/util/retries"
     7  )
     8  
     9  // MongoDBConfig contains config fields for the MongoDB output type.
    10  type MongoDBConfig struct {
    11  	MongoConfig client.Config `json:",inline" yaml:",inline"`
    12  
    13  	Operation    string              `json:"operation" yaml:"operation"`
    14  	WriteConcern client.WriteConcern `json:"write_concern" yaml:"write_concern"`
    15  
    16  	FilterMap   string `json:"filter_map" yaml:"filter_map"`
    17  	DocumentMap string `json:"document_map" yaml:"document_map"`
    18  	HintMap     string `json:"hint_map" yaml:"hint_map"`
    19  
    20  	// DeleteEmptyValue bool `json:"delete_empty_value" yaml:"delete_empty_value"`
    21  	Upsert      bool               `json:"upsert" yaml:"upsert"`
    22  	MaxInFlight int                `json:"max_in_flight" yaml:"max_in_flight"`
    23  	RetryConfig retries.Config     `json:",inline" yaml:",inline"`
    24  	Batching    batch.PolicyConfig `json:"batching" yaml:"batching"`
    25  }
    26  
    27  // NewMongoDBConfig creates a MongoDB populated with default values.
    28  func NewMongoDBConfig() MongoDBConfig {
    29  	rConf := retries.NewConfig()
    30  	rConf.MaxRetries = 3
    31  	rConf.Backoff.InitialInterval = "1s"
    32  	rConf.Backoff.MaxInterval = "5s"
    33  	rConf.Backoff.MaxElapsedTime = "30s"
    34  
    35  	return MongoDBConfig{
    36  		MongoConfig:  client.NewConfig(),
    37  		Operation:    "update-one",
    38  		MaxInFlight:  1,
    39  		RetryConfig:  rConf,
    40  		Batching:     batch.NewPolicyConfig(),
    41  		WriteConcern: client.WriteConcern{},
    42  	}
    43  }