Skip to content

Commit

Permalink
feat: add livenessProbe & readinessProbe (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
bukowa committed Oct 18, 2022
1 parent 4666727 commit a14d8fe
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
5 changes: 2 additions & 3 deletions cliff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ body = """
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits %}
- {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message }}\
{% endfor %}
- {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }} | ( [ Commit ](https://github.com/bukowa/http-headers/commit/{{ commit.id }}) ) {% endfor %}
{% endfor %}\n
"""
# remove the leading and trailing whitespace from the template
Expand Down Expand Up @@ -57,7 +56,7 @@ commit_parsers = [
# filter out the commits that are not matched by commit parsers
filter_commits = true
# glob pattern for matching git tags
tag_pattern = "[0-9].[0-9].[0-9].*"
tag_pattern = "[0-9].[0-9].[0-9]"
# regex for skipping tags
skip_tags = "v0.1.0-beta.1"
# regex for ignoring tags
Expand Down
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,17 @@ func headers(w http.ResponseWriter, req *http.Request) {
}
}

func livenessProbe(w http.ResponseWriter, req *http.Request) {
w.WriteHeader(200)
}

func readinessProbe(w http.ResponseWriter, req *http.Request) {
w.WriteHeader(200)
}

func main() {
http.HandleFunc("/livenessProbe", livenessProbe)
http.HandleFunc("/readinessProbe", readinessProbe)
http.HandleFunc("/", headers)

var host = flag.String("host", "", "host to run on")
Expand Down
18 changes: 17 additions & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if [[ $line =~ "Starting instance" ]]; then
exit 1
fi

RESULT=$(curl -H 'User-Agent:' -H 'Header1: header1' -H 'Header2: header2' localhost:9001)
RESULT=$(curl -s -H 'User-Agent:' -H 'Header1: header1' -H 'Header2: header2' localhost:9001)

WANT='Instance name: example
Accept: [*/*]
Expand All @@ -32,3 +32,19 @@ if [[ "$RESULT" != "$WANT" ]]; then
else
echo "test passed"
fi

RESULT=$(curl -s -w "%{http_code}\n" "localhost:9001/livenessProbe")

if [[ "$RESULT" != 200 ]]; then
printf "test failed"; exit 1
else
echo "test passed"
fi

RESULT=$(curl -s -w "%{http_code}\n" "localhost:9001/readinessProbe")

if [[ "$RESULT" != 200 ]]; then
printf "test failed"; exit 1
else
echo "test passed"
fi

0 comments on commit a14d8fe

Please sign in to comment.