From 099b626bc8c5504da71859aa1cdf41b9082590d3 Mon Sep 17 00:00:00 2001 From: Andrew Sisley Date: Mon, 28 Oct 2024 13:51:53 -0400 Subject: [PATCH] WIP - Implement branchable collections --- internal/core/crdt/collection.go | 50 ++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 internal/core/crdt/collection.go diff --git a/internal/core/crdt/collection.go b/internal/core/crdt/collection.go new file mode 100644 index 0000000000..3caa14832c --- /dev/null +++ b/internal/core/crdt/collection.go @@ -0,0 +1,50 @@ +// Copyright 2024 Democratized Data Foundation +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +package crdt + +import ( + "context" + + "github.com/sourcenetwork/defradb/internal/core" +) + +type CollectionDelta struct { + Priority uint64 + // todo: This is temporary pending a global collection id (link to ticket) + SchemaVersionID string +} + +var _ core.Delta = (*CollectionDelta)(nil) +var _ core.ReplicatedData = (*CollectionDelta)(nil) + +func (delta *CollectionDelta) IPLDSchemaBytes() []byte { //todo + return []byte(` + type CounterDelta struct { + docID Bytes + fieldName String + priority Int + nonce Int + schemaVersionID String + data Bytes + }`) +} + +func (d *CollectionDelta) GetPriority() uint64 { + panic("todo") +} + +func (d *CollectionDelta) SetPriority(uint64) { + panic("todo") +} + +func (d *CollectionDelta) Merge(ctx context.Context, other core.Delta) error { + panic("todo") +}