NewConfig returns a new configuration instance with sane defaults.
()
| 545 | |
| 546 | // NewConfig returns a new configuration instance with sane defaults. |
| 547 | func NewConfig() *Config { |
| 548 | c := &Config{} |
| 549 | |
| 550 | c.Admin.Retry.Max = 5 |
| 551 | c.Admin.Retry.Backoff = 100 * time.Millisecond |
| 552 | c.Admin.Timeout = 3 * time.Second |
| 553 | |
| 554 | c.Net.MaxOpenRequests = 5 |
| 555 | c.Net.DialTimeout = 30 * time.Second |
| 556 | c.Net.ReadTimeout = 30 * time.Second |
| 557 | c.Net.WriteTimeout = 30 * time.Second |
| 558 | c.Net.SASL.Handshake = true |
| 559 | c.Net.SASL.Version = SASLHandshakeV1 |
| 560 | |
| 561 | c.Metadata.Retry.Max = 3 |
| 562 | c.Metadata.Retry.Backoff = 250 * time.Millisecond |
| 563 | c.Metadata.RefreshFrequency = defaultMetadataRefreshFrequency |
| 564 | c.Metadata.Full = true |
| 565 | c.Metadata.AllowAutoTopicCreation = true |
| 566 | c.Metadata.SingleFlight = true |
| 567 | |
| 568 | c.Producer.MaxMessageBytes = 1024 * 1024 |
| 569 | c.Producer.RequiredAcks = WaitForLocal |
| 570 | c.Producer.Timeout = 10 * time.Second |
| 571 | c.Producer.Partitioner = NewHashPartitioner |
| 572 | c.Producer.Retry.Max = 3 |
| 573 | c.Producer.Retry.Backoff = 100 * time.Millisecond |
| 574 | c.Producer.Return.Errors = true |
| 575 | c.Producer.CompressionLevel = CompressionLevelDefault |
| 576 | |
| 577 | c.Producer.Transaction.Timeout = 1 * time.Minute |
| 578 | c.Producer.Transaction.Retry.Max = 50 |
| 579 | c.Producer.Transaction.Retry.Backoff = 100 * time.Millisecond |
| 580 | |
| 581 | c.Consumer.Fetch.Min = 1 |
| 582 | c.Consumer.Fetch.Default = 1024 * 1024 |
| 583 | c.Consumer.Fetch.MaxBytes = 50 * 1024 * 1024 |
| 584 | c.Consumer.Retry.Backoff = 2 * time.Second |
| 585 | c.Consumer.MaxWaitTime = 500 * time.Millisecond |
| 586 | c.Consumer.MaxProcessingTime = 100 * time.Millisecond |
| 587 | c.Consumer.Return.Errors = false |
| 588 | c.Consumer.Offsets.AutoCommit.Enable = true |
| 589 | c.Consumer.Offsets.AutoCommit.Interval = 1 * time.Second |
| 590 | c.Consumer.Offsets.Initial = OffsetNewest |
| 591 | c.Consumer.Offsets.Retry.Max = 3 |
| 592 | |
| 593 | c.Consumer.Group.Session.Timeout = 10 * time.Second |
| 594 | c.Consumer.Group.Heartbeat.Interval = 3 * time.Second |
| 595 | c.Consumer.Group.Rebalance.GroupStrategies = []BalanceStrategy{NewBalanceStrategyRange()} |
| 596 | c.Consumer.Group.Rebalance.Timeout = 60 * time.Second |
| 597 | c.Consumer.Group.Rebalance.Retry.Max = 4 |
| 598 | c.Consumer.Group.Rebalance.Retry.Backoff = 2 * time.Second |
| 599 | c.Consumer.Group.ResetInvalidOffsets = true |
| 600 | |
| 601 | c.ClientID = defaultClientID |
| 602 | c.ChannelBufferSize = 256 |
| 603 | c.ApiVersionsRequest = true |
| 604 | c.Version = DefaultVersion |