feat: add persistent storage (#30)

* refactor: remove unused default timeout

* feat: add persistent storage

Allows you to save the state to a file and load it upon restarting the app to restore the previous state.

* chore: upgrade to go 1.18

* use tinykv with generics

* build: add "-buildvcs=false" flag

Git is not available in golang:1.18-alpine image
This commit is contained in:
Alexis Couvreur
2022-05-09 22:55:32 +02:00
parent 4eb086f9d5
commit 3eb7d480da
9 changed files with 397 additions and 647 deletions

View File

@@ -4,6 +4,9 @@ import (
"net/http"
"net/http/httptest"
"testing"
"time"
"github.com/acouvreur/tinykv"
)
type ScalerMock struct {
@@ -50,7 +53,9 @@ func TestOndemand_ServeHTTP(t *testing.T) {
request := httptest.NewRequest("GET", "/?name=whoami&timeout=5m", nil)
responseRecorder := httptest.NewRecorder()
onDemandHandler := onDemand(test.scaler)
store := tinykv.New[OnDemandRequestState](time.Second * 20)
onDemandHandler := onDemand(test.scaler, store)
onDemandHandler(responseRecorder, request)
body := responseRecorder.Body.String()