Skip to content
Snippets Groups Projects
Commit 8f0d2d1f authored by Alex Ellis (VMware)'s avatar Alex Ellis (VMware)
Browse files

Expose scale-function endpoint


- exposes scale-function endpoint for use with faas-idler, this
is protected by auth when enabled.

Signed-off-by: default avatarAlex Ellis (VMware) <alexellis2@gmail.com>
parent 4cbb7d96
No related branches found
No related tags found
No related merge requests found
......@@ -197,6 +197,33 @@ paths:
description: Function not found
'500':
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}':
get:
summary: Get a summary of an OpenFaaS function
......
......@@ -101,6 +101,8 @@ func main() {
faasHandlers.ListFunctions = metrics.AddMetricsHandler(faasHandlers.ListFunctions, prometheusQuery)
faasHandlers.Proxy = handlers.MakeCallIDMiddleware(faasHandlers.Proxy)
faasHandlers.ScaleFunction = handlers.MakeForwardingProxyHandler(reverseProxy, forwardingNotifiers, urlResolver)
if credentials != nil {
faasHandlers.UpdateFunction =
handlers.DecorateWithBasicAuth(faasHandlers.UpdateFunction, credentials)
......@@ -110,6 +112,9 @@ func main() {
handlers.DecorateWithBasicAuth(faasHandlers.DeployFunction, credentials)
faasHandlers.ListFunctions =
handlers.DecorateWithBasicAuth(faasHandlers.ListFunctions, credentials)
faasHandlers.ScaleFunction =
handlers.DecorateWithBasicAuth(faasHandlers.ScaleFunction, credentials)
}
r := mux.NewRouter()
......@@ -141,6 +146,7 @@ func main() {
r.HandleFunc("/system/functions", faasHandlers.DeployFunction).Methods(http.MethodPost)
r.HandleFunc("/system/functions", faasHandlers.DeleteFunction).Methods(http.MethodDelete)
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 {
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 http.HandlerFunc
// ScaleFunction allows a function to be scaled
ScaleFunction http.HandlerFunc
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment