Extract scaling from zero

- extracting this package means it can be used in other components
such as the asynchronous nats-queue-worker which may need to
invoke functions which are scaled down to zero replicas.

Ref: https://github.com/openfaas/nats-queue-worker/issues/32

Tested on Docker Swarm for scaling up, already scaled and not
found error.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis (VMware)
2018-11-01 12:54:17 +00:00
committed by Alex Ellis
parent fb06e299cf
commit 9cea08c728
15 changed files with 208 additions and 125 deletions

View File

@ -8,7 +8,7 @@ import (
"testing"
"github.com/openfaas/faas-provider/auth"
"github.com/openfaas/faas/gateway/handlers"
"github.com/openfaas/faas/gateway/scaling"
)
const fallbackValue = 120
@ -70,11 +70,11 @@ func TestGetReplicasExistentFn(t *testing.T) {
}))
defer testServer.Close()
expectedSvcQryResp := handlers.ServiceQueryResponse{
expectedSvcQryResp := scaling.ServiceQueryResponse{
Replicas: 0,
MaxReplicas: uint64(handlers.DefaultMaxReplicas),
MinReplicas: uint64(handlers.DefaultMinReplicas),
ScalingFactor: uint64(handlers.DefaultScalingFactor),
MaxReplicas: uint64(scaling.DefaultMaxReplicas),
MinReplicas: uint64(scaling.DefaultMinReplicas),
ScalingFactor: uint64(scaling.DefaultScalingFactor),
AvailableReplicas: 0,
}