cosmium/internal/repositories/partition_key_ranges.go

47 lines
1.4 KiB
Go
Raw Normal View History

2024-02-10 23:44:20 +00:00
package repositories
import (
"fmt"
"github.com/google/uuid"
repositorymodels "github.com/pikami/cosmium/internal/repository_models"
"github.com/pikami/cosmium/internal/resourceid"
)
// I have no idea what this is tbh
func GetPartitionKeyRanges(databaseId string, collectionId string) ([]repositorymodels.PartitionKeyRange, repositorymodels.RepositoryStatus) {
2024-02-27 18:08:48 +00:00
databaseRid := databaseId
collectionRid := collectionId
var timestamp int64 = 0
if database, ok := storeState.Databases[databaseId]; !ok {
databaseRid = database.ResourceID
}
2024-02-27 18:08:48 +00:00
if collection, ok := storeState.Collections[databaseId][collectionId]; !ok {
collectionRid = collection.ResourceID
timestamp = collection.TimeStamp
}
2024-02-27 18:08:48 +00:00
pkrResourceId := resourceid.NewCombined(databaseRid, collectionRid, resourceid.New())
pkrSelf := fmt.Sprintf("dbs/%s/colls/%s/pkranges/%s/", databaseRid, collectionRid, pkrResourceId)
etag := fmt.Sprintf("\"%s\"", uuid.New())
return []repositorymodels.PartitionKeyRange{
2024-02-10 23:44:20 +00:00
{
ResourceID: pkrResourceId,
2024-02-10 23:44:20 +00:00
ID: "0",
Etag: etag,
2024-02-10 23:44:20 +00:00
MinInclusive: "",
MaxExclusive: "FF",
RidPrefix: 0,
Self: pkrSelf,
2024-02-10 23:44:20 +00:00
ThroughputFraction: 1,
Status: "online",
Parents: []interface{}{},
2024-02-27 18:08:48 +00:00
TimeStamp: timestamp,
2024-02-10 23:44:20 +00:00
Lsn: 17,
},
}, repositorymodels.StatusOk
2024-02-10 23:44:20 +00:00
}