github.com/moqsien/xraycore@v1.8.5/app/dispatcher/stats.go (about)

     1  package dispatcher
     2  
     3  import (
     4  	"github.com/moqsien/xraycore/common"
     5  	"github.com/moqsien/xraycore/common/buf"
     6  	"github.com/moqsien/xraycore/features/stats"
     7  )
     8  
     9  type SizeStatWriter struct {
    10  	Counter stats.Counter
    11  	Writer  buf.Writer
    12  }
    13  
    14  func (w *SizeStatWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
    15  	w.Counter.Add(int64(mb.Len()))
    16  	return w.Writer.WriteMultiBuffer(mb)
    17  }
    18  
    19  func (w *SizeStatWriter) Close() error {
    20  	return common.Close(w.Writer)
    21  }
    22  
    23  func (w *SizeStatWriter) Interrupt() {
    24  	common.Interrupt(w.Writer)
    25  }