mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
Add List Cluster Metadata API (#2206)
* Add List Cluster Metdata API Co-authored-by: yux0 <[email protected]>
This commit is contained in:
committed by
GitHub
co-authored by
yux0
parent
0ec9ed2411
commit
dbbbb27dd6
@@ -52,7 +52,10 @@ const (
|
||||
|
||||
updateClusterMetadataQry = `UPDATE cluster_metadata_info SET data = $1, data_encoding = $2, version = $3 WHERE metadata_partition = $4 AND cluster_name = $5`
|
||||
|
||||
getClusterMetadataQry = `SELECT data, data_encoding, version FROM cluster_metadata_info WHERE metadata_partition = $1 AND cluster_name = $2`
|
||||
getClusterMetadataBase = `SELECT data, data_encoding, version FROM cluster_metadata_info `
|
||||
getClusterMetadataQry = getClusterMetadataBase + `WHERE metadata_partition = $1 AND cluster_name = $2`
|
||||
listClusterMetadataQry = getClusterMetadataBase + `WHERE metadata_partition = $1 ORDER BY cluster_name LIMIT $2`
|
||||
listClusterMetadataRangeQry = getClusterMetadataBase + `WHERE metadata_partition = $1 AND cluster_name > $2 ORDER BY cluster_name LIMIT $3`
|
||||
|
||||
writeLockGetClusterMetadataQry = getClusterMetadataQry + ` FOR UPDATE`
|
||||
|
||||
@@ -134,6 +137,32 @@ func (pdb *db) SaveClusterMetadata(
|
||||
)
|
||||
}
|
||||
|
||||
func (pdb *db) ListClusterMetadata(
|
||||
ctx context.Context,
|
||||
filter *sqlplugin.ClusterMetadataFilter,
|
||||
) ([]sqlplugin.ClusterMetadataRow, error) {
|
||||
var err error
|
||||
var rows []sqlplugin.ClusterMetadataRow
|
||||
switch {
|
||||
case len(filter.ClusterName) != 0:
|
||||
err = pdb.conn.SelectContext(ctx,
|
||||
&rows,
|
||||
listClusterMetadataRangeQry,
|
||||
constMetadataPartition,
|
||||
filter.ClusterName,
|
||||
filter.PageSize,
|
||||
)
|
||||
default:
|
||||
err = pdb.conn.SelectContext(ctx,
|
||||
&rows,
|
||||
listClusterMetadataQry,
|
||||
constMetadataPartition,
|
||||
filter.PageSize,
|
||||
)
|
||||
}
|
||||
return rows, err
|
||||
}
|
||||
|
||||
func (pdb *db) GetClusterMetadataV1(ctx context.Context) (*sqlplugin.ClusterMetadataRow, error) {
|
||||
var row sqlplugin.ClusterMetadataRow
|
||||
err := pdb.conn.GetContext(ctx,
|
||||
|
||||
Reference in New Issue
Block a user