feat: implement platform handler creation

also refactor public and internal api to support transaction between
multiple methods

#2
This commit is contained in:
Alexander Navarro 2024-11-18 16:51:09 -03:00
parent b2d8dadcee
commit 01086d12c9
7 changed files with 423 additions and 253 deletions

25
pkg/platform.go Normal file
View file

@ -0,0 +1,25 @@
package synchronizator
type PlatformClass interface {
// How to transform the struct into a node. It needs to return the class,
// name and a []byte representation of the metadata.
//
// - name: A user friendly name
// - metadata: Arbitrary data. This will be stored as a jsonb in the database
//
ToNode() (string, []byte, error)
// How to transform a node into the struct. This method should modify the
// struct directly as it receives a pointer.
//
// - name: A user friendly name
// - metadata: Arbitrary data. This is stored as a jsonb in the database
FromNode(string, []byte) error
}
// Utility struct to represent a collection of nodes, it's a [Node] itself so all
// the node's functionality is available.
type Platform struct {
Node // Underlaying node info
collections []*Collection // Child nodes
}