unistore: move continue to the resource package (#101206)

* minor improvements to tests

* move continue token

* update sql backend
This commit is contained in:
Georges Chaudy
2025-02-24 18:02:30 +02:00
committed by GitHub
parent 74632a25c3
commit e13bd52da6
5 changed files with 48 additions and 21 deletions
-32
View File
@@ -1,32 +0,0 @@
package sql
import (
"encoding/base64"
"encoding/json"
"fmt"
)
type ContinueToken struct {
StartOffset int64 `json:"o"`
ResourceVersion int64 `json:"v"`
}
func (c ContinueToken) String() string {
b, _ := json.Marshal(c)
return base64.StdEncoding.EncodeToString(b)
}
func GetContinueToken(token string) (*ContinueToken, error) {
continueVal, err := base64.StdEncoding.DecodeString(token)
if err != nil {
return nil, fmt.Errorf("error decoding continue token")
}
t := &ContinueToken{}
err = json.Unmarshal(continueVal, t)
if err != nil {
return nil, err
}
return t, nil
}