github.com/Jeffail/benthos/v3@v3.65.0/lib/message/roundtrip/writer.go (about)

     1  package roundtrip
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/Jeffail/benthos/v3/lib/types"
     7  )
     8  
     9  //------------------------------------------------------------------------------
    10  
    11  // Writer is a writer implementation that adds messages to a ResultStore located
    12  // in the context of the first message part of each batch. This is essentially a
    13  // mechanism that returns the result of a pipeline directly back to the origin
    14  // of the message.
    15  type Writer struct{}
    16  
    17  // Connect is a noop.
    18  func (s Writer) Connect() error {
    19  	return nil
    20  }
    21  
    22  // Write a message batch to a ResultStore located in the first message of the
    23  // batch.
    24  func (s Writer) Write(msg types.Message) error {
    25  	return SetAsResponse(msg)
    26  }
    27  
    28  // CloseAsync is a noop.
    29  func (s Writer) CloseAsync() {}
    30  
    31  // WaitForClose is a noop.
    32  func (s Writer) WaitForClose(time.Duration) error {
    33  	return nil
    34  }
    35  
    36  //------------------------------------------------------------------------------