DynamoDB LogstashPipelines Document
DynamoDB LogstashPipelines Document
Ke
Value
y
DATA#logstash-
pk
pipeline
sk CURRENT#(id)
HISTORY#(id)#(vers
sk
ion)
Your eyes do not deceive you -- there's two sk listed. The sk:CURRENT#(id) is the
one that's used in all the operations. BUT we're also keeping history for these items,
so every time we change the current one we're also adding a history entry.
id: The unique ID generated by LogstashPipelineDynamoDBMapper
version: The timestamp the change was made, e.g. 1727251684123
AWS SDK
Use the AWS SDK v3. The imports etc are already present in the file. Use
the DocumentClient in favor of the standard Client as it does un/marshalling for you.
Data Output
The API uses the ts-results-es package to return the appropriate data, or an error
object. (e.g. Result<TData, TError>). There are three helper types that clarify what
format the returned data should be:
Implementati
Type Example Use Case Purpose
on
Return a single
item from a single
invocation, or
error.
SingleResult Result<T,
getItemById(id) Error could be
<T> ErrorType>
database
misconfiguration
or item not found,
for example
Return multiple
items from a
single invocation,
or error.
Error could be
MultiResult< Result<T[],
getAllItems() database
T> ErrorType>
misconfiguration,
for example (no
items found can
just be an empty
array)
Return a list of
single items from
multiple
invocations, or
`Result<Result
BatchResult< saveMultipleItems(ite error -- or an error
<T, ErrorType>,
T> ms) if something
ErrorType>
prevented any of
the invocations
(e.g. database
misconfiguration)
deleteItems(items): BatchResult
Take an array of items and delete them from the database - DeleteCommand
o Don't delete history
getItems(ids): BatchResult
Get each item by its ID - GetCommand (but see below)
If the lookup(s) can't be invoked at all, return an ErrorType.
If the lookup(s) can be invoked, return a list of those items or error (for
example, if not found).
There's the possibility that DynamoDB will allow you to do all of this at once
(BatchGetItem, I think) instead of making multiple GetItem calls.
saveItems(items): BatchResult
Save each item - PutCommand
If the writes can't be invoked at all, return an ErrorType.
If the write can be invoked, return a list of those items or error (for example,
if SDK error).
There's the possibility that DynamoDB will allow you to do all of this at once
(BatchPutItem, I think) instead of making multiple GetItem calls.
Additional Notes
I plan to update the unit tests as we go; right now they're pretty sparse.
Let me know if you have any questions.