github.com/v2fly/v2ray-core/v4@v4.45.2/app/dispatcher/stats.go (about)

     1  //go:build !confonly
     2  // +build !confonly
     3  
     4  package dispatcher
     5  
     6  import (
     7  	"github.com/v2fly/v2ray-core/v4/common"
     8  	"github.com/v2fly/v2ray-core/v4/common/buf"
     9  	"github.com/v2fly/v2ray-core/v4/features/stats"
    10  )
    11  
    12  type SizeStatWriter struct {
    13  	Counter stats.Counter
    14  	Writer  buf.Writer
    15  }
    16  
    17  func (w *SizeStatWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
    18  	w.Counter.Add(int64(mb.Len()))
    19  	return w.Writer.WriteMultiBuffer(mb)
    20  }
    21  
    22  func (w *SizeStatWriter) Close() error {
    23  	return common.Close(w.Writer)
    24  }
    25  
    26  func (w *SizeStatWriter) Interrupt() {
    27  	common.Interrupt(w.Writer)
    28  }