mirror of
https://github.com/pikami/cosmium.git
synced 2026-01-31 15:22:58 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3daba9d0eb | ||
|
|
d3d238fa98 | ||
|
|
cae6fda95c | ||
|
|
46c446c273 |
58
.github/workflows/compile-shared-libraries.yml
vendored
58
.github/workflows/compile-shared-libraries.yml
vendored
@@ -7,6 +7,9 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
artifact: shared-libraries
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
@@ -29,3 +32,58 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: shared-libraries
|
name: shared-libraries
|
||||||
path: dist/*
|
path: dist/*
|
||||||
|
|
||||||
|
test:
|
||||||
|
needs: build
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: ubuntu-latest
|
||||||
|
lib_ext: amd64.so
|
||||||
|
- os: windows-latest
|
||||||
|
lib_ext: amd64.dll
|
||||||
|
- os: macos-latest
|
||||||
|
lib_ext: arm64.dylib
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Download shared libraries
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: shared-libraries
|
||||||
|
path: libs
|
||||||
|
|
||||||
|
- name: Install MinGW (GCC) on Windows
|
||||||
|
if: runner.os == 'Windows'
|
||||||
|
run: choco install mingw --no-progress
|
||||||
|
|
||||||
|
- name: Build test loader (Windows)
|
||||||
|
if: runner.os == 'Windows'
|
||||||
|
run: |
|
||||||
|
mkdir build
|
||||||
|
gcc -Wall -o build/test_loader.exe sharedlibrary/tests/*.c
|
||||||
|
|
||||||
|
- name: Build test loader (Unix)
|
||||||
|
if: runner.os != 'Windows'
|
||||||
|
run: |
|
||||||
|
mkdir build
|
||||||
|
gcc -Wall -ldl -o build/test_loader sharedlibrary/tests/*.c
|
||||||
|
|
||||||
|
- name: Run test (Unix)
|
||||||
|
if: runner.os != 'Windows'
|
||||||
|
run: |
|
||||||
|
LIB=$(ls libs/*${{ matrix.lib_ext }} | head -n 1)
|
||||||
|
echo "Testing library: $LIB"
|
||||||
|
chmod +x build/test_loader
|
||||||
|
./build/test_loader "$LIB"
|
||||||
|
|
||||||
|
- name: Run test (Windows)
|
||||||
|
if: runner.os == 'Windows'
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
$lib = Get-ChildItem "libs/*${{ matrix.lib_ext }}" | Select-Object -First 1
|
||||||
|
Write-Host "Testing library: $($lib.FullName)"
|
||||||
|
.\build\test_loader.exe $lib.FullName
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import (
|
|||||||
apimodels "github.com/pikami/cosmium/api/api_models"
|
apimodels "github.com/pikami/cosmium/api/api_models"
|
||||||
"github.com/pikami/cosmium/api/headers"
|
"github.com/pikami/cosmium/api/headers"
|
||||||
"github.com/pikami/cosmium/internal/constants"
|
"github.com/pikami/cosmium/internal/constants"
|
||||||
|
continuationtoken "github.com/pikami/cosmium/internal/continuation_token"
|
||||||
"github.com/pikami/cosmium/internal/converters"
|
"github.com/pikami/cosmium/internal/converters"
|
||||||
"github.com/pikami/cosmium/internal/datastore"
|
"github.com/pikami/cosmium/internal/datastore"
|
||||||
"github.com/pikami/cosmium/internal/logger"
|
"github.com/pikami/cosmium/internal/logger"
|
||||||
@@ -262,20 +263,50 @@ func (h *Handlers) handleDocumentQuery(c *gin.Context, requestBody map[string]in
|
|||||||
queryParameters = parametersToMap(paramsArray)
|
queryParameters = parametersToMap(paramsArray)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
collection, collectionStatus := h.dataStore.GetCollection(databaseId, collectionId)
|
||||||
|
if collectionStatus == datastore.StatusNotFound {
|
||||||
|
c.IndentedJSON(http.StatusNotFound, constants.NotFoundResponse)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if collectionStatus != datastore.StatusOk {
|
||||||
|
c.IndentedJSON(http.StatusInternalServerError, constants.UnknownErrorResponse)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
continuationToken := continuationtoken.GenerateDefault(collection.ResourceID)
|
||||||
|
continuationTokenHeader := c.GetHeader(headers.ContinuationToken)
|
||||||
|
if continuationTokenHeader != "" {
|
||||||
|
continuationToken = continuationtoken.FromString(continuationTokenHeader)
|
||||||
|
}
|
||||||
|
|
||||||
|
pageMaxItemCount, maxItemCountError := strconv.Atoi(c.GetHeader(headers.MaxItemCount))
|
||||||
|
if maxItemCountError != nil {
|
||||||
|
pageMaxItemCount = 1000
|
||||||
|
}
|
||||||
|
|
||||||
queryText := requestBody["query"].(string)
|
queryText := requestBody["query"].(string)
|
||||||
docs, status := h.executeQueryDocuments(databaseId, collectionId, queryText, queryParameters)
|
executeQueryResult, status := h.executeQueryDocuments(
|
||||||
|
databaseId, collectionId, queryText, queryParameters, pageMaxItemCount, continuationToken.Token.TotalResults)
|
||||||
if status != datastore.StatusOk {
|
if status != datastore.StatusOk {
|
||||||
// TODO: Currently we return everything if the query fails
|
// TODO: Currently we return everything if the query fails
|
||||||
|
logger.Infof("Query failed: %s", queryText)
|
||||||
h.GetAllDocuments(c)
|
h.GetAllDocuments(c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
collection, _ := h.dataStore.GetCollection(databaseId, collectionId)
|
resultCount := len(executeQueryResult.Rows)
|
||||||
c.Header(headers.ItemCount, fmt.Sprintf("%d", len(docs)))
|
if executeQueryResult.HasMorePages {
|
||||||
|
nextContinuationToken := continuationtoken.Generate(
|
||||||
|
collection.ResourceID, continuationToken.Token.PageIndex+1, continuationToken.Token.TotalResults+resultCount)
|
||||||
|
c.Header(headers.ContinuationToken, nextContinuationToken.ToString())
|
||||||
|
}
|
||||||
|
|
||||||
|
c.Header(headers.ItemCount, fmt.Sprintf("%d", resultCount))
|
||||||
c.IndentedJSON(http.StatusOK, gin.H{
|
c.IndentedJSON(http.StatusOK, gin.H{
|
||||||
"_rid": collection.ResourceID,
|
"_rid": collection.ResourceID,
|
||||||
"Documents": docs,
|
"Documents": executeQueryResult.Rows,
|
||||||
"_count": len(docs),
|
"_count": resultCount,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -377,16 +408,23 @@ func dataStoreStatusToResponseCode(status datastore.DataStoreStatus) int {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handlers) executeQueryDocuments(databaseId string, collectionId string, query string, queryParameters map[string]interface{}) ([]memoryexecutor.RowType, datastore.DataStoreStatus) {
|
func (h *Handlers) executeQueryDocuments(
|
||||||
|
databaseId string,
|
||||||
|
collectionId string,
|
||||||
|
query string,
|
||||||
|
queryParameters map[string]interface{},
|
||||||
|
pageMaxItemCount int,
|
||||||
|
pageCursor int,
|
||||||
|
) (memoryexecutor.ExecuteQueryResult, datastore.DataStoreStatus) {
|
||||||
parsedQuery, err := nosql.Parse("", []byte(query))
|
parsedQuery, err := nosql.Parse("", []byte(query))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("Failed to parse query: %s\nerr: %v", query, err)
|
logger.Errorf("Failed to parse query: %s\nerr: %v", query, err)
|
||||||
return nil, datastore.BadRequest
|
return memoryexecutor.ExecuteQueryResult{}, datastore.BadRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
allDocumentsIterator, status := h.dataStore.GetDocumentIterator(databaseId, collectionId)
|
allDocumentsIterator, status := h.dataStore.GetDocumentIterator(databaseId, collectionId)
|
||||||
if status != datastore.StatusOk {
|
if status != datastore.StatusOk {
|
||||||
return nil, status
|
return memoryexecutor.ExecuteQueryResult{}, status
|
||||||
}
|
}
|
||||||
defer allDocumentsIterator.Close()
|
defer allDocumentsIterator.Close()
|
||||||
|
|
||||||
@@ -394,8 +432,8 @@ func (h *Handlers) executeQueryDocuments(databaseId string, collectionId string,
|
|||||||
|
|
||||||
if typedQuery, ok := parsedQuery.(parsers.SelectStmt); ok {
|
if typedQuery, ok := parsedQuery.(parsers.SelectStmt); ok {
|
||||||
typedQuery.Parameters = queryParameters
|
typedQuery.Parameters = queryParameters
|
||||||
return memoryexecutor.ExecuteQuery(typedQuery, rowsIterator), datastore.StatusOk
|
return memoryexecutor.ExecuteQuery(typedQuery, rowsIterator, pageCursor, pageMaxItemCount), datastore.StatusOk
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, datastore.BadRequest
|
return memoryexecutor.ExecuteQueryResult{}, datastore.BadRequest
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ const (
|
|||||||
ItemCount = "x-ms-item-count"
|
ItemCount = "x-ms-item-count"
|
||||||
LSN = "lsn"
|
LSN = "lsn"
|
||||||
XDate = "x-ms-date"
|
XDate = "x-ms-date"
|
||||||
|
MaxItemCount = "x-ms-max-item-count"
|
||||||
|
ContinuationToken = "x-ms-continuation"
|
||||||
|
|
||||||
// Kinda retarded, but what can I do ¯\_(ツ)_/¯
|
// Kinda retarded, but what can I do ¯\_(ツ)_/¯
|
||||||
IsQuery = "x-ms-documentdb-isquery" // Sent from python sdk and web explorer
|
IsQuery = "x-ms-documentdb-isquery" // Sent from python sdk and web explorer
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import (
|
|||||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
|
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
|
||||||
"github.com/Azure/azure-sdk-for-go/sdk/data/azcosmos"
|
"github.com/Azure/azure-sdk-for-go/sdk/data/azcosmos"
|
||||||
"github.com/pikami/cosmium/api/config"
|
"github.com/pikami/cosmium/api/config"
|
||||||
|
continuationtoken "github.com/pikami/cosmium/internal/continuation_token"
|
||||||
"github.com/pikami/cosmium/internal/datastore"
|
"github.com/pikami/cosmium/internal/datastore"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
@@ -512,4 +513,46 @@ func Test_Documents(t *testing.T) {
|
|||||||
assert.Equal(t, "67890", itemResponseBody["id"])
|
assert.Equal(t, "67890", itemResponseBody["id"])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
runTestsWithPresets(t, "Test_Documents_With_Continuation_Token", presets, func(t *testing.T, ts *TestServer, client *azcosmos.Client) {
|
||||||
|
collectionClient := documents_InitializeDb(t, ts)
|
||||||
|
|
||||||
|
t.Run("Should query document with continuation token", func(t *testing.T) {
|
||||||
|
context := context.TODO()
|
||||||
|
pager := collectionClient.NewQueryItemsPager(
|
||||||
|
"SELECT c.id, c[\"pk\"] FROM c ORDER BY c.id",
|
||||||
|
azcosmos.PartitionKey{},
|
||||||
|
&azcosmos.QueryOptions{
|
||||||
|
PageSizeHint: 1,
|
||||||
|
})
|
||||||
|
|
||||||
|
assert.True(t, pager.More())
|
||||||
|
|
||||||
|
firstResponse, err := pager.NextPage(context)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Equal(t, 1, len(firstResponse.Items))
|
||||||
|
var firstItem map[string]interface{}
|
||||||
|
err = json.Unmarshal(firstResponse.Items[0], &firstItem)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Equal(t, "12345", firstItem["id"])
|
||||||
|
assert.Equal(t, "123", firstItem["pk"])
|
||||||
|
|
||||||
|
firstContinuationToken := continuationtoken.FromString(*firstResponse.ContinuationToken)
|
||||||
|
assert.Equal(t, 1, firstContinuationToken.Token.PageIndex)
|
||||||
|
assert.Equal(t, 1, firstContinuationToken.Token.TotalResults)
|
||||||
|
|
||||||
|
assert.True(t, pager.More())
|
||||||
|
secondResponse, err := pager.NextPage(context)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Equal(t, 1, len(secondResponse.Items))
|
||||||
|
var secondItem map[string]interface{}
|
||||||
|
err = json.Unmarshal(secondResponse.Items[0], &secondItem)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Equal(t, "67890", secondItem["id"])
|
||||||
|
assert.Equal(t, "456", secondItem["pk"])
|
||||||
|
assert.Nil(t, secondResponse.ContinuationToken)
|
||||||
|
|
||||||
|
assert.False(t, pager.More())
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
51
go.mod
51
go.mod
@@ -3,40 +3,40 @@ module github.com/pikami/cosmium
|
|||||||
go 1.24.7
|
go 1.24.7
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.19.1
|
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/data/azcosmos v1.4.1
|
github.com/Azure/azure-sdk-for-go/sdk/data/azcosmos v1.4.2
|
||||||
github.com/cosmiumdev/json-patch/v5 v5.9.11
|
github.com/cosmiumdev/json-patch/v5 v5.9.11
|
||||||
github.com/dgraph-io/badger/v4 v4.8.0
|
github.com/dgraph-io/badger/v4 v4.9.0
|
||||||
github.com/gin-gonic/gin v1.11.0
|
github.com/gin-gonic/gin v1.11.0
|
||||||
github.com/google/uuid v1.6.0
|
github.com/google/uuid v1.6.0
|
||||||
github.com/stretchr/testify v1.11.1
|
github.com/stretchr/testify v1.11.1
|
||||||
github.com/vmihailenco/msgpack/v5 v5.4.1
|
github.com/vmihailenco/msgpack/v5 v5.4.1
|
||||||
golang.org/x/exp v0.0.0-20251002181428-27f1f14c8bb9
|
golang.org/x/exp v0.0.0-20260112195511-716be5621a96
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Azure/azure-sdk-for-go v68.0.0+incompatible // indirect
|
github.com/Azure/azure-sdk-for-go v68.0.0+incompatible // indirect
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 // indirect
|
github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 // indirect
|
||||||
github.com/bytedance/gopkg v0.1.3 // indirect
|
github.com/bytedance/gopkg v0.1.3 // indirect
|
||||||
github.com/bytedance/sonic v1.14.1 // indirect
|
github.com/bytedance/sonic v1.15.0 // indirect
|
||||||
github.com/bytedance/sonic/loader v0.3.0 // indirect
|
github.com/bytedance/sonic/loader v0.5.0 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||||
github.com/cloudwego/base64x v0.1.6 // indirect
|
github.com/cloudwego/base64x v0.1.6 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/dgraph-io/ristretto/v2 v2.3.0 // indirect
|
github.com/dgraph-io/ristretto/v2 v2.4.0 // indirect
|
||||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||||
github.com/gabriel-vasile/mimetype v1.4.10 // indirect
|
github.com/gabriel-vasile/mimetype v1.4.12 // indirect
|
||||||
github.com/gin-contrib/sse v1.1.0 // indirect
|
github.com/gin-contrib/sse v1.1.0 // indirect
|
||||||
github.com/go-logr/logr v1.4.3 // indirect
|
github.com/go-logr/logr v1.4.3 // indirect
|
||||||
github.com/go-logr/stdr v1.2.2 // indirect
|
github.com/go-logr/stdr v1.2.2 // indirect
|
||||||
github.com/go-playground/locales v0.14.1 // indirect
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
github.com/go-playground/validator/v10 v10.28.0 // indirect
|
github.com/go-playground/validator/v10 v10.30.1 // indirect
|
||||||
github.com/goccy/go-json v0.10.5 // indirect
|
github.com/goccy/go-json v0.10.5 // indirect
|
||||||
github.com/goccy/go-yaml v1.18.0 // indirect
|
github.com/goccy/go-yaml v1.19.2 // indirect
|
||||||
github.com/google/flatbuffers v25.9.23+incompatible // indirect
|
github.com/google/flatbuffers v25.12.19+incompatible // indirect
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
github.com/klauspost/compress v1.18.0 // indirect
|
github.com/klauspost/compress v1.18.3 // indirect
|
||||||
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
||||||
github.com/leodido/go-urn v1.4.0 // indirect
|
github.com/leodido/go-urn v1.4.0 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
@@ -44,24 +44,21 @@ require (
|
|||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/quic-go/qpack v0.5.1 // indirect
|
github.com/quic-go/qpack v0.6.0 // indirect
|
||||||
github.com/quic-go/quic-go v0.55.0 // indirect
|
github.com/quic-go/quic-go v0.59.0 // indirect
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||||
github.com/ugorji/go/codec v1.3.0 // indirect
|
github.com/ugorji/go/codec v1.3.1 // indirect
|
||||||
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
|
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
|
||||||
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
|
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
|
||||||
go.opentelemetry.io/otel v1.38.0 // indirect
|
go.opentelemetry.io/otel v1.39.0 // indirect
|
||||||
go.opentelemetry.io/otel/metric v1.38.0 // indirect
|
go.opentelemetry.io/otel/metric v1.39.0 // indirect
|
||||||
go.opentelemetry.io/otel/trace v1.38.0 // indirect
|
go.opentelemetry.io/otel/trace v1.39.0 // indirect
|
||||||
go.uber.org/mock v0.6.0 // indirect
|
go.uber.org/mock v0.6.0 // indirect
|
||||||
golang.org/x/arch v0.22.0 // indirect
|
golang.org/x/arch v0.23.0 // indirect
|
||||||
golang.org/x/crypto v0.43.0 // indirect
|
golang.org/x/crypto v0.47.0 // indirect
|
||||||
golang.org/x/mod v0.29.0 // indirect
|
golang.org/x/net v0.49.0 // indirect
|
||||||
golang.org/x/net v0.45.0 // indirect
|
golang.org/x/sys v0.40.0 // indirect
|
||||||
golang.org/x/sync v0.17.0 // indirect
|
golang.org/x/text v0.33.0 // indirect
|
||||||
golang.org/x/sys v0.37.0 // indirect
|
google.golang.org/protobuf v1.36.11 // indirect
|
||||||
golang.org/x/text v0.30.0 // indirect
|
|
||||||
golang.org/x/tools v0.37.0 // indirect
|
|
||||||
google.golang.org/protobuf v1.36.10 // indirect
|
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
106
go.sum
106
go.sum
@@ -1,21 +1,21 @@
|
|||||||
github.com/Azure/azure-sdk-for-go v68.0.0+incompatible h1:fcYLmCpyNYRnvJbPerq7U0hS+6+I79yEDJBqVNcqUzU=
|
github.com/Azure/azure-sdk-for-go v68.0.0+incompatible h1:fcYLmCpyNYRnvJbPerq7U0hS+6+I79yEDJBqVNcqUzU=
|
||||||
github.com/Azure/azure-sdk-for-go v68.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
|
github.com/Azure/azure-sdk-for-go v68.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.19.1 h1:5YTBM8QDVIBN3sxBil89WfdAAqDZbyJTgh688DSxX5w=
|
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0 h1:fou+2+WFTib47nS+nz/ozhEBnvU96bKHy6LjRsY4E28=
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.19.1/go.mod h1:YD5h/ldMsG0XiIw7PdyNhLxaM317eFh5yNLccNfGdyw=
|
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0/go.mod h1:t76Ruy8AHvUAC8GfMWJMa0ElSbuIcO03NLpynfbgsPA=
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.1 h1:B+blDbyVIG3WaikNxPnhPiJ1MThR03b3vKGtER95TP4=
|
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.1 h1:B+blDbyVIG3WaikNxPnhPiJ1MThR03b3vKGtER95TP4=
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.1/go.mod h1:JdM5psgjfBf5fo2uWOZhflPWyDBZ/O/CNAH9CtsuZE4=
|
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.1/go.mod h1:JdM5psgjfBf5fo2uWOZhflPWyDBZ/O/CNAH9CtsuZE4=
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/data/azcosmos v1.4.1 h1:ToPLhnXvatKVN4ZkcxLOwcXOJhdu4iQl8w0efeuDz9Y=
|
github.com/Azure/azure-sdk-for-go/sdk/data/azcosmos v1.4.2 h1:zqxnp53f5Jn5PFU5Av4mvyWEbZ7whg72AoOCEzlXFKc=
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/data/azcosmos v1.4.1/go.mod h1:Krtog/7tz27z75TwM5cIS8bxEH4dcBUezcq+kGVeZEo=
|
github.com/Azure/azure-sdk-for-go/sdk/data/azcosmos v1.4.2/go.mod h1:Krtog/7tz27z75TwM5cIS8bxEH4dcBUezcq+kGVeZEo=
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 h1:9iefClla7iYpfYWdzPCRDozdmndjTm8DXdpCzPajMgA=
|
github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 h1:9iefClla7iYpfYWdzPCRDozdmndjTm8DXdpCzPajMgA=
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2/go.mod h1:XtLgD3ZD34DAaVIIAyG3objl5DynM3CQ/vMcbBNJZGI=
|
github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2/go.mod h1:XtLgD3ZD34DAaVIIAyG3objl5DynM3CQ/vMcbBNJZGI=
|
||||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 h1:oygO0locgZJe7PpYPXT5A29ZkwJaPqcva7BVeemZOZs=
|
github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 h1:oygO0locgZJe7PpYPXT5A29ZkwJaPqcva7BVeemZOZs=
|
||||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI=
|
github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI=
|
||||||
github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M=
|
github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M=
|
||||||
github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM=
|
github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM=
|
||||||
github.com/bytedance/sonic v1.14.1 h1:FBMC0zVz5XUmE4z9wF4Jey0An5FueFvOsTKKKtwIl7w=
|
github.com/bytedance/sonic v1.15.0 h1:/PXeWFaR5ElNcVE84U0dOHjiMHQOwNIx3K4ymzh/uSE=
|
||||||
github.com/bytedance/sonic v1.14.1/go.mod h1:gi6uhQLMbTdeP0muCnrjHLeCUPyb70ujhnNlhOylAFc=
|
github.com/bytedance/sonic v1.15.0/go.mod h1:tFkWrPz0/CUCLEF4ri4UkHekCIcdnkqXw9VduqpJh0k=
|
||||||
github.com/bytedance/sonic/loader v0.3.0 h1:dskwH8edlzNMctoruo8FPTJDF3vLtDT0sXZwvZJyqeA=
|
github.com/bytedance/sonic/loader v0.5.0 h1:gXH3KVnatgY7loH5/TkeVyXPfESoqSBSBEiDd5VjlgE=
|
||||||
github.com/bytedance/sonic/loader v0.3.0/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
|
github.com/bytedance/sonic/loader v0.5.0/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo=
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M=
|
github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M=
|
||||||
@@ -25,16 +25,16 @@ github.com/cosmiumdev/json-patch/v5 v5.9.11/go.mod h1:YPZmckmv4ZY+oxKIOjgq3sIudH
|
|||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/dgraph-io/badger/v4 v4.8.0 h1:JYph1ChBijCw8SLeybvPINizbDKWZ5n/GYbz2yhN/bs=
|
github.com/dgraph-io/badger/v4 v4.9.0 h1:tpqWb0NewSrCYqTvywbcXOhQdWcqephkVkbBmaaqHzc=
|
||||||
github.com/dgraph-io/badger/v4 v4.8.0/go.mod h1:U6on6e8k/RTbUWxqKR0MvugJuVmkxSNc79ap4917h4w=
|
github.com/dgraph-io/badger/v4 v4.9.0/go.mod h1:5/MEx97uzdPUHR4KtkNt8asfI2T4JiEiQlV7kWUo8c0=
|
||||||
github.com/dgraph-io/ristretto/v2 v2.3.0 h1:qTQ38m7oIyd4GAed/QkUZyPFNMnvVWyazGXRwvOt5zk=
|
github.com/dgraph-io/ristretto/v2 v2.4.0 h1:I/w09yLjhdcVD2QV192UJcq8dPBaAJb9pOuMyNy0XlU=
|
||||||
github.com/dgraph-io/ristretto/v2 v2.3.0/go.mod h1:gpoRV3VzrEY1a9dWAYV6T1U7YzfgttXdd/ZzL1s9OZM=
|
github.com/dgraph-io/ristretto/v2 v2.4.0/go.mod h1:0KsrXtXvnv0EqnzyowllbVJB8yBonswa2lTCK2gGo9E=
|
||||||
github.com/dgryski/go-farm v0.0.0-20240924180020-3414d57e47da h1:aIftn67I1fkbMa512G+w+Pxci9hJPB8oMnkcP3iZF38=
|
github.com/dgryski/go-farm v0.0.0-20240924180020-3414d57e47da h1:aIftn67I1fkbMa512G+w+Pxci9hJPB8oMnkcP3iZF38=
|
||||||
github.com/dgryski/go-farm v0.0.0-20240924180020-3414d57e47da/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
|
github.com/dgryski/go-farm v0.0.0-20240924180020-3414d57e47da/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
|
||||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.10 h1:zyueNbySn/z8mJZHLt6IPw0KoZsiQNszIpU+bX4+ZK0=
|
github.com/gabriel-vasile/mimetype v1.4.12 h1:e9hWvmLYvtp846tLHam2o++qitpguFiYCKbn0w9jyqw=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.10/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
|
github.com/gabriel-vasile/mimetype v1.4.12/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
|
||||||
github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w=
|
github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w=
|
||||||
github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM=
|
github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM=
|
||||||
github.com/gin-gonic/gin v1.11.0 h1:OW/6PLjyusp2PPXtyxKHU0RbX6I/l28FTdDlae5ueWk=
|
github.com/gin-gonic/gin v1.11.0 h1:OW/6PLjyusp2PPXtyxKHU0RbX6I/l28FTdDlae5ueWk=
|
||||||
@@ -50,16 +50,16 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
|
|||||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||||
github.com/go-playground/validator/v10 v10.28.0 h1:Q7ibns33JjyW48gHkuFT91qX48KG0ktULL6FgHdG688=
|
github.com/go-playground/validator/v10 v10.30.1 h1:f3zDSN/zOma+w6+1Wswgd9fLkdwy06ntQJp0BBvFG0w=
|
||||||
github.com/go-playground/validator/v10 v10.28.0/go.mod h1:GoI6I1SjPBh9p7ykNE/yj3fFYbyDOpwMn5KXd+m2hUU=
|
github.com/go-playground/validator/v10 v10.30.1/go.mod h1:oSuBIQzuJxL//3MelwSLD5hc2Tu889bF0Idm9Dg26cM=
|
||||||
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
||||||
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||||
github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw=
|
github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM=
|
||||||
github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
|
github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
|
||||||
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
|
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
|
||||||
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||||
github.com/google/flatbuffers v25.9.23+incompatible h1:rGZKv+wOb6QPzIdkM2KxhBZCDrA0DeN6DNmRDrqIsQU=
|
github.com/google/flatbuffers v25.12.19+incompatible h1:haMV2JRRJCe1998HeW/p0X9UaMTK6SDo0ffLn2+DbLs=
|
||||||
github.com/google/flatbuffers v25.9.23+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
|
github.com/google/flatbuffers v25.12.19+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
|
||||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
@@ -67,8 +67,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
|||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
|
github.com/klauspost/compress v1.18.3 h1:9PJRvfbmTabkOX8moIpXPbMMbYN60bWImDDU7L+/6zw=
|
||||||
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
|
github.com/klauspost/compress v1.18.3/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4=
|
||||||
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
|
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
|
||||||
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
@@ -92,60 +92,56 @@ github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmd
|
|||||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
|
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI=
|
github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8=
|
||||||
github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg=
|
github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII=
|
||||||
github.com/quic-go/quic-go v0.55.0 h1:zccPQIqYCXDt5NmcEabyYvOnomjs8Tlwl7tISjJh9Mk=
|
github.com/quic-go/quic-go v0.59.0 h1:OLJkp1Mlm/aS7dpKgTc6cnpynnD2Xg7C1pwL6vy/SAw=
|
||||||
github.com/quic-go/quic-go v0.55.0/go.mod h1:DR51ilwU1uE164KuWXhinFcKWGlEjzys2l8zUl5Ss1U=
|
github.com/quic-go/quic-go v0.59.0/go.mod h1:upnsH4Ju1YkqpLXC305eW3yDZ4NfnNbmQRCMWS58IKU=
|
||||||
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||||
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
|
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
|
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||||
github.com/ugorji/go/codec v1.3.0 h1:Qd2W2sQawAfG8XSvzwhBeoGq71zXOC/Q1E9y/wUcsUA=
|
github.com/ugorji/go/codec v1.3.1 h1:waO7eEiFDwidsBN6agj1vJQ4AG7lh2yqXyOXqhgQuyY=
|
||||||
github.com/ugorji/go/codec v1.3.0/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
|
github.com/ugorji/go/codec v1.3.1/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
|
||||||
github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8=
|
github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8=
|
||||||
github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
|
github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
|
||||||
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
|
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
|
||||||
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
|
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
|
||||||
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
|
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
|
||||||
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
|
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
|
||||||
go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8=
|
go.opentelemetry.io/otel v1.39.0 h1:8yPrr/S0ND9QEfTfdP9V+SiwT4E0G7Y5MO7p85nis48=
|
||||||
go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM=
|
go.opentelemetry.io/otel v1.39.0/go.mod h1:kLlFTywNWrFyEdH0oj2xK0bFYZtHRYUdv1NklR/tgc8=
|
||||||
go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA=
|
go.opentelemetry.io/otel/metric v1.39.0 h1:d1UzonvEZriVfpNKEVmHXbdf909uGTOQjA0HF0Ls5Q0=
|
||||||
go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI=
|
go.opentelemetry.io/otel/metric v1.39.0/go.mod h1:jrZSWL33sD7bBxg1xjrqyDjnuzTUB0x1nBERXd7Ftcs=
|
||||||
go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE=
|
go.opentelemetry.io/otel/trace v1.39.0 h1:2d2vfpEDmCJ5zVYz7ijaJdOF59xLomrvj7bjt6/qCJI=
|
||||||
go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs=
|
go.opentelemetry.io/otel/trace v1.39.0/go.mod h1:88w4/PnZSazkGzz/w84VHpQafiU4EtqqlVdxWy+rNOA=
|
||||||
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
|
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
|
||||||
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
|
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
|
||||||
golang.org/x/arch v0.22.0 h1:c/Zle32i5ttqRXjdLyyHZESLD/bB90DCU1g9l/0YBDI=
|
golang.org/x/arch v0.23.0 h1:lKF64A2jF6Zd8L0knGltUnegD62JMFBiCPBmQpToHhg=
|
||||||
golang.org/x/arch v0.22.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A=
|
golang.org/x/arch v0.23.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A=
|
||||||
golang.org/x/crypto v0.43.0 h1:dduJYIi3A3KOfdGOHX8AVZ/jGiyPa3IbBozJ5kNuE04=
|
golang.org/x/crypto v0.47.0 h1:V6e3FRj+n4dbpw86FJ8Fv7XVOql7TEwpHapKoMJ/GO8=
|
||||||
golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0=
|
golang.org/x/crypto v0.47.0/go.mod h1:ff3Y9VzzKbwSSEzWqJsJVBnWmRwRSHt/6Op5n9bQc4A=
|
||||||
golang.org/x/exp v0.0.0-20251002181428-27f1f14c8bb9 h1:TQwNpfvNkxAVlItJf6Cr5JTsVZoC/Sj7K3OZv2Pc14A=
|
golang.org/x/exp v0.0.0-20260112195511-716be5621a96 h1:Z/6YuSHTLOHfNFdb8zVZomZr7cqNgTJvA8+Qz75D8gU=
|
||||||
golang.org/x/exp v0.0.0-20251002181428-27f1f14c8bb9/go.mod h1:TwQYMMnGpvZyc+JpB/UAuTNIsVJifOlSkrZkhcvpVUk=
|
golang.org/x/exp v0.0.0-20260112195511-716be5621a96/go.mod h1:nzimsREAkjBCIEFtHiYkrJyT+2uy9YZJB7H1k68CXZU=
|
||||||
golang.org/x/mod v0.29.0 h1:HV8lRxZC4l2cr3Zq1LvtOsi/ThTgWnUk/y64QSs8GwA=
|
golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o=
|
||||||
golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w=
|
golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8=
|
||||||
golang.org/x/net v0.45.0 h1:RLBg5JKixCy82FtLJpeNlVM0nrSqpCRYzVU1n8kj0tM=
|
|
||||||
golang.org/x/net v0.45.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY=
|
|
||||||
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
|
|
||||||
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
|
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
|
||||||
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||||
golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k=
|
golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE=
|
||||||
golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM=
|
golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8=
|
||||||
golang.org/x/tools v0.37.0 h1:DVSRzp7FwePZW356yEAChSdNcQo6Nsp+fex1SUW09lE=
|
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
|
||||||
golang.org/x/tools v0.37.0/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w=
|
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||||
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
|
|
||||||
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||||
|
|||||||
145
internal/continuation_token/continuation_token.go
Normal file
145
internal/continuation_token/continuation_token.go
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
package continuationtoken
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/pikami/cosmium/internal/logger"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ContinuationTokenExternal struct {
|
||||||
|
Token string `json:"token"`
|
||||||
|
Range struct {
|
||||||
|
Min string `json:"min"`
|
||||||
|
Max string `json:"max"`
|
||||||
|
} `json:"range"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ContinuationToken struct {
|
||||||
|
Token struct {
|
||||||
|
ResourceId string // RID
|
||||||
|
PageIndex int // RT
|
||||||
|
TotalResults int // TRC
|
||||||
|
ISV int // ISV
|
||||||
|
IEO int // IEO
|
||||||
|
QCF int // QCF
|
||||||
|
LR int // LR
|
||||||
|
}
|
||||||
|
Range struct {
|
||||||
|
Min string
|
||||||
|
Max string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Generate(resourceid string, pageIndex int, totalResults int) ContinuationToken {
|
||||||
|
ct := ContinuationToken{}
|
||||||
|
ct.Token.ResourceId = resourceid
|
||||||
|
ct.Token.PageIndex = pageIndex
|
||||||
|
ct.Token.TotalResults = totalResults
|
||||||
|
ct.Token.ISV = 2
|
||||||
|
ct.Token.IEO = 65567
|
||||||
|
ct.Token.QCF = 8
|
||||||
|
ct.Token.LR = 1
|
||||||
|
ct.Range.Min = ""
|
||||||
|
ct.Range.Max = "FF"
|
||||||
|
|
||||||
|
return ct
|
||||||
|
}
|
||||||
|
|
||||||
|
func GenerateDefault(resourceid string) ContinuationToken {
|
||||||
|
return Generate(resourceid, 0, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ct *ContinuationToken) ToString() string {
|
||||||
|
token := fmt.Sprintf(
|
||||||
|
"-RID:~%s#RT:%d#TRC:%d#ISV:%d#IEO:%d#QCF:%d#LR:%d",
|
||||||
|
ct.Token.ResourceId,
|
||||||
|
ct.Token.PageIndex,
|
||||||
|
ct.Token.TotalResults,
|
||||||
|
ct.Token.ISV,
|
||||||
|
ct.Token.IEO,
|
||||||
|
ct.Token.QCF,
|
||||||
|
ct.Token.LR,
|
||||||
|
)
|
||||||
|
|
||||||
|
ect := ContinuationTokenExternal{}
|
||||||
|
ect.Token = token
|
||||||
|
ect.Range.Min = ct.Range.Min
|
||||||
|
ect.Range.Max = ct.Range.Max
|
||||||
|
|
||||||
|
json, err := json.Marshal(ect)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error(err, "failed to marshal continuation token")
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(json)
|
||||||
|
}
|
||||||
|
|
||||||
|
func FromString(token string) ContinuationToken {
|
||||||
|
ect := ContinuationTokenExternal{}
|
||||||
|
err := json.Unmarshal([]byte(token), &ect)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error(err, "failed to unmarshal continuation token")
|
||||||
|
return ContinuationToken{}
|
||||||
|
}
|
||||||
|
|
||||||
|
ct, err := parseContinuationToken(ect.Token, ect.Range.Min, ect.Range.Max)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error(err, "failed to parse continuation token")
|
||||||
|
return ContinuationToken{}
|
||||||
|
}
|
||||||
|
|
||||||
|
return *ct
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseContinuationToken(token string, minRange string, maxRange string) (*ContinuationToken, error) {
|
||||||
|
const prefix = "-RID:~"
|
||||||
|
if !strings.HasPrefix(token, prefix) {
|
||||||
|
return nil, fmt.Errorf("invalid token prefix")
|
||||||
|
}
|
||||||
|
|
||||||
|
parts := strings.Split(token[len(prefix):], "#")
|
||||||
|
if len(parts) != 7 {
|
||||||
|
return nil, fmt.Errorf("invalid token format: expected 7 fields, got %d", len(parts))
|
||||||
|
}
|
||||||
|
|
||||||
|
ct := &ContinuationToken{}
|
||||||
|
|
||||||
|
ct.Token.ResourceId = parts[0]
|
||||||
|
|
||||||
|
parseIntField := func(part, key string) (int, error) {
|
||||||
|
if !strings.HasPrefix(part, key+":") {
|
||||||
|
return 0, fmt.Errorf("expected %s field", key)
|
||||||
|
}
|
||||||
|
return strconv.Atoi(strings.TrimPrefix(part, key+":"))
|
||||||
|
}
|
||||||
|
|
||||||
|
var err error
|
||||||
|
|
||||||
|
if ct.Token.PageIndex, err = parseIntField(parts[1], "RT"); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if ct.Token.TotalResults, err = parseIntField(parts[2], "TRC"); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if ct.Token.ISV, err = parseIntField(parts[3], "ISV"); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if ct.Token.IEO, err = parseIntField(parts[4], "IEO"); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if ct.Token.QCF, err = parseIntField(parts[5], "QCF"); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if ct.Token.LR, err = parseIntField(parts[6], "LR"); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
ct.Range.Min = minRange
|
||||||
|
ct.Range.Max = maxRange
|
||||||
|
|
||||||
|
return ct, nil
|
||||||
|
}
|
||||||
35
internal/continuation_token/continuation_token_test.go
Normal file
35
internal/continuation_token/continuation_token_test.go
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
package continuationtoken
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Test_Generate(t *testing.T) {
|
||||||
|
token := Generate("test-resource-id", 1, 100)
|
||||||
|
|
||||||
|
assert.Equal(t, "test-resource-id", token.Token.ResourceId)
|
||||||
|
assert.Equal(t, 1, token.Token.PageIndex)
|
||||||
|
assert.Equal(t, 100, token.Token.TotalResults)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_FromString(t *testing.T) {
|
||||||
|
token := FromString("{\"token\":\"-RID:~test-resource-id#RT:1#TRC:100#ISV:2#IEO:65567#QCF:8#LR:1\",\"range\":{\"min\":\"\",\"max\":\"FF\"}}")
|
||||||
|
|
||||||
|
assert.Equal(t, "test-resource-id", token.Token.ResourceId)
|
||||||
|
assert.Equal(t, 1, token.Token.PageIndex)
|
||||||
|
assert.Equal(t, 100, token.Token.TotalResults)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_ToString(t *testing.T) {
|
||||||
|
token := Generate("test-resource-id", 1, 100)
|
||||||
|
assert.Equal(t, "{\"token\":\"-RID:~test-resource-id#RT:1#TRC:100#ISV:2#IEO:65567#QCF:8#LR:1\",\"range\":{\"min\":\"\",\"max\":\"FF\"}}", token.ToString())
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_GenerateDefault(t *testing.T) {
|
||||||
|
token := GenerateDefault("test-resource-id")
|
||||||
|
assert.Equal(t, "test-resource-id", token.Token.ResourceId)
|
||||||
|
assert.Equal(t, 0, token.Token.PageIndex)
|
||||||
|
assert.Equal(t, 0, token.Token.TotalResults)
|
||||||
|
}
|
||||||
@@ -5,18 +5,46 @@ import (
|
|||||||
"github.com/pikami/cosmium/parsers"
|
"github.com/pikami/cosmium/parsers"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ExecuteQuery(query parsers.SelectStmt, documents rowTypeIterator) []RowType {
|
type ExecuteQueryResult struct {
|
||||||
|
Rows []RowType
|
||||||
|
HasMorePages bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func ExecuteQuery(
|
||||||
|
query parsers.SelectStmt,
|
||||||
|
documents rowTypeIterator,
|
||||||
|
offset int,
|
||||||
|
limit int,
|
||||||
|
) ExecuteQueryResult {
|
||||||
resultIter := executeQuery(query, &rowTypeToRowContextIterator{documents: documents, query: query})
|
resultIter := executeQuery(query, &rowTypeToRowContextIterator{documents: documents, query: query})
|
||||||
result := make([]RowType, 0)
|
|
||||||
for {
|
result := &ExecuteQueryResult{
|
||||||
|
Rows: make([]RowType, 0),
|
||||||
|
HasMorePages: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < offset; i++ {
|
||||||
|
_, status := resultIter.Next()
|
||||||
|
if status != datastore.StatusOk {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < limit; i++ {
|
||||||
row, status := resultIter.Next()
|
row, status := resultIter.Next()
|
||||||
if status != datastore.StatusOk {
|
if status != datastore.StatusOk {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
result = append(result, row)
|
result.Rows = append(result.Rows, row)
|
||||||
}
|
}
|
||||||
return result
|
|
||||||
|
_, status := resultIter.Next()
|
||||||
|
if status == datastore.StatusOk {
|
||||||
|
result.HasMorePages = true
|
||||||
|
}
|
||||||
|
|
||||||
|
return *result
|
||||||
}
|
}
|
||||||
|
|
||||||
func executeQuery(query parsers.SelectStmt, documents rowIterator) rowTypeIterator {
|
func executeQuery(query parsers.SelectStmt, documents rowIterator) rowTypeIterator {
|
||||||
|
|||||||
@@ -38,10 +38,10 @@ func testQueryExecute(
|
|||||||
expectedData []memoryexecutor.RowType,
|
expectedData []memoryexecutor.RowType,
|
||||||
) {
|
) {
|
||||||
iter := NewTestDocumentIterator(data)
|
iter := NewTestDocumentIterator(data)
|
||||||
result := memoryexecutor.ExecuteQuery(query, iter)
|
result := memoryexecutor.ExecuteQuery(query, iter, 0, 1000)
|
||||||
|
|
||||||
if !reflect.DeepEqual(result, expectedData) {
|
if !reflect.DeepEqual(result.Rows, expectedData) {
|
||||||
t.Errorf("execution result does not match expected data.\nExpected: %+v\nGot: %+v", expectedData, result)
|
t.Errorf("execution result does not match expected data.\nExpected: %+v\nGot: %+v", expectedData, result.Rows)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ int test_Databases();
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
/* Disable stdout buffering for CI environments without a real terminal */
|
||||||
|
setvbuf(stdout, NULL, _IONBF, 0);
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage: %s <path_to_shared_library>\n", argv[0]);
|
fprintf(stderr, "Usage: %s <path_to_shared_library>\n", argv[0]);
|
||||||
@@ -14,13 +17,20 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char *libPath = argv[1];
|
const char *libPath = argv[1];
|
||||||
handle = dlopen(libPath, RTLD_LAZY);
|
handle = load_library(libPath);
|
||||||
if (!handle)
|
if (!handle)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to load shared library: %s\n", dlerror());
|
fprintf(stderr, "Failed to load shared library: %s\n", get_load_error());
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* give the loaded library a short time to initialize */
|
||||||
|
#ifdef _WIN32
|
||||||
|
Sleep(1000);
|
||||||
|
#else
|
||||||
|
sleep(1);
|
||||||
|
#endif
|
||||||
|
|
||||||
printf("Running tests for library: %s\n", libPath);
|
printf("Running tests for library: %s\n", libPath);
|
||||||
int results[] = {
|
int results[] = {
|
||||||
test_CreateServerInstance(),
|
test_CreateServerInstance(),
|
||||||
@@ -41,6 +51,15 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
printf("Tests passed: %d/%d\n", numPassed, numTests);
|
printf("Tests passed: %d/%d\n", numPassed, numTests);
|
||||||
|
|
||||||
dlclose(handle);
|
/* Exit explicitly before unloading the library.
|
||||||
return EXIT_SUCCESS;
|
Go runtime cleanup during FreeLibrary can set a non-zero exit code on Windows. */
|
||||||
|
int exitCode = (numPassed == numTests) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
ExitProcess(exitCode);
|
||||||
|
#else
|
||||||
|
close_library(handle);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return exitCode;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,50 @@
|
|||||||
#include "shared.h"
|
#include "shared.h"
|
||||||
|
|
||||||
void *handle = NULL;
|
lib_handle_t handle = NULL;
|
||||||
|
|
||||||
|
char *get_load_error(void)
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
DWORD error = GetLastError();
|
||||||
|
static char buf[256];
|
||||||
|
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
|
NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
|
buf, sizeof(buf), NULL);
|
||||||
|
return buf;
|
||||||
|
#else
|
||||||
|
return dlerror();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
lib_handle_t load_library(const char *path)
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
return LoadLibraryA(path);
|
||||||
|
#else
|
||||||
|
return dlopen(path, RTLD_LAZY);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void close_library(lib_handle_t handle)
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
FreeLibrary(handle);
|
||||||
|
#else
|
||||||
|
dlclose(handle);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void *load_function(const char *func_name)
|
void *load_function(const char *func_name)
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
void *func = (void *)GetProcAddress(handle, func_name);
|
||||||
|
#else
|
||||||
void *func = dlsym(handle, func_name);
|
void *func = dlsym(handle, func_name);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!func)
|
if (!func)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to load function %s: %s\n", func_name, dlerror());
|
fprintf(stderr, "Failed to load function %s: %s\n", func_name, get_load_error());
|
||||||
}
|
}
|
||||||
return func;
|
return func;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,24 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <dlfcn.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
extern void *handle;
|
#ifdef _WIN32
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <windows.h>
|
||||||
|
typedef HMODULE lib_handle_t;
|
||||||
|
#else
|
||||||
|
#include <dlfcn.h>
|
||||||
|
typedef void* lib_handle_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern lib_handle_t handle;
|
||||||
|
|
||||||
void *load_function(const char *func_name);
|
void *load_function(const char *func_name);
|
||||||
char *compact_json(const char *json);
|
char *compact_json(const char *json);
|
||||||
|
char *get_load_error(void);
|
||||||
|
lib_handle_t load_library(const char *path);
|
||||||
|
void close_library(lib_handle_t handle);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,6 +2,16 @@
|
|||||||
|
|
||||||
int test_Databases()
|
int test_Databases()
|
||||||
{
|
{
|
||||||
|
/* Load FreeMemory function - must use this to free memory allocated by the DLL
|
||||||
|
because the DLL may use a different C runtime heap than the test loader */
|
||||||
|
typedef void (*FreeMemoryFn)(char *);
|
||||||
|
FreeMemoryFn FreeMemory = (FreeMemoryFn)load_function("FreeMemory");
|
||||||
|
if (!FreeMemory)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Failed to find FreeMemory function\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
typedef int (*CreateDatabaseFn)(char *, char *);
|
typedef int (*CreateDatabaseFn)(char *, char *);
|
||||||
CreateDatabaseFn CreateDatabase = (CreateDatabaseFn)load_function("CreateDatabase");
|
CreateDatabaseFn CreateDatabase = (CreateDatabaseFn)load_function("CreateDatabase");
|
||||||
if (!CreateDatabase)
|
if (!CreateDatabase)
|
||||||
@@ -36,6 +46,7 @@ int test_Databases()
|
|||||||
if (database)
|
if (database)
|
||||||
{
|
{
|
||||||
printf("GetDatabase: SUCCESS (database = %s)\n", database);
|
printf("GetDatabase: SUCCESS (database = %s)\n", database);
|
||||||
|
FreeMemory(database);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,16 @@
|
|||||||
|
|
||||||
int test_ServerInstanceStateMethods()
|
int test_ServerInstanceStateMethods()
|
||||||
{
|
{
|
||||||
|
/* Load FreeMemory function - must use this to free memory allocated by the DLL
|
||||||
|
because the DLL may use a different C runtime heap than the test loader */
|
||||||
|
typedef void (*FreeMemoryFn)(char *);
|
||||||
|
FreeMemoryFn FreeMemory = (FreeMemoryFn)load_function("FreeMemory");
|
||||||
|
if (!FreeMemory)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Failed to find FreeMemory function\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
typedef int (*LoadServerInstanceStateFn)(char *, char *);
|
typedef int (*LoadServerInstanceStateFn)(char *, char *);
|
||||||
LoadServerInstanceStateFn LoadServerInstanceState = (LoadServerInstanceStateFn)load_function("LoadServerInstanceState");
|
LoadServerInstanceStateFn LoadServerInstanceState = (LoadServerInstanceStateFn)load_function("LoadServerInstanceState");
|
||||||
if (!LoadServerInstanceState)
|
if (!LoadServerInstanceState)
|
||||||
@@ -46,7 +56,7 @@ int test_ServerInstanceStateMethods()
|
|||||||
char *compact_state = compact_json(state);
|
char *compact_state = compact_json(state);
|
||||||
if (!compact_state)
|
if (!compact_state)
|
||||||
{
|
{
|
||||||
free(state);
|
FreeMemory(state);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,10 +69,12 @@ int test_ServerInstanceStateMethods()
|
|||||||
printf("GetServerInstanceState: State does not match expected value.\n");
|
printf("GetServerInstanceState: State does not match expected value.\n");
|
||||||
printf("Expected: %s\n", expected_state);
|
printf("Expected: %s\n", expected_state);
|
||||||
printf("Actual: %s\n", compact_state);
|
printf("Actual: %s\n", compact_state);
|
||||||
|
FreeMemory(state);
|
||||||
|
free(compact_state);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(state);
|
FreeMemory(state);
|
||||||
free(compact_state);
|
free(compact_state);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user