github.com/Jeffail/benthos/v3@v3.65.0/lib/output/amqp_1.go (about)

     1  package output
     2  
     3  import (
     4  	"github.com/Jeffail/benthos/v3/internal/docs"
     5  	"github.com/Jeffail/benthos/v3/internal/metadata"
     6  	"github.com/Jeffail/benthos/v3/lib/log"
     7  	"github.com/Jeffail/benthos/v3/lib/metrics"
     8  	"github.com/Jeffail/benthos/v3/lib/output/writer"
     9  	"github.com/Jeffail/benthos/v3/lib/types"
    10  	"github.com/Jeffail/benthos/v3/lib/util/amqp/sasl"
    11  	"github.com/Jeffail/benthos/v3/lib/util/tls"
    12  )
    13  
    14  //------------------------------------------------------------------------------
    15  
    16  func init() {
    17  	Constructors[TypeAMQP1] = TypeSpec{
    18  		constructor: fromSimpleConstructor(NewAMQP1),
    19  		Status:      docs.StatusBeta,
    20  		Summary: `
    21  Sends messages to an AMQP (1.0) server.`,
    22  		Description: `
    23  ### Metadata
    24  
    25  Message metadata is added to each AMQP message as string annotations. In order to control which metadata keys are added use the ` + "`metadata`" + ` config field.`,
    26  		Async: true,
    27  		FieldSpecs: docs.FieldSpecs{
    28  			docs.FieldCommon("url",
    29  				"A URL to connect to.",
    30  				"amqp://localhost:5672/",
    31  				"amqps://guest:guest@localhost:5672/",
    32  			),
    33  			docs.FieldCommon("target_address", "The target address to write to.", "/foo", "queue:/bar", "topic:/baz"),
    34  			docs.FieldCommon("max_in_flight", "The maximum number of messages to have in flight at a given time. Increase this to improve throughput."),
    35  			tls.FieldSpec(),
    36  			sasl.FieldSpec(),
    37  			docs.FieldCommon("metadata", "Specify criteria for which metadata values are attached to messages as headers.").WithChildren(metadata.ExcludeFilterFields()...),
    38  		},
    39  		Categories: []Category{
    40  			CategoryServices,
    41  		},
    42  	}
    43  }
    44  
    45  //------------------------------------------------------------------------------
    46  
    47  // NewAMQP1 creates a new AMQP output type.
    48  func NewAMQP1(conf Config, mgr types.Manager, log log.Modular, stats metrics.Type) (Type, error) {
    49  	a, err := writer.NewAMQP1(conf.AMQP1, log, stats)
    50  	if err != nil {
    51  		return nil, err
    52  	}
    53  	w, err := NewAsyncWriter(
    54  		TypeAMQP1, conf.AMQP1.MaxInFlight, a, log, stats,
    55  	)
    56  	if err != nil {
    57  		return nil, err
    58  	}
    59  	return OnlySinglePayloads(w), nil
    60  }
    61  
    62  //------------------------------------------------------------------------------