[Feature] Function status

This commit is contained in:
Denis Makogon
2017-06-06 14:12:50 -07:00
parent 6334f44a72
commit 3f065ce6bf
29 changed files with 1165 additions and 564 deletions

View File

@@ -6,20 +6,24 @@ import (
)
type Apps []*App
type Tasks []*Task
type FnCalls []*FnCall
var (
ErrAppsAlreadyExists = errors.New("App already exists")
ErrAppsCreate = errors.New("Could not create app")
ErrAppsGet = errors.New("Could not get app from datastore")
ErrAppsList = errors.New("Could not list apps from datastore")
ErrAppsMissingNew = errors.New("Missing new application")
ErrAppsNameImmutable = errors.New("Could not update app - name is immutable")
ErrAppsNotFound = errors.New("App not found")
ErrAppsNothingToUpdate = errors.New("Nothing to update")
ErrAppsRemoving = errors.New("Could not remove app from datastore")
ErrAppsUpdate = errors.New("Could not update app")
ErrDeleteAppsWithRoutes = errors.New("Cannot remove apps with routes")
ErrUsableImage = errors.New("Image not found")
ErrAppsAlreadyExists = errors.New("App already exists")
ErrAppsCreate = errors.New("Could not create app")
ErrAppsGet = errors.New("Could not get app from datastore")
ErrAppsList = errors.New("Could not list apps from datastore")
ErrAppsMissingNew = errors.New("Missing new application")
ErrAppsNameImmutable = errors.New("Could not update app - name is immutable")
ErrAppsNotFound = errors.New("App not found")
ErrAppsNothingToUpdate = errors.New("Nothing to update")
ErrAppsRemoving = errors.New("Could not remove app from datastore")
ErrAppsUpdate = errors.New("Could not update app")
ErrDeleteAppsWithRoutes = errors.New("Cannot remove apps with routes")
ErrUsableImage = errors.New("Image not found")
ErrCallNotFound = errors.New("Call not found")
ErrTaskInvalidAppAndRoute = errors.New("Unable to get call for given app and route")
)
type App struct {

View File

@@ -58,6 +58,11 @@ type Datastore interface {
// ErrDatastoreEmptyRoutePath when routePath is empty. Returns ErrRoutesNotFound when no route exists.
RemoveRoute(ctx context.Context, appName, routePath string) error
// InsertTask inserts a task
InsertTask(ctx context.Context, task *Task) error
GetTask(ctx context.Context, callID string) (*FnCall, error)
GetTasks(ctx context.Context, filter *CallFilter) (FnCalls, error)
// The following provide a generic key value store for arbitrary data, can be used by extensions to store extra data
// todo: should we namespace these by app? Then when an app is deleted, it can delete any of this extra data too.
Put(context.Context, []byte, []byte) error
@@ -70,4 +75,5 @@ var (
ErrDatastoreEmptyApp = errors.New("Missing app")
ErrDatastoreEmptyRoute = errors.New("Missing route")
ErrDatastoreEmptyKey = errors.New("Missing key")
ErrDatastoreEmptyTaskID = errors.New("Missing task ID")
)

View File

@@ -28,6 +28,30 @@ const (
FormatHTTP = "http"
)
type FnCall struct {
IDStatus
CompletedAt strfmt.DateTime `json:"completed_at,omitempty"`
CreatedAt strfmt.DateTime `json:"created_at,omitempty"`
StartedAt strfmt.DateTime `json:"started_at,omitempty"`
AppName string `json:"app_name,omitempty"`
Path string `json:"path"`
}
func (fnCall *FnCall) FromTask(task *Task) *FnCall {
return &FnCall{
CreatedAt:task.CreatedAt,
StartedAt:task.StartedAt,
CompletedAt:task.CompletedAt,
AppName:task.AppName,
Path:task.Path,
IDStatus: IDStatus{
ID:task.ID,
Status:task.Status,
},
}
}
/*Task task
swagger:model Task
@@ -151,3 +175,8 @@ func (m *Task) validateReason(formats strfmt.Registry) error {
return nil
}
type CallFilter struct {
Path string
AppName string
}