correct share infinite loop

This commit is contained in:
mr
2024-10-02 12:23:22 +02:00
parent 93903b4938
commit c309d97623
14 changed files with 35 additions and 23 deletions

View File

@@ -3,10 +3,12 @@ package utils
import (
"encoding/json"
"errors"
"time"
"cloud.o-forge.io/core/oc-lib/dbs"
"cloud.o-forge.io/core/oc-lib/dbs/mongo"
"cloud.o-forge.io/core/oc-lib/logs"
"cloud.o-forge.io/core/oc-lib/static"
"cloud.o-forge.io/core/oc-lib/tools"
"github.com/go-playground/validator/v10"
"github.com/google/uuid"
@@ -22,8 +24,10 @@ var validate = validator.New(validator.WithRequiredStructEnabled())
* every data in base root model should inherit from this struct (only exception is the ResourceModel)
*/
type AbstractObject struct {
UUID string `json:"id,omitempty" bson:"id,omitempty" validate:"required"`
Name string `json:"name,omitempty" bson:"name,omitempty" validate:"required"`
UUID string `json:"id,omitempty" bson:"id,omitempty" validate:"required"`
Name string `json:"name,omitempty" bson:"name,omitempty" validate:"required"`
UpdateDate time.Time `json:"update_date" bson:"update_date"`
LastPeerWriter string `json:"last_peer_writer" bson:"last_peer_writer"`
}
// GetID returns the id of the object (abstract)
@@ -36,6 +40,11 @@ func (ao *AbstractObject) GetName() string {
return ao.Name
}
func (ao *AbstractObject) UpToDate() {
ao.UpdateDate = time.Now()
ao.LastPeerWriter, _ = static.GetMyLocalJsonPeer()
}
// GetAccessor returns the accessor of the object (abstract)
func (dma *AbstractObject) GetAccessor(caller *tools.HTTPCaller) Accessor {
return nil

View File

@@ -19,6 +19,7 @@ type DBObject interface {
GenerateID()
GetID() string
GetName() string
UpToDate()
Deserialize(j map[string]interface{}) DBObject
Serialize() map[string]interface{}
GetAccessor(caller *tools.HTTPCaller) Accessor