mirror of
https://github.com/openfaas/faas.git
synced 2025-06-22 23:03:24 +00:00
Expose scale-function endpoint
- exposes scale-function endpoint for use with faas-idler, this is protected by auth when enabled. Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
This commit is contained in:
@ -197,6 +197,33 @@ paths:
|
|||||||
description: Function not found
|
description: Function not found
|
||||||
'500':
|
'500':
|
||||||
description: Error connecting to function
|
description: Error connecting to function
|
||||||
|
'/system/scale-function/{functionName}':
|
||||||
|
get:
|
||||||
|
summary: Scale a function
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: functionName
|
||||||
|
description: Function name
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
- in: body
|
||||||
|
name: input
|
||||||
|
description: Function to scale plus replica count
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
format: binary
|
||||||
|
example:
|
||||||
|
'{"service": "hello-world", "replicas": 10}'
|
||||||
|
required: false
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: Scaling OK
|
||||||
|
'202':
|
||||||
|
description: Scaling OK
|
||||||
|
'404':
|
||||||
|
description: Function not found
|
||||||
|
'500':
|
||||||
|
description: Error scaling function
|
||||||
'/system/function/{functionName}':
|
'/system/function/{functionName}':
|
||||||
get:
|
get:
|
||||||
summary: Get a summary of an OpenFaaS function
|
summary: Get a summary of an OpenFaaS function
|
||||||
|
@ -101,6 +101,8 @@ func main() {
|
|||||||
faasHandlers.ListFunctions = metrics.AddMetricsHandler(faasHandlers.ListFunctions, prometheusQuery)
|
faasHandlers.ListFunctions = metrics.AddMetricsHandler(faasHandlers.ListFunctions, prometheusQuery)
|
||||||
faasHandlers.Proxy = handlers.MakeCallIDMiddleware(faasHandlers.Proxy)
|
faasHandlers.Proxy = handlers.MakeCallIDMiddleware(faasHandlers.Proxy)
|
||||||
|
|
||||||
|
faasHandlers.ScaleFunction = handlers.MakeForwardingProxyHandler(reverseProxy, forwardingNotifiers, urlResolver)
|
||||||
|
|
||||||
if credentials != nil {
|
if credentials != nil {
|
||||||
faasHandlers.UpdateFunction =
|
faasHandlers.UpdateFunction =
|
||||||
handlers.DecorateWithBasicAuth(faasHandlers.UpdateFunction, credentials)
|
handlers.DecorateWithBasicAuth(faasHandlers.UpdateFunction, credentials)
|
||||||
@ -110,6 +112,9 @@ func main() {
|
|||||||
handlers.DecorateWithBasicAuth(faasHandlers.DeployFunction, credentials)
|
handlers.DecorateWithBasicAuth(faasHandlers.DeployFunction, credentials)
|
||||||
faasHandlers.ListFunctions =
|
faasHandlers.ListFunctions =
|
||||||
handlers.DecorateWithBasicAuth(faasHandlers.ListFunctions, credentials)
|
handlers.DecorateWithBasicAuth(faasHandlers.ListFunctions, credentials)
|
||||||
|
faasHandlers.ScaleFunction =
|
||||||
|
handlers.DecorateWithBasicAuth(faasHandlers.ScaleFunction, credentials)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r := mux.NewRouter()
|
r := mux.NewRouter()
|
||||||
@ -141,6 +146,7 @@ func main() {
|
|||||||
r.HandleFunc("/system/functions", faasHandlers.DeployFunction).Methods(http.MethodPost)
|
r.HandleFunc("/system/functions", faasHandlers.DeployFunction).Methods(http.MethodPost)
|
||||||
r.HandleFunc("/system/functions", faasHandlers.DeleteFunction).Methods(http.MethodDelete)
|
r.HandleFunc("/system/functions", faasHandlers.DeleteFunction).Methods(http.MethodDelete)
|
||||||
r.HandleFunc("/system/functions", faasHandlers.UpdateFunction).Methods(http.MethodPut)
|
r.HandleFunc("/system/functions", faasHandlers.UpdateFunction).Methods(http.MethodPut)
|
||||||
|
r.HandleFunc("/system/scale-function/{name:[-a-zA-Z_0-9]+}", faasHandlers.ScaleFunction).Methods(http.MethodPost)
|
||||||
|
|
||||||
if faasHandlers.QueuedProxy != nil {
|
if faasHandlers.QueuedProxy != nil {
|
||||||
r.HandleFunc("/async-function/{name:[-a-zA-Z_0-9]+}/", faasHandlers.QueuedProxy).Methods(http.MethodPost)
|
r.HandleFunc("/async-function/{name:[-a-zA-Z_0-9]+}/", faasHandlers.QueuedProxy).Methods(http.MethodPost)
|
||||||
|
@ -17,4 +17,7 @@ type HandlerSet struct {
|
|||||||
|
|
||||||
// AsyncReport - report a deferred execution result
|
// AsyncReport - report a deferred execution result
|
||||||
AsyncReport http.HandlerFunc
|
AsyncReport http.HandlerFunc
|
||||||
|
|
||||||
|
// ScaleFunction allows a function to be scaled
|
||||||
|
ScaleFunction http.HandlerFunc
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user