Skip to content

Commit

Permalink
Release: 1.2.0 (update to go 1.22, add -ready-delay)
Browse files Browse the repository at this point in the history
  • Loading branch information
msirovy committed Mar 11, 2024
1 parent ff9f8fb commit 7b81a84
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Build
FROM golang:1.21.4-bookworm AS build
FROM golang:1.22-bookworm AS build


COPY . /usr/src/troll/
Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Troll is a very simple webserver returning defined response with configurable de
* 404 page dumping request to log
* Generate 503 randomly (simulate errors)
* Fill RAM with each request (simulate mem leaks)
* Ready delay for testing canary releases and readyness check

## Build

Expand All @@ -58,17 +59,19 @@ env GOOS=target-OS GOARCH=target-architecture go build .
troll -help

-fail int
Returns 503. Set 1 - 10, where 10 = 100% error rate.
Returns 503. Set 1 - 10, where 10 = 100% error rate.
-fill-ram int
Fill ram with each request. Set number in bytes.
Fill ram with each request. Set number in bytes.
-name string
Define custom application name (default "troll")
Define custom application name (default "troll")
-ready-delay int
Simulate long application init (seconds).
-root string
Define document root for serving files (default "./public")
Define document root for serving files (default "./public")
-v2-path string
Define path to v2 api endpoint configuration yaml (default "./v2_api.yaml")
Define path to v2 api endpoint configuration yaml (default "./v2_api.yaml")
-wait int
Minimal wait time before each request
Minimal wait time before each request
```

## Config
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module gitlab.com/theztd/troll

go 1.17
go 1.22

require (
github.com/gin-contrib/requestid v0.0.5
Expand Down
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s=
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
github.com/ugorji/go v1.2.7 h1:qYhyWUUd6WbiM+C6JZAUkIJt/1WrjzNHY9+KCIjVqTo=
github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=
Expand Down
12 changes: 12 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,24 @@ func main() {
flag.StringVar(&V2_PATH, "v2-path", "./v2_api.yaml", "Define path to v2 api endpoint configuration yaml")
flag.IntVar(&FAIL_FREQ, "fail", 0, "Returns 503. Set 1 - 10, where 10 = 100% error rate.")
flag.IntVar(&FILL_RAM, "fill-ram", 0, "Fill ram with each request. Set number in bytes.")
flag.IntVar(&READY_DELAY, "ready-delay", 0, "Simulate long application init (seconds).")

flag.Parse()

// it is better to be configurable via env
ADDRESS = getEnv("ADDRESS", ":8080")
LOG_LEVEL = getEnv("LOG_LEVEL", "info")

if READY_DELAY > 0 {
fmt.Printf("Application init")
for i := 0; i < READY_DELAY; i++ {
time.Sleep(time.Duration(1 * time.Second))
fmt.Printf(".")
}
fmt.Printf(" DONE\n\n")

}

// It is enought
getRoutes()

Expand Down
3 changes: 2 additions & 1 deletion variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
var router = gin.New()
var m = ginmetrics.GetMonitor()

var VERSION string = "1.1.2"
var VERSION string = "1.2.0"
var LOG_LEVEL string
var NAME string
var DOC_ROOT string
Expand All @@ -18,3 +18,4 @@ var ADDRESS string
var V2_PATH string
var FAIL_FREQ int = 0
var FILL_RAM int = 0
var READY_DELAY int = 0

0 comments on commit 7b81a84

Please sign in to comment.