Skip to content

Commit

Permalink
Multitenant DynamoDB collector should use a string for the hash key.
Browse files Browse the repository at this point in the history
This is because the key is of the form "<userid>-<hour bucket>", but as I was testing without a userid, I didn't notice that "-<hour bucket>" was a valid number.
  • Loading branch information
tomwilkie committed Apr 6, 2016
1 parent c9b323f commit fd75e45
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/multitenant/dynamo_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (c *dynamoDBCollector) CreateTables() error {
AttributeDefinitions: []*dynamodb.AttributeDefinition{
{
AttributeName: aws.String(hourField),
AttributeType: aws.String("N"),
AttributeType: aws.String("S"),
},
{
AttributeName: aws.String(tsField),
Expand Down Expand Up @@ -104,7 +104,7 @@ func (c *dynamoDBCollector) getRows(userid string, row int64, start, end time.Ti
KeyConditions: map[string]*dynamodb.Condition{
hourField: {
AttributeValueList: []*dynamodb.AttributeValue{
{N: aws.String(rowKey)},
{S: aws.String(rowKey)},
},
ComparisonOperator: aws.String("EQ"),
},
Expand Down Expand Up @@ -158,11 +158,11 @@ func (c *dynamoDBCollector) Report(ctx context.Context) (report.Report, error) {
// Queries will only every span 2 rows max.
if rowStart != rowEnd {
if result, err = c.getRows(userid, rowStart, start, now, result); err != nil {
return report.MakeReport(), nil
return report.MakeReport(), err
}
}
if result, err = c.getRows(userid, rowEnd, start, now, result); err != nil {
return report.MakeReport(), nil
return report.MakeReport(), err
}
return result, nil
}
Expand All @@ -186,7 +186,7 @@ func (c *dynamoDBCollector) Add(ctx context.Context, rep report.Report) error {
TableName: aws.String(tableName),
Item: map[string]*dynamodb.AttributeValue{
hourField: {
N: aws.String(rowKey),
S: aws.String(rowKey),
},
tsField: {
N: aws.String(strconv.FormatInt(now.UnixNano(), 10)),
Expand Down

0 comments on commit fd75e45

Please sign in to comment.