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

     1  package output
     2  
     3  import (
     4  	"github.com/Jeffail/benthos/v3/internal/docs"
     5  	"github.com/Jeffail/benthos/v3/internal/impl/redis"
     6  	"github.com/Jeffail/benthos/v3/lib/log"
     7  	"github.com/Jeffail/benthos/v3/lib/message/batch"
     8  	"github.com/Jeffail/benthos/v3/lib/metrics"
     9  	"github.com/Jeffail/benthos/v3/lib/output/writer"
    10  	"github.com/Jeffail/benthos/v3/lib/types"
    11  )
    12  
    13  //------------------------------------------------------------------------------
    14  
    15  func init() {
    16  	Constructors[TypeRedisList] = TypeSpec{
    17  		constructor: fromSimpleConstructor(NewRedisList),
    18  		Summary: `
    19  Pushes messages onto the end of a Redis list (which is created if it doesn't
    20  already exist) using the RPUSH command.`,
    21  		Description: `
    22  The field ` + "`key`" + ` supports
    23  [interpolation functions](/docs/configuration/interpolation#bloblang-queries), allowing
    24  you to create a unique key for each message.`,
    25  		Async:   true,
    26  		Batches: true,
    27  		FieldSpecs: redis.ConfigDocs().Add(
    28  			docs.FieldCommon(
    29  				"key", "The key for each message, function interpolations can be optionally used to create a unique key per message.",
    30  				"benthos_list", "${!meta(\"kafka_key\")}", "${!json(\"doc.id\")}", "${!count(\"msgs\")}",
    31  			).IsInterpolated(),
    32  			docs.FieldCommon("max_in_flight", "The maximum number of messages to have in flight at a given time. Increase this to improve throughput."),
    33  			batch.FieldSpec(),
    34  		),
    35  		Categories: []Category{
    36  			CategoryServices,
    37  		},
    38  	}
    39  }
    40  
    41  //------------------------------------------------------------------------------
    42  
    43  // NewRedisList creates a new RedisList output type.
    44  func NewRedisList(conf Config, mgr types.Manager, log log.Modular, stats metrics.Type) (Type, error) {
    45  	w, err := writer.NewRedisListV2(conf.RedisList, mgr, log, stats)
    46  	if err != nil {
    47  		return nil, err
    48  	}
    49  	a, err := NewAsyncWriter(TypeRedisList, conf.RedisList.MaxInFlight, w, log, stats)
    50  	if err != nil {
    51  		return nil, err
    52  	}
    53  	return NewBatcherFromConfig(conf.RedisList.Batching, a, mgr, log, stats)
    54  }
    55  
    56  //------------------------------------------------------------------------------