options.go 782 B

12345678910111213141516171819202122232425262728293031323334
  1. package asynczap
  2. import "time"
  3. const (
  4. defaultMaxMemoryUsage = 1 << 26 // 64MB
  5. defaultWriteBufferSize = 1 << 20 // 1MB
  6. defaultFlushInterval = time.Millisecond * 100
  7. )
  8. type Options struct {
  9. // MaxMemoryUsage is maximum amount of memory that will be used by in-flight log records.
  10. MaxMemoryUsage int
  11. // WriteBufferSize specifies size of the buffer used for writes to underlying file.
  12. WriteBufferSize int
  13. // FlushInterval specifies how often background goroutine would wake up.
  14. FlushInterval time.Duration
  15. }
  16. func (o *Options) setDefault() {
  17. if o.MaxMemoryUsage == 0 {
  18. o.MaxMemoryUsage = defaultMaxMemoryUsage
  19. }
  20. if o.WriteBufferSize == 0 {
  21. o.WriteBufferSize = defaultWriteBufferSize
  22. }
  23. if o.FlushInterval == 0 {
  24. o.FlushInterval = defaultFlushInterval
  25. }
  26. }