backend/remote-state/oss: extract pkName constant
This commit is contained in:
parent
a4178d12d6
commit
07139e453a
|
@ -181,7 +181,7 @@ func deleteOSSBucket(t *testing.T, ossClient *oss.Client, bucketName string) {
|
||||||
func createTablestoreTable(t *testing.T, otsClient *tablestore.TableStoreClient, tableName string) {
|
func createTablestoreTable(t *testing.T, otsClient *tablestore.TableStoreClient, tableName string) {
|
||||||
tableMeta := new(tablestore.TableMeta)
|
tableMeta := new(tablestore.TableMeta)
|
||||||
tableMeta.TableName = tableName
|
tableMeta.TableName = tableName
|
||||||
tableMeta.AddPrimaryKeyColumn("LockID", tablestore.PrimaryKeyType_STRING)
|
tableMeta.AddPrimaryKeyColumn(pkName, tablestore.PrimaryKeyType_STRING)
|
||||||
|
|
||||||
tableOption := new(tablestore.TableOption)
|
tableOption := new(tablestore.TableOption)
|
||||||
tableOption.TimeToAlive = -1
|
tableOption.TimeToAlive = -1
|
||||||
|
|
|
@ -21,9 +21,11 @@ import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Store the last saved serial in tablestore with this suffix for consistency checks.
|
|
||||||
const (
|
const (
|
||||||
|
// Store the last saved serial in tablestore with this suffix for consistency checks.
|
||||||
stateIDSuffix = "-md5"
|
stateIDSuffix = "-md5"
|
||||||
|
|
||||||
|
pkName = "LockID"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -165,7 +167,7 @@ func (c *RemoteClient) Lock(info *state.LockInfo) (string, error) {
|
||||||
PrimaryKey: &tablestore.PrimaryKey{
|
PrimaryKey: &tablestore.PrimaryKey{
|
||||||
PrimaryKeys: []*tablestore.PrimaryKeyColumn{
|
PrimaryKeys: []*tablestore.PrimaryKeyColumn{
|
||||||
{
|
{
|
||||||
ColumnName: "LockID",
|
ColumnName: pkName,
|
||||||
Value: c.lockPath(),
|
Value: c.lockPath(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -214,12 +216,12 @@ func (c *RemoteClient) getMD5() ([]byte, error) {
|
||||||
PrimaryKey: &tablestore.PrimaryKey{
|
PrimaryKey: &tablestore.PrimaryKey{
|
||||||
PrimaryKeys: []*tablestore.PrimaryKeyColumn{
|
PrimaryKeys: []*tablestore.PrimaryKeyColumn{
|
||||||
{
|
{
|
||||||
ColumnName: "LockID",
|
ColumnName: pkName,
|
||||||
Value: c.lockPath() + stateIDSuffix,
|
Value: c.lockPath() + stateIDSuffix,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ColumnsToGet: []string{"LockID", "Digest"},
|
ColumnsToGet: []string{pkName, "Digest"},
|
||||||
MaxVersion: 1,
|
MaxVersion: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,7 +263,7 @@ func (c *RemoteClient) putMD5(sum []byte) error {
|
||||||
PrimaryKey: &tablestore.PrimaryKey{
|
PrimaryKey: &tablestore.PrimaryKey{
|
||||||
PrimaryKeys: []*tablestore.PrimaryKeyColumn{
|
PrimaryKeys: []*tablestore.PrimaryKeyColumn{
|
||||||
{
|
{
|
||||||
ColumnName: "LockID",
|
ColumnName: pkName,
|
||||||
Value: c.lockPath() + stateIDSuffix,
|
Value: c.lockPath() + stateIDSuffix,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -302,7 +304,7 @@ func (c *RemoteClient) deleteMD5() error {
|
||||||
PrimaryKey: &tablestore.PrimaryKey{
|
PrimaryKey: &tablestore.PrimaryKey{
|
||||||
PrimaryKeys: []*tablestore.PrimaryKeyColumn{
|
PrimaryKeys: []*tablestore.PrimaryKeyColumn{
|
||||||
{
|
{
|
||||||
ColumnName: "LockID",
|
ColumnName: pkName,
|
||||||
Value: c.lockPath() + stateIDSuffix,
|
Value: c.lockPath() + stateIDSuffix,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -328,12 +330,12 @@ func (c *RemoteClient) getLockInfo() (*state.LockInfo, error) {
|
||||||
PrimaryKey: &tablestore.PrimaryKey{
|
PrimaryKey: &tablestore.PrimaryKey{
|
||||||
PrimaryKeys: []*tablestore.PrimaryKeyColumn{
|
PrimaryKeys: []*tablestore.PrimaryKeyColumn{
|
||||||
{
|
{
|
||||||
ColumnName: "LockID",
|
ColumnName: pkName,
|
||||||
Value: c.lockPath(),
|
Value: c.lockPath(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ColumnsToGet: []string{"LockID", "Info"},
|
ColumnsToGet: []string{pkName, "Info"},
|
||||||
MaxVersion: 1,
|
MaxVersion: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,7 +383,7 @@ func (c *RemoteClient) Unlock(id string) error {
|
||||||
PrimaryKey: &tablestore.PrimaryKey{
|
PrimaryKey: &tablestore.PrimaryKey{
|
||||||
PrimaryKeys: []*tablestore.PrimaryKeyColumn{
|
PrimaryKeys: []*tablestore.PrimaryKeyColumn{
|
||||||
{
|
{
|
||||||
ColumnName: "LockID",
|
ColumnName: pkName,
|
||||||
Value: c.lockPath(),
|
Value: c.lockPath(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue