⚠ Migrate TwinProduction/gatus to TwiN/gatus

This commit is contained in:
TwiN
2021-10-07 21:28:04 -04:00
parent 422eaa6d37
commit 6c45f5b99c
92 changed files with 293 additions and 284 deletions

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2021 TwinProduction
Copyright (c) 2021 TwiN
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

View File

@ -1,11 +1,11 @@
# gocache
![build](https://github.com/TwinProduction/gocache/workflows/build/badge.svg?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/TwinProduction/gocache)](https://goreportcard.com/report/github.com/TwinProduction/gocache)
[![codecov](https://codecov.io/gh/TwinProduction/gocache/branch/master/graph/badge.svg)](https://codecov.io/gh/TwinProduction/gocache)
[![Go version](https://img.shields.io/github/go-mod/go-version/TwinProduction/gocache.svg)](https://github.com/TwinProduction/gocache)
[![Go Reference](https://pkg.go.dev/badge/github.com/TwinProduction/gocache.svg)](https://pkg.go.dev/github.com/TwinProduction/gocache)
[![Follow TwinProduction](https://img.shields.io/github/followers/TwinProduction?label=Follow&style=social)](https://github.com/TwinProduction)
![build](https://github.com/TwiN/gocache/workflows/build/badge.svg?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/TwiN/gocache)](https://goreportcard.com/report/github.com/TwiN/gocache)
[![codecov](https://codecov.io/gh/TwiN/gocache/branch/master/graph/badge.svg)](https://codecov.io/gh/TwiN/gocache)
[![Go version](https://img.shields.io/github/go-mod/go-version/TwiN/gocache.svg)](https://github.com/TwiN/gocache)
[![Go Reference](https://pkg.go.dev/badge/github.com/TwiN/gocache.svg)](https://pkg.go.dev/github.com/TwiN/gocache)
[![Follow TwiN](https://img.shields.io/github/followers/TwiN?label=Follow&style=social)](https://github.com/TwiN)
gocache is an easy-to-use, high-performance, lightweight and thread-safe (goroutine-safe) in-memory key-value cache
with support for LRU and FIFO eviction policies as well as expiration, bulk operations and even persistence to file.
@ -58,7 +58,7 @@ It may also serve as a good reference to use in order to implement gocache in yo
## Usage
```
go get -u github.com/TwinProduction/gocache
go get -u github.com/TwiN/gocache
```
If you're interested in using gocache as a server rather than an embedded library, see [Server](#server)
@ -101,7 +101,7 @@ cache.StartJanitor()
| SaveToFile | Stores the content of the cache to a file so that it can be read using `ReadFromFile`. See [persistence](#persistence).
| ReadFromFile | Populates the cache using a file created using `SaveToFile`. See [persistence](#persistence).
For further documentation, please refer to [Go Reference](https://pkg.go.dev/github.com/TwinProduction/gocache)
For further documentation, please refer to [Go Reference](https://pkg.go.dev/github.com/TwiN/gocache)
### Examples
@ -134,7 +134,7 @@ import (
"fmt"
"time"
"github.com/TwinProduction/gocache"
"github.com/TwiN/gocache"
)
func main() {
@ -323,8 +323,8 @@ For the sake of convenience, a ready-to-go cache server is available through the
package main
import (
"github.com/TwinProduction/gocache"
gocacheserver "github.com/TwinProduction/gocache/server"
"github.com/TwiN/gocache"
gocacheserver "github.com/TwiN/gocache/server"
)
func main() {
@ -490,7 +490,7 @@ import (
"os/signal"
"syscall"
"github.com/TwinProduction/gocache"
"github.com/TwiN/gocache"
)
const CacheFile = "gocache.data"

View File

@ -31,9 +31,9 @@ const (
)
var (
ErrKeyDoesNotExist = errors.New("key does not exist")
ErrKeyHasNoExpiration = errors.New("key has no expiration")
ErrJanitorAlreadyRunning = errors.New("janitor is already running")
ErrKeyDoesNotExist = errors.New("key does not exist") // Returned when a cache key does not exist
ErrKeyHasNoExpiration = errors.New("key has no expiration") // Returned when a cache key has no expiration
ErrJanitorAlreadyRunning = errors.New("janitor is already running") // Returned when the janitor has already been started
)
// Cache is the core struct of gocache which contains the data as well as all relevant configuration fields

View File

@ -42,7 +42,7 @@ func (cache *Cache) SaveToFile(path string) error {
if err != nil {
// Failed to encode the value, so we'll skip it.
// This is likely due to the fact that the custom struct wasn't registered using gob.Register(...)
// See [Persistence - Limitations](https://github.com/TwinProduction/gocache#limitations)
// See [Persistence - Limitations](https://github.com/TwiN/gocache#limitations)
continue
}
bucket.Put([]byte(bulkEntry.Key), buffer.Bytes())
@ -91,7 +91,7 @@ func (cache *Cache) ReadFromFile(path string) (int, error) {
// decoding the struct would fail. This can be avoided by using a different variable name every
// time you must change the type of a variable within a struct.
//
// See [Persistence - Limitations](https://github.com/TwinProduction/gocache#limitations)
// See [Persistence - Limitations](https://github.com/TwiN/gocache#limitations)
return err
}
cache.entries[string(k)] = &entry

1
vendor/github.com/TwiN/health/.gitattributes generated vendored Normal file
View File

@ -0,0 +1 @@
* text=auto eol=lf

9
vendor/github.com/TwiN/health/LICENSE.md generated vendored Normal file
View File

@ -0,0 +1,9 @@
MIT License
Copyright (c) 2021 TwiN
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,32 +1,30 @@
# health
![build](https://github.com/TwinProduction/health/workflows/build/badge.svg?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/TwinProduction/health)](https://goreportcard.com/report/github.com/TwinProduction/health)
[![codecov](https://codecov.io/gh/TwinProduction/health/branch/master/graph/badge.svg)](https://codecov.io/gh/TwinProduction/health)
[![Go version](https://img.shields.io/github/go-mod/go-version/TwinProduction/health.svg)](https://github.com/TwinProduction/health)
[![Go Reference](https://pkg.go.dev/badge/github.com/TwinProduction/health.svg)](https://pkg.go.dev/github.com/TwinProduction/health)
![build](https://github.com/TwiN/health/workflows/build/badge.svg?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/TwiN/health)](https://goreportcard.com/report/github.com/TwiN/health)
[![codecov](https://codecov.io/gh/TwiN/health/branch/master/graph/badge.svg)](https://codecov.io/gh/TwiN/health)
[![Go version](https://img.shields.io/github/go-mod/go-version/TwiN/health.svg)](https://github.com/TwiN/health)
[![Go Reference](https://pkg.go.dev/badge/github.com/TwiN/health.svg)](https://pkg.go.dev/github.com/TwiN/health)
Health is a library used for creating a very simple health endpoint.
While implementing a health endpoint is very simple, I've grown tired of implementing
it over and over again.
## Installation
## Installation
```
go get -u github.com/TwinProduction/health
go get -u github.com/TwiN/health
```
## Usage
To retrieve the handler, you must use `health.Handler()` and are expected to pass it to the router like so:
```go
router := http.NewServeMux()
router.Handle("/health", health.Handler())
server := &http.Server{
Addr: ":8080",
Handler: router,
Addr: ":8080",
Handler: router,
}
```
@ -45,28 +43,28 @@ health.SetStatus(health.Up)
health.SetStatus(health.Down)
```
### Complete example
### Complete example
```go
package main
import (
"net/http"
"time"
"net/http"
"time"
"github.com/TwinProduction/health"
"github.com/TwiN/health"
)
func main() {
router := http.NewServeMux()
router.Handle("/health", health.Handler())
server := &http.Server{
Addr: "0.0.0.0:8080",
Handler: router,
ReadTimeout: 15 * time.Second,
WriteTimeout: 15 * time.Second,
IdleTimeout: 15 * time.Second,
}
server.ListenAndServe()
router := http.NewServeMux()
router.Handle("/health", health.Handler())
server := &http.Server{
Addr: "0.0.0.0:8080",
Handler: router,
ReadTimeout: 15 * time.Second,
WriteTimeout: 15 * time.Second,
IdleTimeout: 15 * time.Second,
}
server.ListenAndServe()
}
```

View File

@ -9,6 +9,7 @@ var (
}
)
// healthHandler is the HTTP handler for serving the health endpoint
type healthHandler struct {
useJSON bool
status Status
@ -22,7 +23,8 @@ func (h *healthHandler) WithJSON(v bool) *healthHandler {
return h
}
func (h healthHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request) {
// ServeHTTP serves the HTTP request for the health handler
func (h healthHandler) ServeHTTP(writer http.ResponseWriter, _ *http.Request) {
var status int
var body []byte
if h.status == Up {

8
vendor/github.com/TwiN/health/status.go generated vendored Normal file
View File

@ -0,0 +1,8 @@
package health
type Status string
var (
Down Status = "DOWN" // For when the application is unhealthy
Up Status = "UP" // For when the application is healthy
)

View File

@ -1 +0,0 @@
* text=lf

View File

@ -1,8 +0,0 @@
package health
type Status string
var (
Down Status = "DOWN"
Up Status = "UP"
)