This repository has been archived by the owner on Mar 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from essentialkaos/develop
Version 4.3.0
- Loading branch information
Showing
5 changed files
with
91 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,7 @@ | |
|
||
Summary: pkg.re morpher server | ||
Name: pkgre | ||
Version: 4.2.1 | ||
Version: 4.3.0 | ||
Release: 0%{?dist} | ||
Group: Applications/System | ||
License: Apache License, Version 2.0 | ||
|
@@ -153,6 +153,9 @@ rm -rf %{buildroot} | |
################################################################################ | ||
|
||
%changelog | ||
* Mon Dec 21 2020 Anton Novojilov <[email protected]> - 4.3.0-0 | ||
- Sending healthcheck requests | ||
|
||
* Fri Dec 18 2020 Anton Novojilov <[email protected]> - 4.2.1-0 | ||
- Improved URL generation for pkg.go.dev redirect | ||
- Dependencies updated to the latest versions | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package healthcheck | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
// // | ||
// Copyright (c) 2020 ESSENTIAL KAOS // | ||
// Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0> // | ||
// // | ||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
import ( | ||
"time" | ||
|
||
"pkg.re/essentialkaos/ek.v12/log" | ||
|
||
"github.com/valyala/fasthttp" | ||
) | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
type Checker struct { | ||
client *fasthttp.Client | ||
url string | ||
} | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
// Start starts healthcheck pinger | ||
func Start(url string, period time.Duration) { | ||
checker := &Checker{ | ||
url: url, | ||
client: &fasthttp.Client{ | ||
Name: "PKGRE Morpher/4", | ||
MaxIdleConnDuration: 5 * time.Second, | ||
ReadTimeout: 5 * time.Second, | ||
WriteTimeout: 3 * time.Second, | ||
MaxConnsPerHost: 10, | ||
}, | ||
} | ||
|
||
go checker.Run(period) | ||
} | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
// Run starts loop for sending pings | ||
func (c *Checker) Run(period time.Duration) { | ||
for range time.NewTicker(period).C { | ||
req := fasthttp.AcquireRequest() | ||
|
||
req.SetRequestURI(c.url) | ||
req.Header.SetMethod("HEAD") | ||
|
||
err := c.client.Do(req, nil) | ||
|
||
if err != nil { | ||
log.Error("Can't send healthcheck request: %v", err) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters