⚠ Migrate TwinProduction/gatus to TwiN/gatus
This commit is contained in:
@ -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:
|
||||
|
@ -1,11 +1,11 @@
|
||||
# gocache
|
||||
|
||||

|
||||
[](https://goreportcard.com/report/github.com/TwinProduction/gocache)
|
||||
[](https://codecov.io/gh/TwinProduction/gocache)
|
||||
[](https://github.com/TwinProduction/gocache)
|
||||
[](https://pkg.go.dev/github.com/TwinProduction/gocache)
|
||||
[](https://github.com/TwinProduction)
|
||||

|
||||
[](https://goreportcard.com/report/github.com/TwiN/gocache)
|
||||
[](https://codecov.io/gh/TwiN/gocache)
|
||||
[](https://github.com/TwiN/gocache)
|
||||
[](https://pkg.go.dev/github.com/TwiN/gocache)
|
||||
[](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"
|
@ -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
|
@ -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
1
vendor/github.com/TwiN/health/.gitattributes
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
* text=auto eol=lf
|
9
vendor/github.com/TwiN/health/LICENSE.md
generated
vendored
Normal file
9
vendor/github.com/TwiN/health/LICENSE.md
generated
vendored
Normal 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.
|
@ -1,32 +1,30 @@
|
||||
# health
|
||||
|
||||

|
||||
[](https://goreportcard.com/report/github.com/TwinProduction/health)
|
||||
[](https://codecov.io/gh/TwinProduction/health)
|
||||
[](https://github.com/TwinProduction/health)
|
||||
[](https://pkg.go.dev/github.com/TwinProduction/health)
|
||||

|
||||
[](https://goreportcard.com/report/github.com/TwiN/health)
|
||||
[](https://codecov.io/gh/TwiN/health)
|
||||
[](https://github.com/TwiN/health)
|
||||
[](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()
|
||||
}
|
||||
```
|
@ -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
8
vendor/github.com/TwiN/health/status.go
generated
vendored
Normal 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
|
||||
)
|
1
vendor/github.com/TwinProduction/health/.gitattributes
generated
vendored
1
vendor/github.com/TwinProduction/health/.gitattributes
generated
vendored
@ -1 +0,0 @@
|
||||
* text=lf
|
8
vendor/github.com/TwinProduction/health/status.go
generated
vendored
8
vendor/github.com/TwinProduction/health/status.go
generated
vendored
@ -1,8 +0,0 @@
|
||||
package health
|
||||
|
||||
type Status string
|
||||
|
||||
var (
|
||||
Down Status = "DOWN"
|
||||
Up Status = "UP"
|
||||
)
|
Reference in New Issue
Block a user