本文整理匯總了Golang中github.com/elastic/libbeat/outputs.MothershipConfig.BulkMaxSize方法的典型用法代碼示例。如果您正苦於以下問題:Golang MothershipConfig.BulkMaxSize方法的具體用法?Golang MothershipConfig.BulkMaxSize怎麽用?Golang MothershipConfig.BulkMaxSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/elastic/libbeat/outputs.MothershipConfig
的用法示例。
在下文中一共展示了MothershipConfig.BulkMaxSize方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: NewOutput
// NewOutput instantiates a new output plugin instance publishing to elasticsearch.
func (f elasticsearchOutputPlugin) NewOutput(
beat string,
config *outputs.MothershipConfig,
topologyExpire int,
) (outputs.Outputer, error) {
// configure bulk size in config in case it is not set
if config.BulkMaxSize == nil {
bulkSize := defaultBulkSize
config.BulkMaxSize = &bulkSize
}
output := &elasticsearchOutput{}
err := output.init(beat, *config, topologyExpire)
if err != nil {
return nil, err
}
return output, nil
}
示例2: init
func (out *fileOutput) init(beat string, config *outputs.MothershipConfig, topology_expire int) error {
out.rotator.Path = config.Path
out.rotator.Name = config.Filename
if out.rotator.Name == "" {
out.rotator.Name = beat
}
logp.Info("File output base filename set to: %v", out.rotator.Name)
// disable bulk support
configDisableInt := -1
config.FlushInterval = &configDisableInt
config.BulkMaxSize = &configDisableInt
rotateeverybytes := uint64(config.RotateEveryKb) * 1024
if rotateeverybytes == 0 {
rotateeverybytes = 10 * 1024 * 1024
}
logp.Info("Rotate every bytes set to: %v", rotateeverybytes)
out.rotator.RotateEveryBytes = &rotateeverybytes
keepfiles := config.NumberOfFiles
if keepfiles == 0 {
keepfiles = 7
}
logp.Info("Number of files set to: %v", keepfiles)
out.rotator.KeepFiles = &keepfiles
err := out.rotator.CreateDirectory()
if err != nil {
return err
}
err = out.rotator.CheckIfConfigSane()
if err != nil {
return err
}
return nil
}
示例3: init
func (out *elasticsearchOutput) init(
beat string,
config outputs.MothershipConfig,
topologyExpire int,
) error {
tlsConfig, err := outputs.LoadTLSConfig(config.TLS)
if err != nil {
return err
}
// configure bulk size in config in case it is not set
if config.BulkMaxSize == nil {
bulkSize := defaultBulkSize
config.BulkMaxSize = &bulkSize
}
clients, err := mode.MakeClients(config, makeClientFactory(beat, tlsConfig, config))
if err != nil {
return err
}
timeout := elasticsearchDefaultTimeout
if config.Timeout != 0 {
timeout = time.Duration(config.Timeout) * time.Second
}
maxRetries := defaultMaxRetries
if config.Max_retries != nil {
maxRetries = *config.Max_retries
}
var waitRetry = time.Duration(1) * time.Second
var maxWaitRetry = time.Duration(60) * time.Second
var m mode.ConnectionMode
out.clients = clients
if len(clients) == 1 {
client := clients[0]
m, err = mode.NewSingleConnectionMode(client, maxRetries,
waitRetry, timeout, maxWaitRetry)
} else {
loadBalance := config.LoadBalance == nil || *config.LoadBalance
if loadBalance {
m, err = mode.NewLoadBalancerMode(clients, maxRetries,
waitRetry, timeout, maxWaitRetry)
} else {
m, err = mode.NewFailOverConnectionMode(clients, maxRetries, waitRetry, timeout)
}
}
if err != nil {
return err
}
if config.Save_topology {
err := out.EnableTTL()
if err != nil {
logp.Err("Fail to set _ttl mapping: %s", err)
// keep trying in the background
go func() {
for {
err := out.EnableTTL()
if err == nil {
break
}
logp.Err("Fail to set _ttl mapping: %s", err)
time.Sleep(5 * time.Second)
}
}()
}
}
out.TopologyExpire = 15000
if topologyExpire != 0 {
out.TopologyExpire = topologyExpire * 1000 // millisec
}
out.mode = m
if config.Index != "" {
out.index = config.Index
} else {
out.index = beat
}
return nil
}