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

     1  package output
     2  
     3  import (
     4  	"github.com/Jeffail/benthos/v3/internal/docs"
     5  	"github.com/Jeffail/benthos/v3/lib/log"
     6  	"github.com/Jeffail/benthos/v3/lib/message/batch"
     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/aws/session"
    11  	"github.com/Jeffail/benthos/v3/lib/util/retries"
    12  )
    13  
    14  //------------------------------------------------------------------------------
    15  
    16  func init() {
    17  	Constructors[TypeAWSKinesisFirehose] = TypeSpec{
    18  		constructor: fromSimpleConstructor(NewAWSKinesisFirehose),
    19  		Version:     "3.36.0",
    20  		Summary: `
    21  Sends messages to a Kinesis Firehose delivery stream.`,
    22  		Description: `
    23  ### Credentials
    24  
    25  By default Benthos will use a shared credentials file when connecting to AWS
    26  services. It's also possible to set them explicitly at the component level,
    27  allowing you to transfer data across accounts. You can find out more
    28  [in this document](/docs/guides/cloud/aws).`,
    29  		Async:   true,
    30  		Batches: true,
    31  		FieldSpecs: docs.FieldSpecs{
    32  			docs.FieldCommon("stream", "The stream to publish messages to."),
    33  			docs.FieldCommon("max_in_flight", "The maximum number of messages to have in flight at a given time. Increase this to improve throughput."),
    34  			batch.FieldSpec(),
    35  		}.Merge(session.FieldSpecs()).Merge(retries.FieldSpecs()),
    36  		Categories: []Category{
    37  			CategoryServices,
    38  			CategoryAWS,
    39  		},
    40  	}
    41  
    42  	Constructors[TypeKinesisFirehose] = TypeSpec{
    43  		constructor: fromSimpleConstructor(NewKinesisFirehose),
    44  		Status:      docs.StatusDeprecated,
    45  		Summary: `
    46  Sends messages to a Kinesis Firehose delivery stream.`,
    47  		Description: `
    48  ## Alternatives
    49  
    50  This output has been renamed to ` + "[`aws_kinesis_firehose`](/docs/components/outputs/aws_kinesis_firehose)" + `.
    51  
    52  ### Credentials
    53  
    54  By default Benthos will use a shared credentials file when connecting to AWS
    55  services. It's also possible to set them explicitly at the component level,
    56  allowing you to transfer data across accounts. You can find out more
    57  [in this document](/docs/guides/cloud/aws).`,
    58  		Async:   true,
    59  		Batches: true,
    60  		FieldSpecs: docs.FieldSpecs{
    61  			docs.FieldCommon("stream", "The stream to publish messages to."),
    62  			docs.FieldCommon("max_in_flight", "The maximum number of messages to have in flight at a given time. Increase this to improve throughput."),
    63  			batch.FieldSpec(),
    64  		}.Merge(session.FieldSpecs()).Merge(retries.FieldSpecs()),
    65  		Categories: []Category{
    66  			CategoryServices,
    67  			CategoryAWS,
    68  		},
    69  	}
    70  }
    71  
    72  //------------------------------------------------------------------------------
    73  
    74  // NewAWSKinesisFirehose creates a new KinesisFirehose output type.
    75  func NewAWSKinesisFirehose(conf Config, mgr types.Manager, log log.Modular, stats metrics.Type) (Type, error) {
    76  	return newKinesisFirehose(TypeAWSKinesisFirehose, conf.AWSKinesisFirehose, mgr, log, stats)
    77  }
    78  
    79  // NewKinesisFirehose creates a new KinesisFirehose output type.
    80  func NewKinesisFirehose(conf Config, mgr types.Manager, log log.Modular, stats metrics.Type) (Type, error) {
    81  	return newKinesisFirehose(TypeKinesisFirehose, conf.KinesisFirehose, mgr, log, stats)
    82  }
    83  
    84  func newKinesisFirehose(name string, conf writer.KinesisFirehoseConfig, mgr types.Manager, log log.Modular, stats metrics.Type) (Type, error) {
    85  	kin, err := writer.NewKinesisFirehose(conf, log, stats)
    86  	if err != nil {
    87  		return nil, err
    88  	}
    89  	var w Type
    90  	if conf.MaxInFlight == 1 {
    91  		w, err = NewWriter(name, kin, log, stats)
    92  	} else {
    93  		w, err = NewAsyncWriter(name, conf.MaxInFlight, kin, log, stats)
    94  	}
    95  	if err != nil {
    96  		return w, err
    97  	}
    98  	return NewBatcherFromConfig(conf.Batching, w, mgr, log, stats)
    99  }
   100  
   101  //------------------------------------------------------------------------------