light modification
This commit is contained in:
		| @@ -73,7 +73,7 @@ func (p *Peer) IsMySelf() (bool, string) { | ||||
| } | ||||
|  | ||||
| // LaunchPeerExecution launches an execution on a peer | ||||
| func (p *Peer) LaunchPeerExecution(peerID string, dataID string, dt tools.DataType, method tools.METHOD, body map[string]interface{}, caller *tools.HTTPCaller) (*PeerExecution, error) { | ||||
| func (p *Peer) LaunchPeerExecution(peerID string, dataID string, dt tools.DataType, method tools.METHOD, body interface{}, caller *tools.HTTPCaller) (*PeerExecution, error) { | ||||
| 	p.UUID = peerID | ||||
| 	return cache.LaunchPeerExecution(peerID, dataID, dt, method, body, caller) // Launch the execution on the peer through the cache | ||||
| } | ||||
|   | ||||
| @@ -15,11 +15,11 @@ import ( | ||||
| * it defines the execution data | ||||
|  */ | ||||
| type PeerExecution struct { | ||||
| 	Method   string                 `json:"method" bson:"method"` | ||||
| 	Url      string                 `json:"url" bson:"url"` | ||||
| 	Body     map[string]interface{} `json:"body" bson:"body"` | ||||
| 	DataType int                    `json:"data_type" bson:"data_type"` | ||||
| 	DataID   string                 `json:"data_id" bson:"data_id"` | ||||
| 	Method   string      `json:"method" bson:"method"` | ||||
| 	Url      string      `json:"url" bson:"url"` | ||||
| 	Body     interface{} `json:"body" bson:"body"` | ||||
| 	DataType int         `json:"data_type" bson:"data_type"` | ||||
| 	DataID   string      `json:"data_id" bson:"data_id"` | ||||
| } | ||||
|  | ||||
| var cache = &PeerCache{} // Singleton instance of the peer cache | ||||
| @@ -84,7 +84,7 @@ func (p *PeerCache) checkPeerStatus(peerID string, appName string, caller *tools | ||||
|  | ||||
| // LaunchPeerExecution launches an execution on a peer | ||||
| func (p *PeerCache) LaunchPeerExecution(peerID string, dataID string, | ||||
| 	dt tools.DataType, method tools.METHOD, body map[string]interface{}, caller *tools.HTTPCaller) (*PeerExecution, error) { | ||||
| 	dt tools.DataType, method tools.METHOD, body interface{}, caller *tools.HTTPCaller) (*PeerExecution, error) { | ||||
| 	fmt.Println("Launching peer execution on", caller.URLS, dt, method) | ||||
| 	methods := caller.URLS[dt] // Get the methods url of the data type | ||||
| 	if m, ok := methods[method]; !ok || m == "" { | ||||
| @@ -128,7 +128,7 @@ func (p *PeerCache) LaunchPeerExecution(peerID string, dataID string, | ||||
| } | ||||
|  | ||||
| // exec executes the method on the peer | ||||
| func (p *PeerCache) exec(url string, method tools.METHOD, body map[string]interface{}, caller *tools.HTTPCaller) error { | ||||
| func (p *PeerCache) exec(url string, method tools.METHOD, body interface{}, caller *tools.HTTPCaller) error { | ||||
| 	var b []byte | ||||
| 	var err error | ||||
| 	fmt.Println("Executing", method, "on", url, "with", body) | ||||
|   | ||||
| @@ -63,7 +63,7 @@ func (ws *WorkflowSchedule) CheckBooking(wfID string, request *tools.APIRequest) | ||||
| 		return false, wf, []*WorkflowExecutions{}, err | ||||
| 	} | ||||
| 	ws.DurationS = longest | ||||
| 	ws.Message = "We estimate that the workflow will start at " + ws.Start.String() + " and last " + fmt.Sprintf("%v", ws.DurationS) + "seconds." | ||||
| 	ws.Message = "We estimate that the workflow will start at " + ws.Start.String() + " and last " + fmt.Sprintf("%v", ws.DurationS) + " seconds." | ||||
| 	if ws.End != nil && ws.Start.Add(time.Duration(longest)*time.Second).After(*ws.End) { | ||||
| 		ws.Warning = "The workflow may be too long to be executed in the given time frame, we will try to book it anyway\n" | ||||
| 	} | ||||
| @@ -155,7 +155,7 @@ func (ws *WorkflowSchedule) getDates() ([]Schedule, error) { | ||||
| 	schedule := []Schedule{} | ||||
| 	if len(ws.Cron) > 0 { // if cron is set then end date should be set | ||||
| 		if ws.End == nil { | ||||
| 			return schedule, errors.New("a cron task should have an end date.") | ||||
| 			return schedule, errors.New("a cron task should have an end date") | ||||
| 		} | ||||
| 		if ws.DurationS <= 0 { | ||||
| 			ws.DurationS = ws.End.Sub(ws.Start).Seconds() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user