func NewWriteBroadcaster(size int) *WriteBroadcaster { if size <= 0 { size = 4 * 1024 } bc := &WriteBroadcaster{ writers: make(map[StreamWriter]bool), buf: rbuf.NewFixedSizeRingBuf(size), closed: false, } return bc }
// NewFile returns a new File for the given file with the given Config options func NewFile(filename string, opts ...FileConfig) (*File, error) { var ( path string f *os.File err error ) if path, err = filepath.Abs(filename); err != nil { return nil, err } if f, err = os.OpenFile(filename, os.O_RDONLY, 0); err != nil { return nil, err } if _, err = f.Seek(0, os.SEEK_END); err != nil { _ = f.Close() return nil, err } t := &File{ filename: path, file: f, ring: rbuf.NewFixedSizeRingBuf(4096), errc: make(chan error), } for _, opt := range opts { err := opt(t) if err != nil { return nil, err } } switch t.rotationStrat { case "notify": if err := t.notifyOnChanges(); err != nil { return nil, err } default: go t.pollForUpdates(PollIntervalFast) go t.pollForRotations(PollIntervalSlow) } return t, nil }
// BASE64 rfc2045 specified that: // All line breaks or other characters not found in Table 1 must be ignored by // decoding software. Other white space probably indicate a transmission error, // about which a warning message or even a message rejection might be // appropriate under some circumstances. func newBase64PadReader(r io.Reader) *base64PadReader { return &base64PadReader{ in: r, rb: rbuf.NewFixedSizeRingBuf(paddingBufferSize), } }
// SetBufferSize sets the size of the internal ring buffer that tailers use to buffer reads and writes from disk func SetBufferSize(i int) FileConfig { return func(t *File) error { t.ring = rbuf.NewFixedSizeRingBuf(i) return nil } }