Files
fn-serverless/api/models/datastore.go
Travis Reeder d5116397b6 API extension points (#473)
* API endpoint extensions working.

extensions example.

* Added server.NewEnv and some docs for the API extensions example.

extensions example.
example main.go.

* Uncommented special handler stuff.

* Added section in docs for extending API linking to example main.go.

* Commented out special_handler test

* Changed to NewFromEnv
2017-01-30 12:14:28 -08:00

36 lines
1.5 KiB
Go

package models
import (
"context"
"errors"
)
type Datastore interface {
// GetApp returns the app called appName or nil if it doesn't exist
GetApp(ctx context.Context, appName string) (*App, error)
GetApps(ctx context.Context, filter *AppFilter) ([]*App, error)
InsertApp(ctx context.Context, app *App) (*App, error)
UpdateApp(ctx context.Context, app *App) (*App, error)
RemoveApp(ctx context.Context, appName string) error
GetRoute(ctx context.Context, appName, routePath string) (*Route, error)
GetRoutes(ctx context.Context, filter *RouteFilter) (routes []*Route, err error)
GetRoutesByApp(ctx context.Context, appName string, filter *RouteFilter) (routes []*Route, err error)
InsertRoute(ctx context.Context, route *Route) (*Route, error)
UpdateRoute(ctx context.Context, route *Route) (*Route, error)
RemoveRoute(ctx context.Context, appName, routePath string) 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
Get(context.Context, []byte) ([]byte, error)
}
var (
ErrDatastoreEmptyAppName = errors.New("Missing app name")
ErrDatastoreEmptyRoutePath = errors.New("Missing route name")
ErrDatastoreEmptyApp = errors.New("Missing app")
ErrDatastoreEmptyRoute = errors.New("Missing route")
ErrDatastoreEmptyKey = errors.New("Missing key")
)