Skip to content

Commit

Permalink
Documentation and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
erwinvaneyk committed Sep 26, 2017
1 parent 99179e0 commit b5ea452
Show file tree
Hide file tree
Showing 38 changed files with 230 additions and 151 deletions.
44 changes: 41 additions & 3 deletions Docs/api/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,10 @@ <h3 class="field-label">Example data</h3>
"resolved" : "aeiou"
}
},
"error" : {
"code" : "aeiou",
"message" : "aeiou"
},
"status" : { },
"updatedAt" : "2000-01-23T04:56:07.000+00:00"
}
Expand Down Expand Up @@ -621,6 +625,7 @@ <h3 class="field-label">Example data</h3>
}
}
},
"error" : "",
"tasks" : {
"key" : {
"metadata" : "",
Expand All @@ -637,6 +642,10 @@ <h3 class="field-label">Example data</h3>
},
"status" : {
"output" : "",
"error" : {
"code" : "aeiou",
"message" : "aeiou"
},
"status" : { },
"updatedAt" : "2000-01-23T04:56:07.000+00:00"
}
Expand Down Expand Up @@ -779,6 +788,7 @@ <h3 class="field-label">Example data</h3>
}
}
},
"error" : "",
"tasks" : {
"key" : {
"metadata" : "",
Expand All @@ -795,6 +805,10 @@ <h3 class="field-label">Example data</h3>
},
"status" : {
"output" : "",
"error" : {
"code" : "aeiou",
"message" : "aeiou"
},
"status" : { },
"updatedAt" : "2000-01-23T04:56:07.000+00:00"
}
Expand Down Expand Up @@ -886,6 +900,7 @@ <h3 class="field-label">Example data</h3>
}
}
},
"error" : "",
"tasks" : {
"key" : {
"metadata" : "",
Expand All @@ -902,6 +917,10 @@ <h3 class="field-label">Example data</h3>
},
"status" : {
"output" : "",
"error" : {
"code" : "aeiou",
"message" : "aeiou"
},
"status" : { },
"updatedAt" : "2000-01-23T04:56:07.000+00:00"
}
Expand Down Expand Up @@ -976,6 +995,7 @@ <h2><a name="__Models">Models</a></h2>

<h3>Table of Contents</h3>
<ol>
<li><a href="#Error"><code>Error</code> - </a></li>
<li><a href="#ObjectMetadata"><code>ObjectMetadata</code> - Common</a></li>
<li><a href="#Task"><code>Task</code> - </a></li>
<li><a href="#TaskDependencyParameters"><code>TaskDependencyParameters</code> - </a></li>
Expand All @@ -993,7 +1013,10 @@ <h3>Table of Contents</h3>
<li><a href="#WorkflowInvocationStatusStatus"><code>WorkflowInvocationStatusStatus</code> - </a></li>
<li><a href="#WorkflowSpec"><code>WorkflowSpec</code> - Workflow Definition</a></li>
<li><a href="#WorkflowStatus"><code>WorkflowStatus</code> - Internal</a></li>
<li><a href="#WorkflowStatusStatus"><code>WorkflowStatusStatus</code> - </a></li>
<li><a href="#WorkflowStatusStatus"><code>WorkflowStatusStatus</code> - <ul>
<li>READY: PARSING = 1; // During validation/parsing</li>
</ul>
</a></li>
<li><a href="#apiserverHealth"><code>apiserverHealth</code> - </a></li>
<li><a href="#apiserverSearchWorkflowResponse"><code>apiserverSearchWorkflowResponse</code> - </a></li>
<li><a href="#apiserverWorkflowIdentifier"><code>apiserverWorkflowIdentifier</code> - </a></li>
Expand All @@ -1004,6 +1027,14 @@ <h3>Table of Contents</h3>
or the response type of an API method. For instance:</a></li>
</ol>

<div class="model">
<h3><a name="Error"><code>Error</code> - </a> <a class="up" href="#__Models">Up</a></h3>
<div class='model-description'></div>
<div class="field-items">
<div class="param">code (optional)</div><div class="param-desc"><span class="param-type"><a href="#string">String</a></span> </div>
<div class="param">message (optional)</div><div class="param-desc"><span class="param-type"><a href="#string">String</a></span> </div>
</div> <!-- field-items -->
</div>
<div class="model">
<h3><a name="ObjectMetadata"><code>ObjectMetadata</code> - Common</a> <a class="up" href="#__Models">Up</a></h3>
<div class='model-description'></div>
Expand Down Expand Up @@ -1068,6 +1099,7 @@ <h3><a name="TaskInvocationStatus"><code>TaskInvocationStatus</code> - </a> <a c
<div class="param">status (optional)</div><div class="param-desc"><span class="param-type"><a href="#TaskInvocationStatusStatus">TaskInvocationStatusStatus</a></span> </div>
<div class="param">updatedAt (optional)</div><div class="param-desc"><span class="param-type"><a href="#DateTime">Date</a></span> format: date-time</div>
<div class="param">output (optional)</div><div class="param-desc"><span class="param-type"><a href="#TypedValue">TypedValue</a></span> </div>
<div class="param">error (optional)</div><div class="param-desc"><span class="param-type"><a href="#Error">Error</a></span> </div>
</div> <!-- field-items -->
</div>
<div class="model">
Expand Down Expand Up @@ -1128,6 +1160,7 @@ <h3><a name="WorkflowInvocationStatus"><code>WorkflowInvocationStatus</code> - <
<div class="param">tasks (optional)</div><div class="param-desc"><span class="param-type"><a href="#TaskInvocation">map[String, TaskInvocation]</a></span> </div>
<div class="param">output (optional)</div><div class="param-desc"><span class="param-type"><a href="#TypedValue">TypedValue</a></span> </div>
<div class="param">dynamicTasks (optional)</div><div class="param-desc"><span class="param-type"><a href="#Task">map[String, Task]</a></span> </div>
<div class="param">error (optional)</div><div class="param-desc"><span class="param-type"><a href="#Error">Error</a></span> </div>
</div> <!-- field-items -->
</div>
<div class="model">
Expand All @@ -1149,7 +1182,8 @@ <h3><a name="WorkflowSpec"><code>WorkflowSpec</code> - Workflow Definition</a> <
<div class="param">tasks (optional)</div><div class="param-desc"><span class="param-type"><a href="#Task">map[String, Task]</a></span> Dependency graph is build into the tasks </div>
<div class="param">outputTask (optional)</div><div class="param-desc"><span class="param-type"><a href="#string">String</a></span> </div>
<div class="param">description (optional)</div><div class="param-desc"><span class="param-type"><a href="#string">String</a></span> </div>
<div class="param">id (optional)</div><div class="param-desc"><span class="param-type"><a href="#string">String</a></span> </div>
<div class="param">id (optional)</div><div class="param-desc"><span class="param-type"><a href="#string">String</a></span> TODO move outside of spec
The UID that the workflow should have. Only use this in case you want to force a specific UID. </div>
<div class="param">name (optional)</div><div class="param-desc"><span class="param-type"><a href="#string">String</a></span> </div>
</div> <!-- field-items -->
</div>
Expand All @@ -1160,10 +1194,14 @@ <h3><a name="WorkflowStatus"><code>WorkflowStatus</code> - Internal</a> <a class
<div class="param">status (optional)</div><div class="param-desc"><span class="param-type"><a href="#WorkflowStatusStatus">WorkflowStatusStatus</a></span> </div>
<div class="param">updatedAt (optional)</div><div class="param-desc"><span class="param-type"><a href="#DateTime">Date</a></span> format: date-time</div>
<div class="param">resolvedTasks (optional)</div><div class="param-desc"><span class="param-type"><a href="#TaskTypeDef">map[String, TaskTypeDef]</a></span> </div>
<div class="param">error (optional)</div><div class="param-desc"><span class="param-type"><a href="#Error">Error</a></span> </div>
</div> <!-- field-items -->
</div>
<div class="model">
<h3><a name="WorkflowStatusStatus"><code>WorkflowStatusStatus</code> - </a> <a class="up" href="#__Models">Up</a></h3>
<h3><a name="WorkflowStatusStatus"><code>WorkflowStatusStatus</code> - <ul>
<li>READY: PARSING = 1; // During validation/parsing</li>
</ul>
</a> <a class="up" href="#__Models">Up</a></h3>
<div class='model-description'></div>
<div class="field-items">
</div> <!-- field-items -->
Expand Down
30 changes: 26 additions & 4 deletions api/swagger/apiserver.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,17 @@
}
},
"definitions": {
"Error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
}
}
},
"ObjectMetadata": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -378,6 +389,9 @@
},
"output": {
"$ref": "#/definitions/TypedValue"
},
"error": {
"$ref": "#/definitions/Error"
}
}
},
Expand Down Expand Up @@ -489,6 +503,9 @@
"additionalProperties": {
"$ref": "#/definitions/Task"
}
},
"error": {
"$ref": "#/definitions/Error"
}
}
},
Expand Down Expand Up @@ -527,10 +544,12 @@
"type": "string"
},
"id": {
"type": "string"
"type": "string",
"description": "TODO move outside of spec\nThe UID that the workflow should have. Only use this in case you want to force a specific UID."
},
"name": {
"type": "string"
"type": "string",
"title": "Name is solely for human-readablity"
}
},
"description": "The workflowDefinition contains the definition of a workflow.\n\nIdeally the source code (json, yaml) can be converted directly to this message.\nNaming, triggers and versioning of the workflow itself is out of the scope of this data structure, which is delegated\nto the user/system upon the creation of a workflow.",
Expand All @@ -551,6 +570,9 @@
"additionalProperties": {
"$ref": "#/definitions/TaskTypeDef"
}
},
"error": {
"$ref": "#/definitions/Error"
}
},
"title": "Internal"
Expand All @@ -559,12 +581,12 @@
"type": "string",
"enum": [
"UNKNOWN",
"PARSING",
"READY",
"FAILED",
"DELETED"
],
"default": "UNKNOWN"
"default": "UNKNOWN",
"title": "- READY: PARSING = 1; // During validation/parsing"
},
"apiserverHealth": {
"type": "object",
Expand Down
2 changes: 1 addition & 1 deletion charts/fission-workflows/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ metadata:
spec:
version: 1
runtime:
# TODO allow environment variables for environment
# TODO Add environment variables for environment once supported by Fission
image: "{{ .Values.envImage }}"
allowedFunctionsPerContainer: infinite
2 changes: 1 addition & 1 deletion charts/fission-workflows/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#

# Bundle image
bundleImage: fission/fission-workflow-bundle:latest
bundleImage: fission/fission-workflows-bundle:latest

# Image of the Fission environment for Fission Workflows
envImage: fission/workflow-env:latest
Expand Down
2 changes: 1 addition & 1 deletion cmd/fission-workflows-bundle/bundle/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ go_library(
"//pkg/api/workflow/parse:go_default_library",
"//pkg/apiserver:go_default_library",
"//pkg/controller:go_default_library",
"//pkg/controller/query:go_default_library",
"//pkg/controller/expr:go_default_library",
"//pkg/fes:go_default_library",
"//pkg/fes/eventstore/nats:go_default_library",
"//pkg/fnenv/fission:go_default_library",
Expand Down
19 changes: 9 additions & 10 deletions cmd/fission-workflows-bundle/bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/fission/fission-workflows/pkg/api/workflow/parse"
"github.com/fission/fission-workflows/pkg/apiserver"
"github.com/fission/fission-workflows/pkg/controller"
"github.com/fission/fission-workflows/pkg/controller/query"
"github.com/fission/fission-workflows/pkg/controller/expr"
"github.com/fission/fission-workflows/pkg/fes"
"github.com/fission/fission-workflows/pkg/fes/eventstore/nats"
"github.com/fission/fission-workflows/pkg/fnenv/fission"
Expand Down Expand Up @@ -153,6 +153,7 @@ func Run(ctx context.Context, opts *Options) error {

<-ctx.Done()
log.Info("Shutting down...")
// TODO properly shutdown components
return nil
}

Expand Down Expand Up @@ -259,9 +260,9 @@ func runWorkflowApiServer(s *grpc.Server, es fes.EventStore, resolvers map[strin
log.Infof("Serving workflow gRPC API at %s.", GRPC_ADDRESS)
}

func runWorkflowInvocationApiServer(s *grpc.Server, es fes.EventStore, invocationCache fes.CacheReader) {
invocationApi := invocation.NewApi(es, invocationCache)
invocationServer := apiserver.NewGrpcInvocationApiServer(invocationApi)
func runWorkflowInvocationApiServer(s *grpc.Server, es fes.EventStore, wfiCache fes.CacheReader) {
invocationApi := invocation.NewApi(es)
invocationServer := apiserver.NewGrpcInvocationApiServer(invocationApi, wfiCache)
apiserver.RegisterWorkflowInvocationAPIServer(s, invocationServer)
log.Infof("Serving workflow invocation gRPC API at %s.", GRPC_ADDRESS)
}
Expand Down Expand Up @@ -306,8 +307,8 @@ func runFissionEnvironmentProxy(proxySrv http.Server, es fes.EventStore, wfiCach
workflowValidator := parse.NewValidator()
workflowApi := workflow.NewApi(es, workflowParser)
wfServer := apiserver.NewGrpcWorkflowApiServer(workflowApi, workflowValidator, wfCache)
wfiApi := invocation.NewApi(es, wfiCache)
wfiServer := apiserver.NewGrpcInvocationApiServer(wfiApi)
wfiApi := invocation.NewApi(es)
wfiServer := apiserver.NewGrpcInvocationApiServer(wfiApi, wfiCache)
proxyMux := http.NewServeMux()
fissionProxyServer := fission.NewFissionProxyServer(wfiServer, wfServer)
fissionProxyServer.RegisterServer(proxyMux)
Expand All @@ -322,17 +323,15 @@ func runController(ctx context.Context, invocationCache fes.CacheReader, wfCache

workflowApi := workflow.NewApi(es, parse.NewResolver(fnResolvers))
functionApi := function.NewApi(fnRuntimes, es)
invocationApi := invocation.NewApi(es, invocationCache)
invocationApi := invocation.NewApi(es)
s := &scheduler.WorkflowScheduler{}
pf := typedvalues.DefaultParserFormatter
ep := query.NewJavascriptExpressionParser(pf)
ep := expr.NewJavascriptExpressionParser(pf)
invocationCtrl := controller.NewInvocationController(invocationCache, wfCache, s, functionApi, invocationApi, ep)
workflowCtrl := controller.NewWorkflowController(wfCache, workflowApi)

ctrl := controller.NewMetaController(invocationCtrl, workflowCtrl)

go ctrl.Run(ctx)
log.Info("Setup controller component.")

// TODO properly shutdown
}
2 changes: 1 addition & 1 deletion cmd/fission-workflows-bundle/bundle/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestWorkflowCreate(t *testing.T) {
assert.NotNil(t, wfId)
assert.NotEmpty(t, wfId.GetId())

time.Sleep(time.Duration(3) * time.Second)
time.Sleep(time.Duration(10) * time.Second)
// Test workflow list
l, err := cl.List(ctx, &empty.Empty{})
assert.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/function/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go_library(
name = "go_default_library",
srcs = [
"api.go",
"function.go",
"runtime.go",
],
visibility = ["//visibility:public"],
deps = [
Expand Down
24 changes: 0 additions & 24 deletions pkg/api/function/function.go

This file was deleted.

41 changes: 41 additions & 0 deletions pkg/api/function/runtime.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package function

import (
"github.com/fission/fission-workflows/pkg/types"
)

// Runtime is the minimal interface that a function runtime environment needs to conform with to handle tasks.
type Runtime interface {

// Invoke executes the task in a blocking way.
//
// spec contains the complete configuration needed for the execution.
// It returns the TaskInvocationStatus with a completed (FINISHED, FAILED, ABORTED) status.
// An error is returned only when error occurs outside of the runtime's control.
Invoke(spec *types.TaskInvocationSpec) (*types.TaskInvocationStatus, error)
}

// AsyncRuntime is a more extended interface that a runtime can optionally support. It allows for asynchronous
// invocations, allowing with progress tracking and invocation cancellations.
type AsyncRuntime interface {

// InvokeAsync invokes a function in the runtime based on the spec and returns an identifier to allow the caller
// to reference the invocation.
InvokeAsync(spec *types.TaskInvocationSpec) (string, error)

// Cancel cancels a function invocation using the function invocation ID.
Cancel(fnInvocationId string) error

// Status fetches the status of a invocation.
//
// The interface user is responsible for determining wether the status indicates that a invocation has completed.
Status(fnInvocationId string) (*types.TaskInvocationStatus, error)
}

// Resolver is the component that resolves a functionRef to a runtime-specific function UID.
type Resolver interface {
// Resolve an ambiguous function name to a unique identifier of a function
//
// If the fnName does not exist an error will be displayed
Resolve(fnName string) (string, error) // TODO refactor to FunctionRef (Fission Env v2)
}
Loading

0 comments on commit b5ea452

Please sign in to comment.