Documentation
¶
Overview ¶
Package dynamostore is the flag source of a DynamoDB table: a flag file is one table, read with Scan, and the store answers with a virtual flag file that it builds from the items of the table (one flag for each item: the attribute flag names it, the other attributes are the definition). It is the only package of the flag sources that imports the DynamoDB client.
Index ¶
Constants ¶
const KeySuffix = ".json"
KeySuffix ends the key of a flag set: the table is the key without it.
const OverallFactor = 10
OverallFactor is the number of request timeouts that the read of a whole table may take: with the default of 30 seconds the read ends after 5 minutes, whatever the pages are.
Variables ¶
var ( // ErrAccessRefused is the cause of an answer that refuses the credentials or the permission. ErrAccessRefused = errors.New("objectstore: DynamoDB access refused") // ErrRequestRefused is the cause of any other answer that refuses the request (a name or a setting is wrong). ErrRequestRefused = errors.New("objectstore: DynamoDB refused the request") // ErrThrottled is the cause of an answer that throttles the request. ErrThrottled = errors.New("objectstore: DynamoDB throttled the request") ErrUnavailable = errors.New("objectstore: DynamoDB is not available") )
The causes of a failed read. None of them holds an endpoint, a table, an account, a role or a request id: the text of the SDK error has them and is dropped; only the short error code of the service is kept.
var ErrKeyRefused = errors.New("objectstore: the key is no table name with the .json suffix")
ErrKeyRefused is the cause of a key that is no table name followed by ".json".
Functions ¶
Types ¶
type Option ¶
type Option func(*Store)
Option adjusts a Store.
func WithRequestTimeout ¶
WithRequestTimeout bounds each request of a read: one Scan call, a page, with all the attempts of the SDK and the waits between them. The read as a whole has a deadline of OverallFactor times that, and the context of the caller. Zero or less keeps storekit.DefaultCloudRequestTimeout.
type Provider ¶
Provider gives the DynamoDB client of a named connection. The connection factory (internal/connection) implements it. The store asks on every call, so a client the factory replaced after a reload is picked up and there is never a second client for the connection.
type Store ¶
type Store struct {
objectstore.NoLifecycle
// contains filtered or unexported fields
}
Store is an objectstore.ObjectStore on the tables of the DynamoDB client of a connection. A key is the name of a table and ".json" (flags.json reads the table flags); the store answers with one JSON document, the flag file, built from every item of the table. See Store.Get for the rules.
func New ¶
New returns the store of the tables of the connection named connectionName. The logger receives the one line about items that are not flags; nil discards it.
func (*Store) Format ¶
Format implements fmt.Formatter: every verb prints the name of the connection and nothing else.
func (*Store) Get ¶
func (s *Store) Get(ctx context.Context, req objectstore.GetRequest) (objectstore.Object, error)
Get implements objectstore.ObjectStore. The answer is the flag file of the table.
- The ETag is the SHA-256 of that document, so an unchanged table is objectstore.ErrNotModified. The document is rebuilt with its names in order: items that are read in another order give the same ETag.
- DynamoDB keeps no modification time for a table: Modified is the zero time.
- A table that does not exist is objectstore.ErrNotFound; one that exists and holds no item is the empty flag set.
- The table is read with Scan, page after page, with consistent reads, and the read stops with objectstore.ErrTooLarge as soon as the file would be over the limit. The pages are not one snapshot: a change while they are read can tear the answer, and the next poll reads the new state.
- Each Scan has its own request timeout (see WithRequestTimeout); the read as a whole ends after OverallFactor request timeouts, or with the context of the caller.
- The size of the items that are left out counts toward the limit.
- The items that are left out are logged at every read.
- The SDK retries a throttled or failed page by its own retryer, set on the connection (retry.maxAttempts); the store adds no retry of its own.