From c12e80199086ac52c7c72e1c19b8ef584197878a Mon Sep 17 00:00:00 2001 From: Harlow Ward Date: Sun, 28 Jul 2019 11:21:08 -0700 Subject: [PATCH] give example of setting storage --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b9b7331..1e9ea15 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ The consumer allows the following optional overrides. ### Storage -To record the progress (checkpoint) of the consumer in the stream we use a storage layer to persist the last sequence number the consumer has read from a particular shard. The boolean value ErrSkipCheckpoint of consumer.ScanError determines if checkpoint will be activated. ScanError is returned by the record processing callback. +To record the progress of the consumer in the stream (checkpoint) we use a storage layer to persist the last sequence number the consumer has read from a particular shard. The boolean value ErrSkipCheckpoint of consumer.ScanError determines if checkpoint will be activated. ScanError is returned by the record processing callback. This will allow consumers to re-launch and pick up at the position in the stream where they left off. @@ -120,6 +120,15 @@ The uniq identifier for a consumer is `[appName, streamName, shardID]` Note: The default storage is in-memory (no-op). Which means the scan will not persist any state and the consumer will start from the beginning of the stream each time it is re-started. +The consumer accpets a `WithStorage` option to set the storage layer: + +```go +c, err := consumer.New(*stream, consumer.WithStorage(db)) +if err != nil { + log.Log("consumer error: %v", err) +} +``` + To persist scan progress choose one of the following storage layers: #### Redis