{"modulePath":"github.com/InVisionApp/benthos","version":"v0.26.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package reader\n\nPackage reader defines implementations of an interface for generic message reading from various third party sources.\n\n## Functions\n\n```go\nfunc OptLinesSetDelimiter(delimiter string) func(r *Lines)\n```\nOptLinesSetDelimiter is a option func that sets the delimiter (default '\\\\n') used to divide lines (message parts) in the stream of data.\n\n```go\nfunc OptLinesSetMaxBuffer(maxBuffer int) func(r *Lines)\n```\nOptLinesSetMaxBuffer is a option func that sets the maximum size of the line parsing buffers.\n\n```go\nfunc OptLinesSetMultipart(multipart bool) func(r *Lines)\n```\nOptLinesSetMultipart is a option func that sets the boolean flag indicating whether lines should be parsed as multipart or not.\n\n## Types\n\n```go\ntype AMQP struct {\n\t// contains filtered or unexported fields\n}\n```\nAMQP is an input type that reads messages via the AMQP 0.91 protocol.\n\n```go\nfunc (a *AMQP) Acknowledge(err error) error\n```\nAcknowledge instructs whether unacknowledged messages have been successfully propagated.\n\n```go\nfunc (a *AMQP) CloseAsync()\n```\nCloseAsync shuts down the AMQP input and stops processing requests.\n\n```go\nfunc (a *AMQP) Connect() (err error)\n```\nConnect establishes a connection to an AMQP server.\n\n```go\nfunc (a *AMQP) Read() (types.Message, error)\n```\nRead a new AMQP message.\n\n```go\nfunc (a *AMQP) WaitForClose(timeout time.Duration) error\n```\nWaitForClose blocks until the AMQP input has closed down.\n\n```go\ntype AMQPBindingConfig struct {\n\tExchange   string `json:\"exchange\" yaml:\"exchange\"`\n\tRoutingKey string `json:\"key\" yaml:\"key\"`\n}\n```\nAMQPBindingConfig contains fields describing a queue binding to be declared.\n\n```go\ntype AMQPConfig struct {\n\tURL             string                 `json:\"url\" yaml:\"url\"`\n\tQueue           string                 `json:\"queue\" yaml:\"queue\"`\n\tQueueDeclare    AMQPQueueDeclareConfig `json:\"queue_declare\" yaml:\"queue_declare\"`\n\tBindingsDeclare []AMQPBindingConfig    `json:\"bindings_declare\" yaml:\"bindings_declare\"`\n\tConsumerTag     string                 `json:\"consumer_tag\" yaml:\"consumer_tag\"`\n\tPrefetchCount   int                    `json:\"prefetch_count\" yaml:\"prefetch_count\"`\n\tPrefetchSize    int                    `json:\"prefetch_size\" yaml:\"prefetch_size\"`\n\tTLS             btls.Config            `json:\"tls\" yaml:\"tls\"`\n}\n```\nAMQPConfig contains configuration for the AMQP input type.\n\n```go\nfunc NewAMQPConfig() AMQPConfig\n```\nNewAMQPConfig creates a new AMQPConfig with default values.\n\n```go\ntype AMQPQueueDeclareConfig struct {\n\tEnabled bool `json:\"enabled\" yaml:\"enabled\"`\n\tDurable bool `json:\"durable\" yaml:\"durable\"`\n}\n```\nAMQPQueueDeclareConfig contains fields indicating whether the target AMQP queue needs to be declared and bound to an exchange, as well as any fields specifying how to accomplish that.\n\n```go\ntype AmazonAWSCredentialsConfig struct {\n\tID     string `json:\"id\" yaml:\"id\"`\n\tSecret string `json:\"secret\" yaml:\"secret\"`\n\tToken  string `json:\"token\" yaml:\"token\"`\n\tRole   string `json:\"role\" yaml:\"role\"`\n}\n```\nAmazonAWSCredentialsConfig contains configuration params for AWS credentials.\n\n```go\ntype AmazonS3 struct {\n\t// contains filtered or unexported fields\n}\n```\nAmazonS3 is a benthos reader.Type implementation that reads messages from an Amazon S3 bucket.\n\n```go\nfunc NewAmazonS3(\n\tconf AmazonS3Config,\n\tlog log.Modular,\n\tstats metrics.Type,\n) *AmazonS3\n```\nNewAmazonS3 creates a new Amazon S3 bucket reader.Type.\n\n```go\nfunc (a *AmazonS3) Acknowledge(err error) error\n```\nAcknowledge confirms whether or not our unacknowledged messages have been successfully propagated or not.\n\n```go\nfunc (a *AmazonS3) CloseAsync()\n```\nCloseAsync begins cleaning up resources used by this reader asynchronously.\n\n```go\nfunc (a *AmazonS3) Connect() error\n```\nConnect attempts to establish a connection to the target S3 bucket and any relevant queues used to traverse the objects (SQS, etc).\n\n```go\nfunc (a *AmazonS3) Read() (types.Message, error)\n```\nRead attempts to read a new message from the target S3 bucket.\n\n```go\nfunc (a *AmazonS3) WaitForClose(time.Duration) error\n```\nWaitForClose will block until either the reader is closed or a specified timeout occurs.\n\n```go\ntype AmazonS3Config struct {\n\tRegion          string                     `json:\"region\" yaml:\"region\"`\n\tBucket          string                     `json:\"bucket\" yaml:\"bucket\"`\n\tPrefix          string                     `json:\"prefix\" yaml:\"prefix\"`\n\tRetries         int                        `json:\"retries\" yaml:\"retries\"`\n\tDeleteObjects   bool                       `json:\"delete_objects\" yaml:\"delete_objects\"`\n\tSQSURL          string                     `json:\"sqs_url\" yaml:\"sqs_url\"`\n\tSQSBodyPath     string                     `json:\"sqs_body_path\" yaml:\"sqs_body_path\"`\n\tSQSEnvelopePath string                     `json:\"sqs_envelope_path\" yaml:\"sqs_envelope_path\"`\n\tSQSMaxMessages  int64                      `json:\"sqs_max_messages\" yaml:\"sqs_max_messages\"`\n\tCredentials     AmazonAWSCredentialsConfig `json:\"credentials\" yaml:\"credentials\"`\n\tTimeoutS        int64                      `json:\"timeout_s\" yaml:\"timeout_s\"`\n}\n```\nAmazonS3Config contains configuration values for the AmazonS3 input type.\n\n```go\nfunc NewAmazonS3Config() AmazonS3Config\n```\nNewAmazonS3Config creates a new AmazonS3Config with default values.\n\n```go\ntype AmazonSQS struct {\n\t// contains filtered or unexported fields\n}\n```\nAmazonSQS is a benthos reader.Type implementation that reads messages from an Amazon SQS queue.\n\n```go\nfunc NewAmazonSQS(\n\tconf AmazonSQSConfig,\n\tlog log.Modular,\n\tstats metrics.Type,\n) *AmazonSQS\n```\nNewAmazonSQS creates a new Amazon SQS reader.Type.\n\n```go\nfunc (a *AmazonSQS) Acknowledge(err error) error\n```\nAcknowledge confirms whether or not our unacknowledged messages have been successfully propagated or not.\n\n```go\nfunc (a *AmazonSQS) CloseAsync()\n```\nCloseAsync begins cleaning up resources used by this reader asynchronously.\n\n```go\nfunc (a *AmazonSQS) Connect() error\n```\nConnect attempts to establish a connection to the target SQS queue.\n\n```go\nfunc (a *AmazonSQS) Read() (types.Message, error)\n```\nRead attempts to read a new message from the target SQS.\n\n```go\nfunc (a *AmazonSQS) WaitForClose(time.Duration) error\n```\nWaitForClose will block until either the reader is closed or a specified timeout occurs.\n\n```go\ntype AmazonSQSConfig struct {\n\tRegion      string                     `json:\"region\" yaml:\"region\"`\n\tURL         string                     `json:\"url\" yaml:\"url\"`\n\tCredentials AmazonAWSCredentialsConfig `json:\"credentials\" yaml:\"credentials\"`\n\tTimeoutS    int64                      `json:\"timeout_s\" yaml:\"timeout_s\"`\n}\n```\nAmazonSQSConfig contains configuration values for the input type.\n\n```go\nfunc NewAmazonSQSConfig() AmazonSQSConfig\n```\nNewAmazonSQSConfig creates a new Config with default values.\n\n```go\ntype CutOff struct {\n\t// contains filtered or unexported fields\n}\n```\nCutOff is a wrapper for reader.Type implementations that exits from WaitForClose immediately. This is only useful when the underlying readable resource cannot be closed reliably and can block forever.\n\n```go\nfunc NewCutOff(r Type) *CutOff\n```\nNewCutOff returns a new CutOff wrapper around a reader.Type.\n\n```go\nfunc (c *CutOff) Acknowledge(err error) error\n```\nAcknowledge instructs whether messages read since the last Acknowledge call were successfully propagated. If the error is nil this will be forwarded to the underlying wrapped reader. If a non-nil error is returned the buffer of messages will be resent.\n\n```go\nfunc (c *CutOff) CloseAsync()\n```\nCloseAsync triggers the asynchronous closing of the reader.\n\n```go\nfunc (c *CutOff) Connect() error\n```\nConnect attempts to establish a connection to the source, if unsuccessful returns an error. If the attempt is successful (or not necessary) returns nil.\n\n```go\nfunc (c *CutOff) Read() (types.Message, error)\n```\nRead attempts to read a new message from the source.\n\n```go\nfunc (c *CutOff) WaitForClose(tout time.Duration) error\n```\nWaitForClose blocks until either the reader is finished closing or a timeout occurs.\n\n```go\ntype Files struct {\n\t// contains filtered or unexported fields\n}\n```\nFiles is an input type that reads file contents at a path as messages.\n\n```go\nfunc (f *Files) Acknowledge(err error) error\n```\nAcknowledge instructs whether unacknowledged messages have been successfully propagated.\n\n```go\nfunc (f *Files) CloseAsync()\n```\nCloseAsync shuts down the Files input and stops processing requests.\n\n```go\nfunc (f *Files) Connect() (err error)\n```\nConnect establishes a connection.\n\n```go\nfunc (f *Files) Read() (types.Message, error)\n```\nRead a new Files message.\n\n```go\nfunc (f *Files) WaitForClose(timeout time.Duration) error\n```\nWaitForClose blocks until the Files input has closed down.\n\n```go\ntype FilesConfig struct {\n\tPath string `json:\"path\" yaml:\"path\"`\n}\n```\nFilesConfig contains configuration for the Files input type.\n\n```go\nfunc NewFilesConfig() FilesConfig\n```\nNewFilesConfig creates a new FilesConfig with default values.\n\n```go\ntype Kafka struct {\n\t// contains filtered or unexported fields\n}\n```\nKafka is an input type that reads from a Kafka instance.\n\n```go\nfunc NewKafka(\n\tconf KafkaConfig, log log.Modular, stats metrics.Type,\n) (*Kafka, error)\n```\nNewKafka creates a new Kafka input type.\n\n```go\nfunc (k *Kafka) Acknowledge(err error) error\n```\nAcknowledge instructs whether the current offset should be committed.\n\n```go\nfunc (k *Kafka) CloseAsync()\n```\nCloseAsync shuts down the Kafka input and stops processing requests.\n\n```go\nfunc (k *Kafka) Connect() error\n```\nConnect establishes a Kafka connection.\n\n```go\nfunc (k *Kafka) Read() (types.Message, error)\n```\nRead attempts to read a message from a Kafka topic.\n\n```go\nfunc (k *Kafka) WaitForClose(timeout time.Duration) error\n```\nWaitForClose blocks until the Kafka input has closed down.\n\n```go\ntype KafkaBalanced struct {\n\t// contains filtered or unexported fields\n}\n```\nKafkaBalanced is an input type that reads from a Kafka cluster by balancing partitions across other consumers of the same consumer group.\n\n```go\nfunc NewKafkaBalanced(\n\tconf KafkaBalancedConfig, log log.Modular, stats metrics.Type,\n) (*KafkaBalanced, error)\n```\nNewKafkaBalanced creates a new KafkaBalanced input type.\n\n```go\nfunc (k *KafkaBalanced) Acknowledge(err error) error\n```\nAcknowledge instructs whether the current offset should be committed.\n\n```go\nfunc (k *KafkaBalanced) CloseAsync()\n```\nCloseAsync shuts down the KafkaBalanced input and stops processing requests.\n\n```go\nfunc (k *KafkaBalanced) Connect() error\n```\nConnect establishes a KafkaBalanced connection.\n\n```go\nfunc (k *KafkaBalanced) Read() (types.Message, error)\n```\nRead attempts to read a message from a KafkaBalanced topic.\n\n```go\nfunc (k *KafkaBalanced) WaitForClose(timeout time.Duration) error\n```\nWaitForClose blocks until the KafkaBalanced input has closed down.\n\n```go\ntype KafkaBalancedConfig struct {\n\tAddresses       []string    `json:\"addresses\" yaml:\"addresses\"`\n\tClientID        string      `json:\"client_id\" yaml:\"client_id\"`\n\tConsumerGroup   string      `json:\"consumer_group\" yaml:\"consumer_group\"`\n\tCommitPeriodMS  int         `json:\"commit_period_ms\" yaml:\"commit_period_ms\"`\n\tTopics          []string    `json:\"topics\" yaml:\"topics\"`\n\tStartFromOldest bool        `json:\"start_from_oldest\" yaml:\"start_from_oldest\"`\n\tTLS             btls.Config `json:\"tls\" yaml:\"tls\"`\n}\n```\nKafkaBalancedConfig contains configuration for the KafkaBalanced input type.\n\n```go\nfunc NewKafkaBalancedConfig() KafkaBalancedConfig\n```\nNewKafkaBalancedConfig creates a new KafkaBalancedConfig with default values.\n\n```go\ntype KafkaConfig struct {\n\tAddresses       []string    `json:\"addresses\" yaml:\"addresses\"`\n\tClientID        string      `json:\"client_id\" yaml:\"client_id\"`\n\tConsumerGroup   string      `json:\"consumer_group\" yaml:\"consumer_group\"`\n\tCommitPeriodMS  int         `json:\"commit_period_ms\" yaml:\"commit_period_ms\"`\n\tTopic           string      `json:\"topic\" yaml:\"topic\"`\n\tPartition       int32       `json:\"partition\" yaml:\"partition\"`\n\tStartFromOldest bool        `json:\"start_from_oldest\" yaml:\"start_from_oldest\"`\n\tTargetVersion   string      `json:\"target_version\" yaml:\"target_version\"`\n\tTLS             btls.Config `json:\"tls\" yaml:\"tls\"`\n}\n```\nKafkaConfig contains configuration fields for the Kafka input type.\n\n```go\nfunc NewKafkaConfig() KafkaConfig\n```\nNewKafkaConfig creates a new KafkaConfig with default values.\n\n```go\ntype Kinesis struct {\n\t// contains filtered or unexported fields\n}\n```\nKinesis is a benthos reader.Type implementation that reads messages from an Amazon Kinesis stream.\n\n```go\nfunc NewKinesis(\n\tconf KinesisConfig,\n\tlog log.Modular,\n\tstats metrics.Type,\n) *Kinesis\n```\nNewKinesis creates a new Amazon Kinesis stream reader.Type.\n\n```go\nfunc (k *Kinesis) Acknowledge(err error) error\n```\nAcknowledge confirms whether or not our unacknowledged messages have been successfully propagated or not.\n\n```go\nfunc (k *Kinesis) CloseAsync()\n```\nCloseAsync begins cleaning up resources used by this reader asynchronously.\n\n```go\nfunc (k *Kinesis) Connect() error\n```\nConnect attempts to establish a connection to the target SQS queue.\n\n```go\nfunc (k *Kinesis) Read() (types.Message, error)\n```\nRead attempts to read a new message from the target SQS.\n\n```go\nfunc (k *Kinesis) WaitForClose(time.Duration) error\n```\nWaitForClose will block until either the reader is closed or a specified timeout occurs.\n\n```go\ntype KinesisConfig struct {\n\tRegion          string                     `json:\"region\" yaml:\"region\"`\n\tCredentials     AmazonAWSCredentialsConfig `json:\"credentials\" yaml:\"credentials\"`\n\tLimit           int64                      `json:\"limit\" yaml:\"limit\"`\n\tStream          string                     `json:\"stream\" yaml:\"stream\"`\n\tShard           string                     `json:\"shard\" yaml:\"shard\"`\n\tDynamoDBTable   string                     `json:\"dynamodb_table\" yaml:\"dynamodb_table\"`\n\tClientID        string                     `json:\"client_id\" yaml:\"client_id\"`\n\tCommitPeriodMS  int                        `json:\"commit_period_ms\" yaml:\"commit_period_ms\"`\n\tStartFromOldest bool                       `json:\"start_from_oldest\" yaml:\"start_from_oldest\"`\n\tTimeoutMS       int64                      `json:\"timeout_ms\" yaml:\"timeout_ms\"`\n}\n```\nKinesisConfig is configuration values for the input type.\n\n```go\nfunc NewKinesisConfig() KinesisConfig\n```\nNewKinesisConfig creates a new Config with default values.\n\n```go\ntype Lines struct {\n\t// contains filtered or unexported fields\n}\n```\nLines is a reader implementation that continuously reads line delimited messages from an io.Reader type.\n\n```go\nfunc NewLines(\n\thandleCtor func() (io.Reader, error),\n\tonClose func(),\n\toptions ...func(r *Lines),\n) (*Lines, error)\n```\nNewLines creates a new reader input type.\n\nCallers must provide a constructor function for the target io.Reader, which is called on start up and again each time a reader is exhausted. If the constructor is called but there is no more content to create a Reader for then the error \\`io.EOF\\` should be returned and the Lines will close.\n\nCallers must also provide an onClose function, which will be called if the Lines has been instructed to shut down. This function should unblock any blocked Read calls.\n\n```go\nfunc (r *Lines) Acknowledge(err error) error\n```\nAcknowledge confirms whether or not our unacknowledged messages have been successfully propagated or not.\n\n```go\nfunc (r *Lines) CloseAsync()\n```\nCloseAsync shuts down the reader input and stops processing requests.\n\n```go\nfunc (r *Lines) Connect() error\n```\nConnect attempts to establish a new scanner for an io.Reader.\n\n```go\nfunc (r *Lines) Read() (types.Message, error)\n```\nRead attempts to read a new line from the io.Reader.\n\n```go\nfunc (r *Lines) WaitForClose(timeout time.Duration) error\n```\nWaitForClose blocks until the reader input has closed down.\n\n```go\ntype MQTT struct {\n\t// contains filtered or unexported fields\n}\n```\nMQTT is an input type that reads MQTT Pub/Sub messages.\n\n```go\nfunc NewMQTT(\n\tconf MQTTConfig, log log.Modular, stats metrics.Type,\n) (*MQTT, error)\n```\nNewMQTT creates a new MQTT input type.\n\n```go\nfunc (m *MQTT) Acknowledge(err error) error\n```\nAcknowledge instructs whether messages have been successfully propagated.\n\n```go\nfunc (m *MQTT) CloseAsync()\n```\nCloseAsync shuts down the MQTT input and stops processing requests.\n\n```go\nfunc (m *MQTT) Connect() error\n```\nConnect establishes a connection to an MQTT server.\n\n```go\nfunc (m *MQTT) Read() (types.Message, error)\n```\nRead attempts to read a new message from an MQTT broker.\n\n```go\nfunc (m *MQTT) WaitForClose(timeout time.Duration) error\n```\nWaitForClose blocks until the MQTT input has closed down.\n\n```go\ntype MQTTConfig struct {\n\tURLs     []string `json:\"urls\" yaml:\"urls\"`\n\tQoS      uint8    `json:\"qos\" yaml:\"qos\"`\n\tTopics   []string `json:\"topics\" yaml:\"topics\"`\n\tClientID string   `json:\"client_id\" yaml:\"client_id\"`\n}\n```\nMQTTConfig contains configuration fields for the MQTT input type.\n\n```go\nfunc NewMQTTConfig() MQTTConfig\n```\nNewMQTTConfig creates a new MQTTConfig with default values.\n\n```go\ntype NATS struct {\n\t// contains filtered or unexported fields\n}\n```\nNATS is an input type that receives NATS messages.\n\n```go\nfunc (n *NATS) Acknowledge(err error) error\n```\nAcknowledge is a noop since NATS messages do not support acknowledgments.\n\n```go\nfunc (n *NATS) CloseAsync()\n```\nCloseAsync shuts down the NATS input and stops processing requests.\n\n```go\nfunc (n *NATS) Connect() error\n```\nConnect establishes a connection to a NATS server.\n\n```go\nfunc (n *NATS) Read() (types.Message, error)\n```\nRead attempts to read a new message from the NATS subject.\n\n```go\nfunc (n *NATS) WaitForClose(timeout time.Duration) error\n```\nWaitForClose blocks until the NATS input has closed down.\n\n```go\ntype NATSConfig struct {\n\tURLs    []string `json:\"urls\" yaml:\"urls\"`\n\tSubject string   `json:\"subject\" yaml:\"subject\"`\n}\n```\nNATSConfig contains configuration fields for the NATS input type.\n\n```go\nfunc NewNATSConfig() NATSConfig\n```\nNewNATSConfig creates a new NATSConfig with default values.\n\n```go\ntype NATSStream struct {\n\t// contains filtered or unexported fields\n}\n```\nNATSStream is an input type that receives NATSStream messages.\n\n```go\nfunc (n *NATSStream) Acknowledge(err error) error\n```\nAcknowledge instructs whether unacknowledged messages have been successfully propagated.\n\n```go\nfunc (n *NATSStream) CloseAsync()\n```\nCloseAsync shuts down the NATSStream input and stops processing requests.\n\n```go\nfunc (n *NATSStream) Connect() error\n```\nConnect attempts to establish a connection to a NATS streaming server.\n\n```go\nfunc (n *NATSStream) Read() (types.Message, error)\n```\nRead attempts to read a new message from the NATS streaming server.\n\n```go\nfunc (n *NATSStream) WaitForClose(timeout time.Duration) error\n```\nWaitForClose blocks until the NATSStream input has closed down.\n\n```go\ntype NATSStreamConfig struct {\n\tURLs            []string `json:\"urls\" yaml:\"urls\"`\n\tClusterID       string   `json:\"cluster_id\" yaml:\"cluster_id\"`\n\tClientID        string   `json:\"client_id\" yaml:\"client_id\"`\n\tQueueID         string   `json:\"queue\" yaml:\"queue\"`\n\tDurableName     string   `json:\"durable_name\" yaml:\"durable_name\"`\n\tStartFromOldest bool     `json:\"start_from_oldest\" yaml:\"start_from_oldest\"`\n\tSubject         string   `json:\"subject\" yaml:\"subject\"`\n}\n```\nNATSStreamConfig contains configuration fields for the NATSStream input type.\n\n```go\nfunc NewNATSStreamConfig() NATSStreamConfig\n```\nNewNATSStreamConfig creates a new NATSStreamConfig with default values.\n\n```go\ntype NSQ struct {\n\t// contains filtered or unexported fields\n}\n```\nNSQ is an input type that receives NSQ messages.\n\n```go\nfunc (n *NSQ) Acknowledge(err error) error\n```\nAcknowledge instructs whether unacknowledged messages have been successfully propagated.\n\n```go\nfunc (n *NSQ) CloseAsync()\n```\nCloseAsync shuts down the NSQ input and stops processing requests.\n\n```go\nfunc (n *NSQ) Connect() (err error)\n```\nConnect establishes a connection to an NSQ server.\n\n```go\nfunc (n *NSQ) HandleMessage(message *nsq.Message) error\n```\nHandleMessage handles an NSQ message.\n\n```go\nfunc (n *NSQ) Read() (types.Message, error)\n```\nRead attempts to read a new message from NSQ.\n\n```go\nfunc (n *NSQ) WaitForClose(timeout time.Duration) error\n```\nWaitForClose blocks until the NSQ input has closed down.\n\n```go\ntype NSQConfig struct {\n\tAddresses       []string `json:\"nsqd_tcp_addresses\" yaml:\"nsqd_tcp_addresses\"`\n\tLookupAddresses []string `json:\"lookupd_http_addresses\" yaml:\"lookupd_http_addresses\"`\n\tTopic           string   `json:\"topic\" yaml:\"topic\"`\n\tChannel         string   `json:\"channel\" yaml:\"channel\"`\n\tUserAgent       string   `json:\"user_agent\" yaml:\"user_agent\"`\n\tMaxInFlight     int      `json:\"max_in_flight\" yaml:\"max_in_flight\"`\n}\n```\nNSQConfig contains configuration fields for the NSQ input type.\n\n```go\nfunc NewNSQConfig() NSQConfig\n```\nNewNSQConfig creates a new NSQConfig with default values.\n\n```go\ntype Preserver struct {\n\t// contains filtered or unexported fields\n}\n```\nPreserver is a wrapper for reader.Type implementations that keeps a buffer of sent messages until they are acknowledged. If an error occurs during message propagation the contents of the buffer will be resent instead of reading new messages until it is depleted. Preserver implements reader.Type.\n\n```go\nfunc NewPreserver(r Type) *Preserver\n```\nNewPreserver returns a new Preserver wrapper around a reader.Type.\n\n```go\nfunc (p *Preserver) Acknowledge(err error) error\n```\nAcknowledge instructs whether messages read since the last Acknowledge call were successfully propagated. If the error is nil this will be forwarded to the underlying wrapped reader. If a non-nil error is returned the buffer of messages will be resent.\n\n```go\nfunc (p *Preserver) CloseAsync()\n```\nCloseAsync triggers the asynchronous closing of the reader.\n\n```go\nfunc (p *Preserver) Connect() error\n```\nConnect attempts to establish a connection to the source, if unsuccessful returns an error. If the attempt is successful (or not necessary) returns nil.\n\n```go\nfunc (p *Preserver) Read() (types.Message, error)\n```\nRead attempts to read a new message from the source.\n\n```go\nfunc (p *Preserver) WaitForClose(tout time.Duration) error\n```\nWaitForClose blocks until either the reader is finished closing or a timeout occurs.\n\n```go\ntype RedisList struct {\n\t// contains filtered or unexported fields\n}\n```\nRedisList is an input type that reads Redis List messages.\n\n```go\nfunc NewRedisList(\n\tconf RedisListConfig, log log.Modular, stats metrics.Type,\n) (*RedisList, error)\n```\nNewRedisList creates a new RedisList input type.\n\n```go\nfunc (r *RedisList) Acknowledge(err error) error\n```\nAcknowledge is a noop since Redis Lists do not support acknowledgements.\n\n```go\nfunc (r *RedisList) CloseAsync()\n```\nCloseAsync shuts down the RedisList input and stops processing requests.\n\n```go\nfunc (r *RedisList) Connect() error\n```\nConnect establishes a connection to a Redis server.\n\n```go\nfunc (r *RedisList) Read() (types.Message, error)\n```\nRead attempts to pop a message from a Redis list.\n\n```go\nfunc (r *RedisList) WaitForClose(timeout time.Duration) error\n```\nWaitForClose blocks until the RedisList input has closed down.\n\n```go\ntype RedisListConfig struct {\n\tURL       string `json:\"url\" yaml:\"url\"`\n\tKey       string `json:\"key\" yaml:\"key\"`\n\tTimeoutMS int    `json:\"timeout_ms\" yaml:\"timeout_ms\"`\n}\n```\nRedisListConfig contains configuration fields for the RedisList input type.\n\n```go\nfunc NewRedisListConfig() RedisListConfig\n```\nNewRedisListConfig creates a new RedisListConfig with default values.\n\n```go\ntype RedisPubSub struct {\n\t// contains filtered or unexported fields\n}\n```\nRedisPubSub is an input type that reads Redis Pub/Sub messages.\n\n```go\nfunc NewRedisPubSub(\n\tconf RedisPubSubConfig, log log.Modular, stats metrics.Type,\n) (*RedisPubSub, error)\n```\nNewRedisPubSub creates a new RedisPubSub input type.\n\n```go\nfunc (r *RedisPubSub) Acknowledge(err error) error\n```\nAcknowledge is a noop since Redis pub/sub channels do not support acknowledgements.\n\n```go\nfunc (r *RedisPubSub) CloseAsync()\n```\nCloseAsync shuts down the RedisPubSub input and stops processing requests.\n\n```go\nfunc (r *RedisPubSub) Connect() error\n```\nConnect establishes a connection to an RedisPubSub server.\n\n```go\nfunc (r *RedisPubSub) Read() (types.Message, error)\n```\nRead attempts to pop a message from a redis pubsub channel.\n\n```go\nfunc (r *RedisPubSub) WaitForClose(timeout time.Duration) error\n```\nWaitForClose blocks until the RedisPubSub input has closed down.\n\n```go\ntype RedisPubSubConfig struct {\n\tURL      string   `json:\"url\" yaml:\"url\"`\n\tChannels []string `json:\"channels\" yaml:\"channels\"`\n}\n```\nRedisPubSubConfig contains configuration fields for the RedisPubSub input type.\n\n```go\nfunc NewRedisPubSubConfig() RedisPubSubConfig\n```\nNewRedisPubSubConfig creates a new RedisPubSubConfig with default values.\n\n```go\ntype RedisStreams struct {\n\t// contains filtered or unexported fields\n}\n```\nRedisStreams is an input type that reads Redis Streams messages.\n\n```go\nfunc NewRedisStreams(\n\tconf RedisStreamsConfig, log log.Modular, stats metrics.Type,\n) (*RedisStreams, error)\n```\nNewRedisStreams creates a new RedisStreams input type.\n\n```go\nfunc (r *RedisStreams) Acknowledge(err error) error\n```\nAcknowledge is a noop since Redis Lists do not support acknowledgements.\n\n```go\nfunc (r *RedisStreams) CloseAsync()\n```\nCloseAsync shuts down the RedisStreams input and stops processing requests.\n\n```go\nfunc (r *RedisStreams) Connect() error\n```\nConnect establishes a connection to a Redis server.\n\n```go\nfunc (r *RedisStreams) Read() (types.Message, error)\n```\nRead attempts to pop a message from a Redis list.\n\n```go\nfunc (r *RedisStreams) WaitForClose(timeout time.Duration) error\n```\nWaitForClose blocks until the RedisStreams input has closed down.\n\n```go\ntype RedisStreamsConfig struct {\n\tURL             string   `json:\"url\" yaml:\"url\"`\n\tBodyKey         string   `json:\"body_key\" yaml:\"body_key\"`\n\tStreams         []string `json:\"streams\" yaml:\"streams\"`\n\tConsumerGroup   string   `json:\"consumer_group\" yaml:\"consumer_group\"`\n\tClientID        string   `json:\"client_id\" yaml:\"client_id\"`\n\tLimit           int64    `json:\"limit\" yaml:\"limit\"`\n\tStartFromOldest bool     `json:\"start_from_oldest\" yaml:\"start_from_oldest\"`\n\tCommitPeriodMS  int      `json:\"commit_period_ms\" yaml:\"commit_period_ms\"`\n\tTimeoutMS       int      `json:\"timeout_ms\" yaml:\"timeout_ms\"`\n}\n```\nRedisStreamsConfig contains configuration fields for the RedisStreams input type.\n\n```go\nfunc NewRedisStreamsConfig() RedisStreamsConfig\n```\nNewRedisStreamsConfig creates a new RedisStreamsConfig with default values.\n\n```go\ntype ScaleProto struct {\n\t// contains filtered or unexported fields\n}\n```\nScaleProto is an input type that contains Scalability Protocols messages.\n\n```go\nfunc (s *ScaleProto) Acknowledge(err error) error\n```\nAcknowledge instructs whether the pending messages were propagated successfully.\n\n```go\nfunc (s *ScaleProto) CloseAsync()\n```\nCloseAsync shuts down the ScaleProto input and stops processing requests.\n\n```go\nfunc (s *ScaleProto) Connect() error\n```\nConnect establishes a nanomsg socket.\n\n```go\nfunc (s *ScaleProto) Read() (types.Message, error)\n```\nRead attempts to read a new message from the nanomsg socket.\n\n```go\nfunc (s *ScaleProto) WaitForClose(timeout time.Duration) error\n```\nWaitForClose blocks until the ScaleProto input has closed down.\n\n```go\ntype ScaleProtoConfig struct {\n\tURLs          []string `json:\"urls\" yaml:\"urls\"`\n\tBind          bool     `json:\"bind\" yaml:\"bind\"`\n\tSocketType    string   `json:\"socket_type\" yaml:\"socket_type\"`\n\tSubFilters    []string `json:\"sub_filters\" yaml:\"sub_filters\"`\n\tPollTimeoutMS int      `json:\"poll_timeout_ms\" yaml:\"poll_timeout_ms\"`\n\tRepTimeoutMS  int      `json:\"reply_timeout_ms\" yaml:\"reply_timeout_ms\"`\n}\n```\nScaleProtoConfig contains configuration fields for the ScaleProto input type.\n\n```go\nfunc NewScaleProtoConfig() ScaleProtoConfig\n```\nNewScaleProtoConfig creates a new ScaleProtoConfig with default values.\n\n```go\ntype Type interface {\n\t// Connect attempts to establish a connection to the source, if unsuccessful\n\t// returns an error. If the attempt is successful (or not necessary) returns\n\t// nil.\n\tConnect() error\n\n\t// Acknowledge, if applicable to the source, should send acknowledgments for\n\t// (or commit) all unacknowledged (or uncommitted) messages that have thus\n\t// far been consumed. If the error is non-nil this means the message was\n\t// unsuccessfully propagated down the pipeline, in which case it is up to\n\t// the implementation to decide whether to simply retry uncommitted messages\n\t// that are buffered locally, or to send the error upstream.\n\tAcknowledge(err error) error\n\n\t// Read attempts to read a new message from the source.\n\tRead() (types.Message, error)\n\n\ttypes.Closable\n}\n```\nType is a type that reads Benthos messages from an external source. If the source supports acknowledgements then it is the responsibility of Type implementations to ensure acknowledgements are not sent for consumed messages until a subsequent Acknowledge call contains a nil error.\n\n```go\nfunc NewAMQP(conf AMQPConfig, log log.Modular, stats metrics.Type) (Type, error)\n```\nNewAMQP creates a new AMQP input type.\n\n```go\nfunc NewFiles(conf FilesConfig) (Type, error)\n```\nNewFiles creates a new Files input type.\n\n```go\nfunc NewNATS(conf NATSConfig, log log.Modular, stats metrics.Type) (Type, error)\n```\nNewNATS creates a new NATS input type.\n\n```go\nfunc NewNATSStream(conf NATSStreamConfig, log log.Modular, stats metrics.Type) (Type, error)\n```\nNewNATSStream creates a new NATSStream input type.\n\n```go\nfunc NewNSQ(conf NSQConfig, log log.Modular, stats metrics.Type) (Type, error)\n```\nNewNSQ creates a new NSQ input type.\n\n```go\nfunc NewScaleProto(conf ScaleProtoConfig, log log.Modular, stats metrics.Type) (Type, error)\n```\nNewScaleProto creates a new ScaleProto input type.\n\n```go\ntype Websocket struct {\n\t// contains filtered or unexported fields\n}\n```\nWebsocket is an input type that reads Websocket messages.\n\n```go\nfunc NewWebsocket(\n\tconf WebsocketConfig,\n\tlog log.Modular,\n\tstats metrics.Type,\n) (*Websocket, error)\n```\nNewWebsocket creates a new Websocket input type.\n\n```go\nfunc (w *Websocket) Acknowledge(err error) error\n```\nAcknowledge instructs whether the pending messages were propagated successfully.\n\n```go\nfunc (w *Websocket) CloseAsync()\n```\nCloseAsync shuts down the Websocket input and stops reading messages.\n\n```go\nfunc (w *Websocket) Connect() error\n```\nConnect establishes a connection to a Websocket server.\n\n```go\nfunc (w *Websocket) Read() (types.Message, error)\n```\nRead attempts to read a new message from the websocket.\n\n```go\nfunc (w *Websocket) WaitForClose(timeout time.Duration) error\n```\nWaitForClose blocks until the Websocket input has closed down.\n\n```go\ntype WebsocketConfig struct {\n\tURL         string `json:\"url\" yaml:\"url\"`\n\tOpenMsg     string `json:\"open_message\" yaml:\"open_message\"`\n\tauth.Config `json:\",inline\" yaml:\",inline\"`\n}\n```\nWebsocketConfig contains configuration fields for the Websocket input type.\n\n```go\nfunc NewWebsocketConfig() WebsocketConfig\n```\nNewWebsocketConfig creates a new WebsocketConfig with default values.\n\n```go\ntype ZMQ4Config struct{}\n```\nZMQ4Config is an empty stub for when ZMQ4 is not compiled.\n\n```go\nfunc NewZMQ4Config() *ZMQ4Config\n```\nNewZMQ4Config returns nil.\n\n","path":"github.com/InVisionApp/benthos/lib/input/reader","name":"reader","synopsis":"Package reader defines implementations of an interface for generic message reading from various third party sources.","isRedistributable":true}
