Пример #1
0
func (s *DynamoStore) UpdateRoot(current, last hash.Hash) bool {
	s.requestWg.Wait()

	putArgs := dynamodb.PutItemInput{
		TableName: aws.String(s.table),
		Item: map[string]*dynamodb.AttributeValue{
			refAttr:   {B: s.rootKey},
			chunkAttr: {B: current.DigestSlice()},
			compAttr:  {S: aws.String(noneValue)},
		},
	}

	if last.IsEmpty() {
		putArgs.ConditionExpression = aws.String(valueNotExistsExpression)
	} else {
		putArgs.ConditionExpression = aws.String(valueEqualsExpression)
		putArgs.ExpressionAttributeValues = map[string]*dynamodb.AttributeValue{
			":prev": {B: last.DigestSlice()},
		}
	}

	_, err := s.ddbsvc.PutItem(&putArgs)
	if err != nil {
		if awsErr, ok := err.(awserr.Error); ok {
			if awsErr.Code() == "ConditionalCheckFailedException" {
				return false
			}
			d.Chk.NoError(awsErr)
		} else {
			d.Chk.NoError(err)
		}
	}

	return true
}
Пример #2
0
func putItemInput() *dynamodb.PutItemInput {
	var input = new(dynamodb.PutItemInput)
	input.TableName = aws.String("Accounts")
	var data = make(map[string]*dynamodb.AttributeValue)
	data["uuid"] = new(dynamodb.AttributeValue)
	data["uuid"].S = aws.String("HFG-FGG-FFG")
	data["username"] = new(dynamodb.AttributeValue)
	data["username"].S = aws.String("blairehh")
	data["password"] = new(dynamodb.AttributeValue)
	data["password"].S = aws.String("fsdfsdfsd")
	data["salt"] = new(dynamodb.AttributeValue)
	data["salt"].S = aws.String("fsfsd")
	data["dbloc"] = new(dynamodb.AttributeValue)
	data["dbloc"].S = aws.String("127.0.0.1/blairehh")
	input.Item = data
	return input
}