本文整理汇总了Golang中github.com/aws/aws-sdk-go/service/dynamodb.DynamoDB.WaitUntilTableExists方法的典型用法代码示例。如果您正苦于以下问题:Golang DynamoDB.WaitUntilTableExists方法的具体用法?Golang DynamoDB.WaitUntilTableExists怎么用?Golang DynamoDB.WaitUntilTableExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/aws/aws-sdk-go/service/dynamodb.DynamoDB
的用法示例。
在下文中一共展示了DynamoDB.WaitUntilTableExists方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: prepareDynamoDBTable
// prepareDynamoDBTable prepares DynamoDB table and it returns table name.
func prepareDynamoDBTable(dynamodbClient *dynamodb.DynamoDB) string {
dummyTableName := randSeq(10)
input := newTestCreateTableInput(dummyTableName)
dynamodbClient.CreateTable(input)
dynamodbClient.WaitUntilTableExists(&dynamodb.DescribeTableInput{
TableName: aws.String(dummyTableName),
})
return dummyTableName
}
示例2: createTable
func createTable(db *dynamodb.DynamoDB, createParams *dynamodb.CreateTableInput) error {
_, err := db.CreateTable(createParams)
if err != nil {
return err
}
describeParams := &dynamodb.DescribeTableInput{
TableName: aws.String(*createParams.TableName),
}
if err := db.WaitUntilTableExists(describeParams); err != nil {
return err
}
return nil
}
示例3: ensureTableExists
// ensureTableExists creates a DynamoDB table with a given
// DynamoDB client. If the table already exists, it is not
// being reconfigured.
func ensureTableExists(client *dynamodb.DynamoDB, table string, readCapacity, writeCapacity int) error {
_, err := client.DescribeTable(&dynamodb.DescribeTableInput{
TableName: aws.String(table),
})
if awserr, ok := err.(awserr.Error); ok {
if awserr.Code() == "ResourceNotFoundException" {
_, err = client.CreateTable(&dynamodb.CreateTableInput{
TableName: aws.String(table),
ProvisionedThroughput: &dynamodb.ProvisionedThroughput{
ReadCapacityUnits: aws.Int64(int64(readCapacity)),
WriteCapacityUnits: aws.Int64(int64(writeCapacity)),
},
KeySchema: []*dynamodb.KeySchemaElement{{
AttributeName: aws.String("Path"),
KeyType: aws.String("HASH"),
}, {
AttributeName: aws.String("Key"),
KeyType: aws.String("RANGE"),
}},
AttributeDefinitions: []*dynamodb.AttributeDefinition{{
AttributeName: aws.String("Path"),
AttributeType: aws.String("S"),
}, {
AttributeName: aws.String("Key"),
AttributeType: aws.String("S"),
}},
})
if err != nil {
return err
}
err = client.WaitUntilTableExists(&dynamodb.DescribeTableInput{
TableName: aws.String(table),
})
if err != nil {
return err
}
}
}
if err != nil {
return err
}
return nil
}