mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
* idle_timeout max of 1h * timeout max of 120s for sync, 1h for async * max memory of 8GB * do full route validation before call invocation * ensure that idle_timeout >= timeout we are now doing validation of updating route inside of the database transaction, which is what we should have been doing all along really. we need this behavior to ensure that the idle timeout is longer than the timeout, among other benefits (like not updating the most recent version of the existing struct and overwriting previous updates, yay). since we have this, we can get rid of the weird skipZero behavior on validate too and validate the real deal holyfield. validating the route before making the call is handy so that we don't do weird things like run a func that wants to use 300GB of RAM and run for 3 weeks. closes #192 closes #344 closes #162
56 lines
1.0 KiB
Go
56 lines
1.0 KiB
Go
package models
|
|
|
|
type App struct {
|
|
Name string `json:"name" db:"name"`
|
|
Config Config `json:"config" db:"config"`
|
|
}
|
|
|
|
func (a *App) Validate() error {
|
|
if a.Name == "" {
|
|
return ErrAppsMissingName
|
|
}
|
|
if len(a.Name) > maxAppName {
|
|
return ErrAppsTooLongName
|
|
}
|
|
for _, c := range a.Name {
|
|
if (c < '0' || '9' < c) && (c < 'A' || 'Z' > c) && (c < 'a' || 'z' < c) && c != '_' && c != '-' {
|
|
return ErrAppsInvalidName
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (a *App) Clone() *App {
|
|
var c App
|
|
c.Name = a.Name
|
|
if a.Config != nil {
|
|
c.Config = make(Config)
|
|
for k, v := range a.Config {
|
|
c.Config[k] = v
|
|
}
|
|
}
|
|
return &c
|
|
}
|
|
|
|
// UpdateConfig adds entries from patch to a.Config, and removes entries with empty values.
|
|
func (a *App) UpdateConfig(patch Config) {
|
|
if patch != nil {
|
|
if a.Config == nil {
|
|
a.Config = make(Config)
|
|
}
|
|
for k, v := range patch {
|
|
if v == "" {
|
|
delete(a.Config, k)
|
|
} else {
|
|
a.Config[k] = v
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
type AppFilter struct {
|
|
Name string // prefix query TODO implemented
|
|
PerPage int
|
|
Cursor string
|
|
}
|