mongo stability debug + zoom

This commit is contained in:
mr 2024-08-02 15:06:40 +02:00
parent fa52c71e93
commit efa73d8a45
3 changed files with 6 additions and 1 deletions

View File

@ -92,6 +92,8 @@ func (m *MongoDB) createClient(MongoURL string) error {
func (m *MongoDB) prepareDB(list_collection []string, config MongoConf) { func (m *MongoDB) prepareDB(list_collection []string, config MongoConf) {
var err error var err error
mngoDB = mngoClient.Database(config.GetDatabase()) mngoDB = mngoClient.Database(config.GetDatabase())
MngoCtx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
existingCollections, err = mngoDB.ListCollectionNames(MngoCtx, bson.D{}) existingCollections, err = mngoDB.ListCollectionNames(MngoCtx, bson.D{})
if err != nil { if err != nil {
m.Logger.Fatal().Msg("Error contacting MongoDB\n" + err.Error()) m.Logger.Fatal().Msg("Error contacting MongoDB\n" + err.Error())
@ -116,6 +118,8 @@ func (m *MongoDB) prepareDB(list_collection []string, config MongoConf) {
// Creates the collection with index specified in mongo/mongo_collections // Creates the collection with index specified in mongo/mongo_collections
// or use the basic collection creation function // or use the basic collection creation function
func (m *MongoDB) createCollection(collection_name string, new_collection *mongo.Collection) { func (m *MongoDB) createCollection(collection_name string, new_collection *mongo.Collection) {
MngoCtx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
var err error var err error
CollectionMap[collection_name] = new_collection CollectionMap[collection_name] = new_collection
_, exists := IndexesMap[collection_name] _, exists := IndexesMap[collection_name]

View File

@ -3,6 +3,7 @@ package graph
import "cloud.o-forge.io/core/oc-lib/models/resources" import "cloud.o-forge.io/core/oc-lib/models/resources"
type Graph struct { type Graph struct {
Zoom float64 `bson:"zoom" json:"zoom" validate:"required"`
Items map[string]GraphItem `bson:"items" json:"items" default:"{}" validate:"required"` Items map[string]GraphItem `bson:"items" json:"items" default:"{}" validate:"required"`
Links []GraphLink `bson:"links" json:"links" default:"{}" validate:"required"` Links []GraphLink `bson:"links" json:"links" default:"{}" validate:"required"`
} }

View File

@ -107,7 +107,7 @@ func (wfa *workflowMongoAccessor) execute(workflow *Workflow) {
} }
resource, _, err := accessor.Search(filters, "") resource, _, err := accessor.Search(filters, "")
if err == nil && len(resource) > 0 { if err == nil && len(resource) > 0 {
fmt.Println(workflow.Processings, resource[0].GetID()) fmt.Println(workflow.Serialize(), resource[0].GetID())
accessor.UpdateOne(&workspace.Workspace{ accessor.UpdateOne(&workspace.Workspace{
Active: true, Active: true,
ResourceSet: resources.ResourceSet{ ResourceSet: resources.ResourceSet{