2024-02-10 23:44:20 +00:00
|
|
|
package repositories
|
|
|
|
|
2024-02-26 19:03:47 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
2024-02-12 19:38:03 +00:00
|
|
|
|
2024-02-26 19:03:47 +00:00
|
|
|
"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
|
2024-02-12 19:38:03 +00:00
|
|
|
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-26 19:03:47 +00:00
|
|
|
}
|
|
|
|
|
2024-02-27 18:08:48 +00:00
|
|
|
if collection, ok := storeState.Collections[databaseId][collectionId]; !ok {
|
|
|
|
collectionRid = collection.ResourceID
|
|
|
|
timestamp = collection.TimeStamp
|
2024-02-26 19:03:47 +00:00
|
|
|
}
|
|
|
|
|
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)
|
2024-02-26 19:03:47 +00:00
|
|
|
etag := fmt.Sprintf("\"%s\"", uuid.New())
|
|
|
|
|
2024-02-12 19:38:03 +00:00
|
|
|
return []repositorymodels.PartitionKeyRange{
|
2024-02-10 23:44:20 +00:00
|
|
|
{
|
2024-02-26 19:03:47 +00:00
|
|
|
ResourceID: pkrResourceId,
|
2024-02-10 23:44:20 +00:00
|
|
|
ID: "0",
|
2024-02-26 19:03:47 +00:00
|
|
|
Etag: etag,
|
2024-02-10 23:44:20 +00:00
|
|
|
MinInclusive: "",
|
|
|
|
MaxExclusive: "FF",
|
|
|
|
RidPrefix: 0,
|
2024-02-26 19:03:47 +00:00
|
|
|
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,
|
|
|
|
},
|
2024-02-12 19:38:03 +00:00
|
|
|
}, repositorymodels.StatusOk
|
2024-02-10 23:44:20 +00:00
|
|
|
}
|