mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
* App ID * Clean-up * Use ID or name to reference apps * Can use app by name or ID * Get rid of AppName for routes API and model routes API is completely backwards-compatible routes API accepts both app ID and name * Get rid of AppName from calls API and model * Fixing tests * Get rid of AppName from logs API and model * Restrict API to work with app names only * Addressing review comments * Fix for hybrid mode * Fix rebase problems * Addressing review comments * Addressing review comments pt.2 * Fixing test issue * Addressing review comments pt.3 * Updated docstring * Adjust UpdateApp SQL implementation to work with app IDs instead of names * Fixing tests * fmt after rebase * Make tests green again! * Use GetAppByID wherever it is necessary - adding new v2 endpoints to keep hybrid api/runner mode working - extract CallBase from Call object to expose that to a user (it doesn't include any app reference, as we do for all other API objects) * Get rid of GetAppByName * Adjusting server router setup * Make hybrid work again * Fix datastore tests * Fixing tests * Do not ignore app_id * Resolve issues after rebase * Updating test to make it work as it was * Tabula rasa for migrations * Adding calls API test - we need to ensure we give "App not found" for the missing app and missing call in first place - making previous test work (request missing call for the existing app) * Make datastore tests work fine with correctly applied migrations * Make CallFunction middleware work again had to adjust its implementation to set app ID before proceeding * The biggest rebase ever made * Fix 8's migration * Fix tests * Fix hybrid client * Fix tests problem * Increment app ID migration version * Fixing TestAppUpdate * Fix rebase issues * Addressing review comments * Renew vendor * Updated swagger doc per recommendations
66 lines
3.2 KiB
Go
66 lines
3.2 KiB
Go
package fnext
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/fnproject/fn/api/models"
|
|
)
|
|
|
|
// AppListener is an interface used to inject custom code at key points in app lifecycle.
|
|
type AppListener interface {
|
|
// BeforeAppCreate called right before creating App in the database
|
|
BeforeAppCreate(ctx context.Context, app *models.App) error
|
|
// AfterAppCreate called after creating App in the database
|
|
AfterAppCreate(ctx context.Context, app *models.App) error
|
|
// BeforeAppUpdate called right before updating App in the database
|
|
BeforeAppUpdate(ctx context.Context, app *models.App) error
|
|
// AfterAppUpdate called after updating App in the database
|
|
AfterAppUpdate(ctx context.Context, app *models.App) error
|
|
// BeforeAppDelete called right before deleting App in the database
|
|
BeforeAppDelete(ctx context.Context, app *models.App) error
|
|
// AfterAppDelete called after deleting App in the database
|
|
AfterAppDelete(ctx context.Context, app *models.App) error
|
|
// BeforeAppGet called right before getting an app
|
|
BeforeAppGet(ctx context.Context, appID string) error
|
|
// AfterAppGet called after getting app from database
|
|
AfterAppGet(ctx context.Context, app *models.App) error
|
|
// BeforeAppsList called right before getting a list of all user's apps. Modify the filter to adjust what gets returned.
|
|
BeforeAppsList(ctx context.Context, filter *models.AppFilter) error
|
|
// AfterAppsList called after deleting getting a list of user's apps. apps is the result after applying AppFilter.
|
|
AfterAppsList(ctx context.Context, apps []*models.App) error
|
|
|
|
// TODO: WHAT IF THESE WERE CHANGE TO WRAPPERS INSTEAD OF LISTENERS, SORT OF LIKE MIDDLEWARE, EG
|
|
// AppCreate(ctx, app, next func(ctx, app) or next.AppCreate(ctx, app)) <- where func is the InsertApp function (ie: the corresponding Datastore function)
|
|
// Then instead of two two functions and modifying objects in the params, they get modified and then passed on. Eg:
|
|
// AppCreate(ctx, app, next) (app *models.App, err error) {
|
|
// // do stuff before
|
|
// app.Name = app.Name + "-12345"
|
|
// app, err = next.AppCreate(ctx, app)
|
|
// // do stuff after if you want
|
|
// return app, err
|
|
// }
|
|
}
|
|
|
|
type RouteListener interface {
|
|
// BeforeRouteCreate called before route created in the datastore
|
|
BeforeRouteCreate(ctx context.Context, route *models.Route) error
|
|
// AfterRouteCreate called after route create in the datastore
|
|
AfterRouteCreate(ctx context.Context, route *models.Route) error
|
|
// BeforeRouteUpdate called before route update in datastore
|
|
BeforeRouteUpdate(ctx context.Context, route *models.Route) error
|
|
// AfterRouteUpdate called after route updated in datastore
|
|
AfterRouteUpdate(ctx context.Context, route *models.Route) error
|
|
// BeforeRouteDelete called before route deleted from the datastore
|
|
BeforeRouteDelete(ctx context.Context, appName string, routePath string) error
|
|
// AfterRouteDelete called after route deleted from the datastore
|
|
AfterRouteDelete(ctx context.Context, appName string, routePath string) error
|
|
}
|
|
|
|
// CallListener enables callbacks around Call events
|
|
type CallListener interface {
|
|
// BeforeCall called before a function is executed
|
|
BeforeCall(ctx context.Context, call *models.Call) error
|
|
// AfterCall called after a function completes
|
|
AfterCall(ctx context.Context, call *models.Call) error
|
|
}
|