Skip to content

Commit bb907bd

Browse files
committed
Completes renaming by removing Composition occurrences
1 parent 9f4d158 commit bb907bd

41 files changed

Lines changed: 242 additions & 566 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

internal/api/api.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ var requestsPool = sync.Pool{
3030
},
3131
}
3232

33-
var compositionRequestsPool = sync.Pool{
33+
var workflowInvocationRequestPool = sync.Pool{
3434
New: func() any {
35-
return new(workflow.CompositionRequest)
35+
return new(workflow.Request)
3636
},
3737
}
3838

@@ -74,7 +74,6 @@ func InvokeFunction(c echo.Context) error {
7474
// init fields if possibly not overwritten later
7575
r.ExecReport.SchedAction = ""
7676
r.ExecReport.OffloadLatency = 0.0
77-
r.IsInComposition = false
7877

7978
if r.Async {
8079
go scheduling.SubmitAsyncRequest(r)

internal/api/server.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ func StartAPIServer(e *echo.Echo) {
2929
e.GET("/function", GetFunctions)
3030
e.GET("/poll/:reqId", PollAsyncResult)
3131
e.GET("/status", GetServerStatus)
32-
// Function composition routes
33-
e.POST("/play/:workflow", InvokeFunctionComposition)
34-
e.POST("/compose", CreateFunctionComposition)
35-
e.POST("/composeASL", CreateFunctionCompositionFromASL)
36-
e.POST("/uncompose", DeleteFunctionComposition)
37-
e.GET("/workflow", GetFunctionCompositions)
32+
// Workflow routes
33+
e.POST("/workflow/invoke/:workflow", InvokeWorkflow)
34+
e.POST("/workflow/create", CreateWorkflowFromASL)
35+
e.POST("/workflow/import", CreateWorkflow)
36+
e.POST("/workflow/delete", DeleteWorkflow)
37+
e.GET("/workflow/list", GetWorkflows)
3838

3939
// Start server
4040
portNumber := config.GetInt(config.API_PORT, 1323)
Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ import (
1818
"github.com/labstack/gommon/log"
1919
)
2020

21-
// ===== Function Composition =====
22-
23-
func CreateFunctionCompositionFromASL(e echo.Context) error {
24-
var creationRequest client.CompositionCreationFromASLRequest
21+
func CreateWorkflowFromASL(e echo.Context) error {
22+
var creationRequest client.WorkflowCreationRequest
2523
var body []byte
2624
body, errReadBody := io.ReadAll(e.Request().Body)
2725
if errReadBody != nil {
@@ -37,22 +35,22 @@ func CreateFunctionCompositionFromASL(e echo.Context) error {
3735
// checking if the function already exists. If exists we return an error
3836
_, found := workflow.GetFC(creationRequest.Name)
3937
if found {
40-
log.Printf("Dropping request for already existing composition '%s'", creationRequest.Name)
41-
return e.JSON(http.StatusConflict, "composition already exists")
38+
log.Printf("Dropping request for already existing workflow '%s'", creationRequest.Name)
39+
return e.JSON(http.StatusConflict, "workflow already exists")
4240
}
4341

44-
log.Printf("New request: creation of composition %s", creationRequest.Name)
42+
log.Printf("New request: creation of workflow %s", creationRequest.Name)
4543

4644
decodedSrc, err := base64.StdEncoding.DecodeString(creationRequest.ASLSrc)
4745
if err != nil {
48-
log.Printf("Could not decode composition source ASL: %v", err)
49-
return e.JSON(http.StatusBadRequest, "composition already exists")
46+
log.Printf("Could not decode workflow source ASL: %v", err)
47+
return e.JSON(http.StatusBadRequest, "workflow already exists")
5048
}
5149

5250
comp, err := workflow.FromASL(creationRequest.Name, decodedSrc[:])
5351
if err != nil {
54-
log.Printf("Could not parse composition from ASL: %v", err)
55-
return e.JSON(http.StatusBadRequest, "composition already exists")
52+
log.Printf("Could not parse workflow from ASL: %v", err)
53+
return e.JSON(http.StatusBadRequest, "workflow already exists")
5654
}
5755

5856
err = comp.SaveToEtcd()
@@ -65,9 +63,9 @@ func CreateFunctionCompositionFromASL(e echo.Context) error {
6563
return e.JSON(http.StatusOK, response)
6664
}
6765

68-
func CreateFunctionComposition(e echo.Context) error {
66+
func CreateWorkflow(e echo.Context) error {
6967
var comp workflow.Workflow
70-
// here we expect to receive the function composition struct already parsed from JSON/YAML
68+
// here we expect to receive the function workflow struct already parsed from JSON/YAML
7169
var body []byte
7270
body, errReadBody := io.ReadAll(e.Request().Body)
7371
if errReadBody != nil {
@@ -76,24 +74,24 @@ func CreateFunctionComposition(e echo.Context) error {
7674

7775
err := json.Unmarshal(body, &comp)
7876
if err != nil && err != io.EOF {
79-
log.Printf("Could not parse composition request - error during unmarshal: %v", err)
77+
log.Printf("Could not parse workflow request - error during unmarshal: %v", err)
8078
return err
8179
}
8280
// checking if the function already exists. If exists we return an error
8381
alreadyPresent := comp.Exists() // TODO: we would need a system-wide lock here...
8482
if alreadyPresent {
85-
log.Printf("Dropping request for already existing composition '%s'", comp.Name)
86-
return e.JSON(http.StatusConflict, "composition already exists")
83+
log.Printf("Dropping request for already existing workflow '%s'", comp.Name)
84+
return e.JSON(http.StatusConflict, "workflow already exists")
8785
}
8886

89-
log.Printf("New request: creation of composition %s", comp.Name)
87+
log.Printf("New request: creation of workflow %s", comp.Name)
9088

9189
// Check that functions exist
9290
for _, fName := range comp.GetUniqueFunctions() {
9391
f, exists := function.GetFunction(fName)
9492
if !exists {
95-
log.Printf("Dropping request for composition with non-existing function '%s'", fName)
96-
return e.JSON(http.StatusBadRequest, "composition with non-existing function")
93+
log.Printf("Dropping request for workflow with non-existing function '%s'", fName)
94+
return e.JSON(http.StatusBadRequest, "workflow with non-existing function")
9795
}
9896
if f.Signature == nil {
9997
return e.JSON(http.StatusBadRequest, "function "+fName+"has nil signature")
@@ -109,67 +107,67 @@ func CreateFunctionComposition(e echo.Context) error {
109107
return e.JSON(http.StatusOK, response)
110108
}
111109

112-
// GetFunctionCompositions handles a request to list the function compositions available in the system.
113-
func GetFunctionCompositions(c echo.Context) error {
110+
// GetWorkflows handles a request to list the function workflows available in the system.
111+
func GetWorkflows(c echo.Context) error {
114112
list, err := workflow.GetAllFC()
115113
if err != nil {
116114
return c.String(http.StatusServiceUnavailable, "")
117115
}
118116
return c.JSON(http.StatusOK, list)
119117
}
120118

121-
// DeleteFunctionComposition handles a function deletion request.
122-
func DeleteFunctionComposition(c echo.Context) error {
119+
// DeleteWorkflow handles a function deletion request.
120+
func DeleteWorkflow(c echo.Context) error {
123121
var comp workflow.Workflow
124-
// here we only need the name of the function composition (and if all function should be deleted with it)
122+
// here we only need the name of the function workflow (and if all function should be deleted with it)
125123
err := json.NewDecoder(c.Request().Body).Decode(&comp)
126124
if err != nil && err != io.EOF {
127125
log.Printf("Could not parse delete request - error during decoding: %v", err)
128126
return err
129127
}
130128

131-
composition, ok := workflow.GetFC(comp.Name) // TODO: we would need a system-wide lock here...
129+
workflow, ok := workflow.GetFC(comp.Name) // TODO: we would need a system-wide lock here...
132130
if !ok {
133131
log.Printf("Dropping request for non existing function '%s'", comp.Name)
134-
return c.JSON(http.StatusNotFound, "the request function composition to delete does not exist")
132+
return c.JSON(http.StatusNotFound, "the request function workflow to delete does not exist")
135133
}
136134

137-
log.Printf("New request: deleting %s", composition.Name)
138-
err = composition.Delete()
135+
log.Printf("New request: deleting %s", workflow.Name)
136+
err = workflow.Delete()
139137
if err != nil {
140138
log.Printf("Failed deletion: %v", err)
141139
return c.JSON(http.StatusServiceUnavailable, "")
142140
}
143141

144-
response := struct{ Deleted string }{composition.Name}
142+
response := struct{ Deleted string }{workflow.Name}
145143
return c.JSON(http.StatusOK, response)
146144
}
147145

148-
// InvokeFunctionComposition handles a function composition invocation request.
149-
func InvokeFunctionComposition(e echo.Context) error {
150-
// gets the command line param value for -workflow (the composition name)
146+
// InvokeWorkflow handles a function workflow invocation request.
147+
func InvokeWorkflow(e echo.Context) error {
148+
// gets the command line param value for -workflow (the workflow name)
151149
fcName := e.Param("workflow")
152150
funComp, ok := workflow.GetFC(fcName)
153151
if !ok {
154152
log.Printf("Dropping request for unknown FC '%s'", fcName)
155-
return e.JSON(http.StatusNotFound, "function composition '"+fcName+"' does not exist")
153+
return e.JSON(http.StatusNotFound, "function workflow '"+fcName+"' does not exist")
156154
}
157155

158-
// we use invocation request that is specific to function compositions
159-
var fcInvocationRequest client.CompositionInvocationRequest
156+
// we use invocation request that is specific to function workflows
157+
var fcInvocationRequest client.WorkflowInvocationRequest
160158
err := json.NewDecoder(e.Request().Body).Decode(&fcInvocationRequest)
161159
if err != nil && err != io.EOF {
162160
log.Printf("Could not parse invoke request - error during decoding: %v", err)
163-
return e.JSON(http.StatusInternalServerError, "failed to parse composition invocation request. Check parameters and composition definition")
161+
return e.JSON(http.StatusInternalServerError, "failed to parse workflow invocation request. Check parameters and workflow definition")
164162
}
165-
// gets a workflow.CompositionRequest from the pool goroutine-safe cache.
166-
fcReq := compositionRequestsPool.Get().(*workflow.CompositionRequest) // A pointer *function.CompositionRequest will be created if does not exists, otherwise removed from the pool
167-
defer compositionRequestsPool.Put(fcReq) // at the end of the function, the function.CompositionRequest is added to the pool.
168-
fcReq.Fc = funComp
163+
// gets a workflow.NewRequest from the pool goroutine-safe cache.
164+
fcReq := workflowInvocationRequestPool.Get().(*workflow.Request) // A pointer *function.NewRequest will be created if does not exists, otherwise removed from the pool
165+
defer workflowInvocationRequestPool.Put(fcReq) // at the end of the function, the function.NewRequest is added to the pool.
166+
fcReq.W = funComp
169167
fcReq.Params = fcInvocationRequest.Params
170168
fcReq.Arrival = time.Now()
171169

172-
// instead of saving only one RequestQoS, we save a map with an entry for each function in the composition
170+
// instead of saving only one RequestQoS, we save a map with an entry for each function in the workflow
173171
fcReq.RequestQoSMap = fcInvocationRequest.RequestQoSMap
174172

175173
fcReq.CanDoOffloading = fcInvocationRequest.CanDoOffloading
@@ -187,12 +185,12 @@ func InvokeFunctionComposition(e echo.Context) error {
187185
}
188186

189187
if fcReq.Async {
190-
go workflow.SubmitAsyncCompositionRequest(fcReq)
188+
go workflow.SubmitAsyncWorkflowInvocationRequest(fcReq)
191189
return e.JSON(http.StatusOK, function.AsyncResponse{ReqId: fcReq.ReqId})
192190
}
193191

194192
// sync execution
195-
err = workflow.SubmitCompositionRequest(fcReq)
193+
err = workflow.SubmitWorkflowInvocationRequest(fcReq)
196194

197195
if errors.Is(err, node.OutOfResourcesErr) {
198196
return e.String(http.StatusTooManyRequests, "")
@@ -213,7 +211,7 @@ func InvokeFunctionComposition(e echo.Context) error {
213211
return true
214212
})
215213

216-
return e.JSON(http.StatusOK, workflow.CompositionResponse{
214+
return e.JSON(http.StatusOK, workflow.InvocationResponse{
217215
Success: true,
218216
Result: fcReq.ExecReport.Result,
219217
Reports: reports,

0 commit comments

Comments
 (0)