light modification
This commit is contained in:
parent
8ab313e6cb
commit
287aa3dea3
@ -121,8 +121,9 @@ func (wf *Workflow) Planify(start time.Time, end *time.Time, request *tools.APIR
|
|||||||
ps, priceds, err := plan[*resources.ProcessingResource](tools.PROCESSING_RESOURCE, wf, priceds, request, wf.Graph.IsProcessing,
|
ps, priceds, err := plan[*resources.ProcessingResource](tools.PROCESSING_RESOURCE, wf, priceds, request, wf.Graph.IsProcessing,
|
||||||
func(res resources.ResourceInterface, priced pricing.PricedItemITF) (time.Time, float64) {
|
func(res resources.ResourceInterface, priced pricing.PricedItemITF) (time.Time, float64) {
|
||||||
return start.Add(time.Duration(wf.Graph.GetAverageTimeProcessingBeforeStart(0, res.GetID(), request)) * time.Second), priced.GetExplicitDurationInS()
|
return start.Add(time.Duration(wf.Graph.GetAverageTimeProcessingBeforeStart(0, res.GetID(), request)) * time.Second), priced.GetExplicitDurationInS()
|
||||||
}, func(started time.Time, duration float64) time.Time {
|
}, func(started time.Time, duration float64) *time.Time {
|
||||||
return started.Add(time.Duration(duration))
|
s := started.Add(time.Duration(duration))
|
||||||
|
return &s
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, priceds, nil, err
|
return 0, priceds, nil, err
|
||||||
@ -130,8 +131,8 @@ func (wf *Workflow) Planify(start time.Time, end *time.Time, request *tools.APIR
|
|||||||
if _, priceds, err = plan[resources.ResourceInterface](tools.DATA_RESOURCE, wf, priceds, request, wf.Graph.IsData,
|
if _, priceds, err = plan[resources.ResourceInterface](tools.DATA_RESOURCE, wf, priceds, request, wf.Graph.IsData,
|
||||||
func(res resources.ResourceInterface, priced pricing.PricedItemITF) (time.Time, float64) {
|
func(res resources.ResourceInterface, priced pricing.PricedItemITF) (time.Time, float64) {
|
||||||
return start, 0
|
return start, 0
|
||||||
}, func(started time.Time, duration float64) time.Time {
|
}, func(started time.Time, duration float64) *time.Time {
|
||||||
return *end
|
return end
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return 0, priceds, nil, err
|
return 0, priceds, nil, err
|
||||||
}
|
}
|
||||||
@ -145,8 +146,9 @@ func (wf *Workflow) Planify(start time.Time, end *time.Time, request *tools.APIR
|
|||||||
return r
|
return r
|
||||||
}, request)
|
}, request)
|
||||||
return start.Add(time.Duration(nearestStart) * time.Second), longestDuration
|
return start.Add(time.Duration(nearestStart) * time.Second), longestDuration
|
||||||
}, func(started time.Time, duration float64) time.Time {
|
}, func(started time.Time, duration float64) *time.Time {
|
||||||
return started.Add(time.Duration(duration))
|
s := started.Add(time.Duration(duration))
|
||||||
|
return &s
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return 0, priceds, nil, err
|
return 0, priceds, nil, err
|
||||||
}
|
}
|
||||||
@ -166,8 +168,9 @@ func (wf *Workflow) Planify(start time.Time, end *time.Time, request *tools.APIR
|
|||||||
longest = neoLongest
|
longest = neoLongest
|
||||||
}
|
}
|
||||||
return start.Add(time.Duration(common.GetPlannerNearestStart(start, priceds, request)) * time.Second), longest
|
return start.Add(time.Duration(common.GetPlannerNearestStart(start, priceds, request)) * time.Second), longest
|
||||||
}, func(start time.Time, longest float64) time.Time {
|
}, func(start time.Time, longest float64) *time.Time {
|
||||||
return start.Add(time.Duration(longest) * time.Second)
|
s := start.Add(time.Duration(longest) * time.Second)
|
||||||
|
return &s
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return 0, priceds, nil, err
|
return 0, priceds, nil, err
|
||||||
}
|
}
|
||||||
@ -175,7 +178,7 @@ func (wf *Workflow) Planify(start time.Time, end *time.Time, request *tools.APIR
|
|||||||
}
|
}
|
||||||
|
|
||||||
func plan[T resources.ResourceInterface](dt tools.DataType, wf *Workflow, priceds map[tools.DataType][]pricing.PricedItemITF, request *tools.APIRequest,
|
func plan[T resources.ResourceInterface](dt tools.DataType, wf *Workflow, priceds map[tools.DataType][]pricing.PricedItemITF, request *tools.APIRequest,
|
||||||
f func(graph.GraphItem) bool, start func(resources.ResourceInterface, pricing.PricedItemITF) (time.Time, float64), end func(time.Time, float64) time.Time) ([]T, map[tools.DataType][]pricing.PricedItemITF, error) {
|
f func(graph.GraphItem) bool, start func(resources.ResourceInterface, pricing.PricedItemITF) (time.Time, float64), end func(time.Time, float64) *time.Time) ([]T, map[tools.DataType][]pricing.PricedItemITF, error) {
|
||||||
resources := []T{}
|
resources := []T{}
|
||||||
for _, item := range wf.GetGraphItems(f) {
|
for _, item := range wf.GetGraphItems(f) {
|
||||||
if priceds[dt] == nil {
|
if priceds[dt] == nil {
|
||||||
@ -189,9 +192,13 @@ func plan[T resources.ResourceInterface](dt tools.DataType, wf *Workflow, priced
|
|||||||
started, duration := start(realItem, priced)
|
started, duration := start(realItem, priced)
|
||||||
priced.SetLocationStart(started)
|
priced.SetLocationStart(started)
|
||||||
if duration >= 0 {
|
if duration >= 0 {
|
||||||
priced.SetLocationEnd(end(started, duration))
|
if e := end(started, duration); e != nil {
|
||||||
|
priced.SetLocationEnd(*e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if e := end(started, priced.GetExplicitDurationInS()); end != nil {
|
||||||
|
priced.SetLocationEnd(*e)
|
||||||
}
|
}
|
||||||
priced.SetLocationEnd(end(started, priced.GetExplicitDurationInS()))
|
|
||||||
resources = append(resources, realItem.(T))
|
resources = append(resources, realItem.(T))
|
||||||
priceds[dt] = append(priceds[dt], priced)
|
priceds[dt] = append(priceds[dt], priced)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user