github.com/Jeffail/benthos/v3@v3.65.0/lib/processor/noop.go (about) 1 package processor 2 3 import ( 4 "time" 5 6 "github.com/Jeffail/benthos/v3/internal/docs" 7 "github.com/Jeffail/benthos/v3/lib/log" 8 "github.com/Jeffail/benthos/v3/lib/metrics" 9 "github.com/Jeffail/benthos/v3/lib/types" 10 ) 11 12 //------------------------------------------------------------------------------ 13 14 func init() { 15 Constructors[TypeNoop] = TypeSpec{ 16 constructor: NewNoop, 17 Summary: "Noop is a processor that does nothing, the message passes through unchanged. Why? Sometimes doing nothing is the braver option.", 18 config: docs.FieldComponent().HasType(docs.FieldTypeObject), 19 } 20 } 21 22 //------------------------------------------------------------------------------ 23 24 // NoopConfig configures the no-op processor. 25 type NoopConfig struct{} 26 27 // NewNoopConfig creates a new default no-op processor config. 28 func NewNoopConfig() NoopConfig { 29 return NoopConfig{} 30 } 31 32 // Noop is a no-op processor that does nothing. 33 type Noop struct{} 34 35 // NewNoop returns a Noop processor. 36 func NewNoop( 37 conf Config, mgr types.Manager, log log.Modular, stats metrics.Type, 38 ) (Type, error) { 39 return &Noop{}, nil 40 } 41 42 //------------------------------------------------------------------------------ 43 44 // ProcessMessage does nothing and returns the message unchanged. 45 func (c *Noop) ProcessMessage(msg types.Message) ([]types.Message, types.Response) { 46 msgs := [1]types.Message{msg} 47 return msgs[:], nil 48 } 49 50 // CloseAsync shuts down the processor and stops processing requests. 51 func (c *Noop) CloseAsync() { 52 } 53 54 // WaitForClose blocks until the processor has closed down. 55 func (c *Noop) WaitForClose(timeout time.Duration) error { 56 return nil 57 } 58 59 //------------------------------------------------------------------------------