refactor(api): replace map[string]uint64 with api.StoreVersion for store version handling

This commit is contained in:
Pasha Sviderski committed 2026-09-30 16:43:46 +10:00
1 parent e4455e936a
commit e50c5fbe57
8 files changed
+37 -22

No files matched your search

+3 -2
View File
@@ -10,6 +10,7 @@ import (
"github.com/google/uuid"
"github.com/psviderski/uncloud/api/pb"
"github.com/psviderski/uncloud/internal/corrosion"
"github.com/psviderski/uncloud/pkg/api"
"google.golang.org/protobuf/encoding/protojson"
)
@@ -81,14 +82,14 @@ func (s *Store) Delete(ctx context.Context, key string) error {
// limitations documented there.
//
// Capturing a vector does not wait for replication or prevent further writes.
func (s *Store) Version(ctx context.Context) (map[string]uint64, error) {
func (s *Store) Version(ctx context.Context) (api.StoreVersion, error) {
rows, err := s.corro.QueryContext(ctx, "SELECT site_id, db_version FROM crsql_db_versions")
if err != nil {
return nil, fmt.Errorf("query crsql_db_versions: %w", err)
}
defer rows.Close()
versions := make(map[string]uint64)
versions := make(api.StoreVersion)
for rows.Next() {
var (
siteID []byte