simplify call to peer
This commit is contained in:
parent
0652215c18
commit
091cbb9e7f
@ -14,6 +14,7 @@ import (
|
|||||||
|
|
||||||
type SharedWorkspace struct {
|
type SharedWorkspace struct {
|
||||||
utils.AbstractObject
|
utils.AbstractObject
|
||||||
|
IsSent bool `json:"is_sent" bson:"-"`
|
||||||
CreatorID string `json:"peer_id,omitempty" bson:"peer_id,omitempty" validate:"required"`
|
CreatorID string `json:"peer_id,omitempty" bson:"peer_id,omitempty" validate:"required"`
|
||||||
Version string `json:"version,omitempty" bson:"version,omitempty"`
|
Version string `json:"version,omitempty" bson:"version,omitempty"`
|
||||||
Description string `json:"description,omitempty" bson:"description,omitempty" validate:"required"`
|
Description string `json:"description,omitempty" bson:"description,omitempty" validate:"required"`
|
||||||
|
@ -152,11 +152,13 @@ func (wfa *sharedWorkspaceMongoAccessor) sendToPeer(shared *SharedWorkspace) {
|
|||||||
if wfa.Caller == nil || wfa.Caller.URLS == nil || wfa.Caller.URLS[utils.SHARED_WORKSPACE.String()] == nil {
|
if wfa.Caller == nil || wfa.Caller.URLS == nil || wfa.Caller.URLS[utils.SHARED_WORKSPACE.String()] == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
paccess := (&peer.Peer{})
|
paccess := (&peer.Peer{})
|
||||||
for _, v := range shared.Peers {
|
for _, v := range shared.Peers {
|
||||||
if (&peer.Peer{AbstractObject: utils.AbstractObject{UUID: v}}).IsMySelf() {
|
if (&peer.Peer{AbstractObject: utils.AbstractObject{UUID: v}}).IsMySelf() || shared.IsSent {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
shared.IsSent = true
|
||||||
b, err := paccess.LaunchPeerExecution(v, v, utils.SHARED_WORKSPACE, tools.POST, shared.Serialize(), wfa.Caller)
|
b, err := paccess.LaunchPeerExecution(v, v, utils.SHARED_WORKSPACE, tools.POST, shared.Serialize(), wfa.Caller)
|
||||||
if err != nil && b == nil {
|
if err != nil && b == nil {
|
||||||
wfa.Logger.Error().Msg("Could not send to peer " + v + ". Error: " + err.Error())
|
wfa.Logger.Error().Msg("Could not send to peer " + v + ". Error: " + err.Error())
|
||||||
@ -165,11 +167,12 @@ func (wfa *sharedWorkspaceMongoAccessor) sendToPeer(shared *SharedWorkspace) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (wfa *sharedWorkspaceMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) {
|
func (wfa *sharedWorkspaceMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) {
|
||||||
wfa.deleteToPeer(set.(*SharedWorkspace))
|
res, code, err := wfa.GenericUpdateOne(set.(*SharedWorkspace), id, wfa, &SharedWorkspace{})
|
||||||
wfa.sharedWorkflow(set.(*SharedWorkspace), id)
|
wfa.deleteToPeer(res.(*SharedWorkspace))
|
||||||
wfa.sharedWorkspace(set.(*SharedWorkspace), id)
|
wfa.sharedWorkflow(res.(*SharedWorkspace), id)
|
||||||
wfa.sendToPeer(set.(*SharedWorkspace))
|
wfa.sharedWorkspace(res.(*SharedWorkspace), id)
|
||||||
return wfa.GenericUpdateOne(set.(*SharedWorkspace), id, wfa, &SharedWorkspace{})
|
wfa.sendToPeer(res.(*SharedWorkspace))
|
||||||
|
return res, code, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wfa *sharedWorkspaceMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) {
|
func (wfa *sharedWorkspaceMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user