github.com/Jeffail/benthos/v3@v3.65.0/lib/output/writer/drop.go (about) 1 package writer 2 3 import ( 4 "time" 5 6 "github.com/Jeffail/benthos/v3/lib/log" 7 "github.com/Jeffail/benthos/v3/lib/metrics" 8 "github.com/Jeffail/benthos/v3/lib/types" 9 ) 10 11 //------------------------------------------------------------------------------ 12 13 // DropConfig contains configuration fields for the drop output type. 14 type DropConfig struct{} 15 16 // NewDropConfig creates a new DropConfig with default values. 17 func NewDropConfig() DropConfig { 18 return DropConfig{} 19 } 20 21 //------------------------------------------------------------------------------ 22 23 // Drop is a benthos writer.Type implementation that writes message parts to no 24 // where. 25 type Drop struct { 26 log log.Modular 27 } 28 29 // NewDrop creates a new file based writer.Type. 30 func NewDrop( 31 conf DropConfig, 32 log log.Modular, 33 stats metrics.Type, 34 ) *Drop { 35 return &Drop{ 36 log: log, 37 } 38 } 39 40 // Connect is a noop. 41 func (d *Drop) Connect() error { 42 d.log.Infoln("Dropping messages.") 43 return nil 44 } 45 46 // Write does nothing. 47 func (d *Drop) Write(msg types.Message) error { 48 return nil 49 } 50 51 // CloseAsync begins cleaning up resources used by this reader asynchronously. 52 func (d *Drop) CloseAsync() { 53 } 54 55 // WaitForClose will block until either the reader is closed or a specified 56 // timeout occurs. 57 func (d *Drop) WaitForClose(time.Duration) error { 58 return nil 59 } 60 61 //------------------------------------------------------------------------------