Compare commits
24 Commits
a13770b2cd
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| c47de4cd63 | |||
|
19fc8d1185
|
|||
|
5fff23f01b
|
|||
|
9b319d6adc
|
|||
|
0a8f82f0d6
|
|||
|
|
9607f99932
|
||
| f66c40ef36 | |||
| 7ce1731a6f | |||
| c72ef8350b | |||
|
7e9653606e
|
|||
|
e7592e8737
|
|||
|
334c0c1480
|
|||
|
abc87abe88
|
|||
|
1367783e8a
|
|||
|
|
51e48dd842 | ||
|
3a3580b6ed
|
|||
|
dc5c363583
|
|||
|
c7d94c6965
|
|||
|
628abc4d11
|
|||
|
b33df27b31
|
|||
|
1958d9b3d9
|
|||
|
64121d56c7
|
|||
|
f5d780fb1b
|
|||
|
a4050c28dc
|
10
.env
10
.env
@@ -1,11 +1,19 @@
|
|||||||
APP_HOST=http://localhost:8080
|
APP_HOST=http://localhost:8080
|
||||||
|
APP_TZ=Europe/Moscow
|
||||||
|
|
||||||
|
# panic
|
||||||
|
# fatal
|
||||||
|
# error
|
||||||
|
# warn
|
||||||
|
# info
|
||||||
|
# debug
|
||||||
|
LOG_LEVEL=debug
|
||||||
|
|
||||||
DATABASE_HOST=localhost
|
DATABASE_HOST=localhost
|
||||||
DATABASE_PORT=5444
|
DATABASE_PORT=5444
|
||||||
DATABASE_USER=status
|
DATABASE_USER=status
|
||||||
DATABASE_PASS=status
|
DATABASE_PASS=status
|
||||||
DATABASE_DB=status
|
DATABASE_DB=status
|
||||||
DATABASE_TZ=Europe/Moscow
|
|
||||||
|
|
||||||
RABBIT_USER=user
|
RABBIT_USER=user
|
||||||
RABBIT_PASSWORD=user
|
RABBIT_PASSWORD=user
|
||||||
|
|||||||
26
.github/workflows/golang-lint.yml
vendored
Normal file
26
.github/workflows/golang-lint.yml
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
name: Lint Golang
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- dev
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
pull-requests: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
golangci:
|
||||||
|
name: lint
|
||||||
|
runs-on: self-hosted
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
- uses: actions/setup-go@v6
|
||||||
|
with:
|
||||||
|
go-version: 1.25.0
|
||||||
|
- name: golangci-lint
|
||||||
|
uses: golangci/golangci-lint-action@v8
|
||||||
|
with:
|
||||||
|
version: v2.5.0
|
||||||
|
args: '--config=${{ github.workspace }}/.golangci.yml'
|
||||||
47
.github/workflows/release.yml
vendored
47
.github/workflows/release.yml
vendored
@@ -1,16 +1,35 @@
|
|||||||
name: goreleaser
|
name: Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
# run only against tags
|
branches:
|
||||||
tags:
|
- master
|
||||||
- "*"
|
- main
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
semantic-release:
|
||||||
|
name: Sematic Release
|
||||||
|
runs-on: self-hosted
|
||||||
|
outputs:
|
||||||
|
releaseContentLink: ${{ steps.release.outputs.releaseContentLink }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Release
|
||||||
|
id: release
|
||||||
|
run: |
|
||||||
|
export TMP_FILE_NAME=$(openssl rand -hex 36)
|
||||||
|
yarn install
|
||||||
|
yarn semantic-release
|
||||||
|
echo "releaseContentLink=$(cat /tmp/$TMP_FILE_NAME | curl -F '_=<-' https://past.ostiwe.com)" >> "$GITHUB_OUTPUT"
|
||||||
goreleaser:
|
goreleaser:
|
||||||
|
needs: semantic-release
|
||||||
|
name: Goreleaser
|
||||||
runs-on: self-hosted
|
runs-on: self-hosted
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@@ -21,11 +40,17 @@ jobs:
|
|||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '^1.25'
|
go-version: '^1.25'
|
||||||
- name: Run GoReleaser
|
- name: Install go release
|
||||||
uses: goreleaser/goreleaser-action@v6
|
run: go install github.com/goreleaser/goreleaser/v2@latest
|
||||||
with:
|
- name: Get release notes
|
||||||
distribution: goreleaser
|
id: get-notes
|
||||||
version: "~> v2"
|
run: |
|
||||||
args: release --clean
|
export FILE_NAME=$(openssl rand -hex 36)
|
||||||
|
echo "name=$FILE_NAME" >> "$GITHUB_OUTPUT"
|
||||||
|
curl -L ${{ needs.semantic-release.outputs.releaseContentLink }} >> "/tmp/$FILE_NAME"
|
||||||
|
- name: Run Goreleaser
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.GORELEASER_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.GORELEASER_TOKEN }}
|
||||||
|
run: |
|
||||||
|
goreleaser release --release-notes /tmp/${{ steps.get-notes.outputs.name }} --clean
|
||||||
|
rm /tmp/${{ steps.get-notes.outputs.name }}
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -55,3 +55,4 @@ Temporary Items
|
|||||||
.apdisk
|
.apdisk
|
||||||
# Added by goreleaser init:
|
# Added by goreleaser init:
|
||||||
dist/
|
dist/
|
||||||
|
node_modules
|
||||||
|
|||||||
27
.golangci.yml
Normal file
27
.golangci.yml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
version: "2"
|
||||||
|
|
||||||
|
run:
|
||||||
|
relative-path-mode: gomod
|
||||||
|
timeout: 5m
|
||||||
|
|
||||||
|
linters:
|
||||||
|
settings:
|
||||||
|
dupl:
|
||||||
|
threshold: 100
|
||||||
|
enable:
|
||||||
|
- errcheck
|
||||||
|
- govet
|
||||||
|
- ineffassign
|
||||||
|
- staticcheck
|
||||||
|
- unused
|
||||||
|
- errname
|
||||||
|
- dupl
|
||||||
|
- decorder
|
||||||
|
- cyclop
|
||||||
|
- funlen
|
||||||
|
- lll
|
||||||
|
- nestif
|
||||||
|
- nlreturn
|
||||||
|
- prealloc
|
||||||
|
- tagalign
|
||||||
|
- whitespace
|
||||||
@@ -1,17 +1,10 @@
|
|||||||
version: 2
|
version: 2
|
||||||
|
|
||||||
before:
|
|
||||||
hooks:
|
|
||||||
- go mod tidy
|
|
||||||
|
|
||||||
builds:
|
builds:
|
||||||
- env:
|
- env:
|
||||||
- CGO_ENABLED=0
|
- CGO_ENABLED=0
|
||||||
goos:
|
goos:
|
||||||
- linux
|
- linux
|
||||||
- windows
|
|
||||||
- darwin
|
|
||||||
- freebsd
|
|
||||||
ldflags:
|
ldflags:
|
||||||
- -s -w
|
- -s -w
|
||||||
- -X 'git.ostiwe.com/ostiwe-com/status/version.ApplicationVersion={{.Tag}}'
|
- -X 'git.ostiwe.com/ostiwe-com/status/version.ApplicationVersion={{.Tag}}'
|
||||||
@@ -31,41 +24,6 @@ archives:
|
|||||||
- goos: windows
|
- goos: windows
|
||||||
formats: [zip]
|
formats: [zip]
|
||||||
|
|
||||||
changelog:
|
|
||||||
use: gitea
|
|
||||||
format: "{{ .SHA }}: {{ .Message }}{{ with .AuthorUsername }} (@{{ . }}){{ end }}"
|
|
||||||
abbrev: 0
|
|
||||||
sort: asc
|
|
||||||
groups:
|
|
||||||
- title: Features
|
|
||||||
regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$'
|
|
||||||
order: 0
|
|
||||||
- title: Fixes
|
|
||||||
regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$'
|
|
||||||
order: 1
|
|
||||||
- title: Refactoring
|
|
||||||
regexp: '^.*?refactor(\([[:word:]]+\))??!?:.+$'
|
|
||||||
order: 2
|
|
||||||
- title: "Bug fixes"
|
|
||||||
regexp: '^.*?bug(\([[:word:]]+\))??!?:.+$'
|
|
||||||
order: 3
|
|
||||||
- title: Others
|
|
||||||
order: 999
|
|
||||||
filters:
|
|
||||||
exclude:
|
|
||||||
- "^docs:"
|
|
||||||
- "^test:"
|
|
||||||
|
|
||||||
release:
|
|
||||||
gitea:
|
|
||||||
name: status
|
|
||||||
owner: ostiwe-com
|
|
||||||
footer: >-
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
Released by [GoReleaser](https://github.com/goreleaser/goreleaser).
|
|
||||||
|
|
||||||
gitea_urls:
|
gitea_urls:
|
||||||
api: https://git.ostiwe.com/api/v1
|
api: https://git.ostiwe.com/api/v1
|
||||||
download: https://git.ostiwe.com
|
download: https://git.ostiwe.com
|
||||||
41
CHANGELOG.md
Normal file
41
CHANGELOG.md
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
## [1.2.0](https://git.ostiwe.com/ostiwe-com/status/compare/v1.1.1...v1.2.0) (2025-10-29)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Added ID field to PublicService DTO, update fields in Service model, fix CalculateUptimePercent method, transform services to Public services in goroutines ([a4050c2](https://git.ostiwe.com/ostiwe-com/status/commit/a4050c28dc9cfb2edcc3716b91af4a8ba146637b))
|
||||||
|
* **ci:** Update release config ([1367783](https://git.ostiwe.com/ostiwe-com/status/commit/1367783e8acb2e4e1503489794c52460133c815b))
|
||||||
|
* **ci:** Update release config ([dc5c363](https://git.ostiwe.com/ostiwe-com/status/commit/dc5c3635831dffd5e0e9da25e8e69b9ebf29663c))
|
||||||
|
* **ci:** Update release config ([64121d5](https://git.ostiwe.com/ostiwe-com/status/commit/64121d56c7def468b880a30cd0c1f86a25fd3398))
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Fix errors ([7e96536](https://git.ostiwe.com/ostiwe-com/status/commit/7e9653606e5b0c14294481abde4be9121fc3afd2))
|
||||||
|
* Recreate closeNotify channel on recreate rabbit connection ([f5d780f](https://git.ostiwe.com/ostiwe-com/status/commit/f5d780fb1b682aa1f6f29b9297ed1e3e22ad15e1))
|
||||||
|
|
||||||
|
### CI/CD Changes
|
||||||
|
|
||||||
|
* Added golangci linter ([e7592e8](https://git.ostiwe.com/ostiwe-com/status/commit/e7592e87378f273d33ce170484d956607a663cd5))
|
||||||
|
* Change CI ([334c0c1](https://git.ostiwe.com/ostiwe-com/status/commit/334c0c1480afc22b1deac93b613f407ff0f3de26))
|
||||||
|
* Install go-releaser in CI ([abc87ab](https://git.ostiwe.com/ostiwe-com/status/commit/abc87abe8859efdcbf226c8aefe3e5ef94c64b0a))
|
||||||
|
|
||||||
|
### Refactoring
|
||||||
|
|
||||||
|
* Added node_modules to ignore for git ([c7d94c6](https://git.ostiwe.com/ostiwe-com/status/commit/c7d94c6965333d638436b0dca8a2a58767f1497e))
|
||||||
|
* Remove unused code ([1958d9b](https://git.ostiwe.com/ostiwe-com/status/commit/1958d9b3d94fe32d7c4fcefb66acb0cd475d98ec))
|
||||||
|
* Switching to a cron system for tasks, restructuring service and status models ([b33df27](https://git.ostiwe.com/ostiwe-com/status/commit/b33df27b31587ba935c1a3d2abc04b7b98bed531))
|
||||||
|
* Update startup server ([628abc4](https://git.ostiwe.com/ostiwe-com/status/commit/628abc4d11849d751bbf21fd79ea637f09a66521))
|
||||||
|
|
||||||
|
|
||||||
|
# [1.2.0](https://git.ostiwe.com/ostiwe-com/status/compare/v1.1.1...v1.2.0) (2025-10-28)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Recreate closeNotify channel on recreate rabbit connection ([f5d780f](https://git.ostiwe.com/ostiwe-com/status/commit/f5d780fb1b682aa1f6f29b9297ed1e3e22ad15e1))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Added ID field to PublicService DTO, update fields in Service model, fix CalculateUptimePercent method, transform services to Public services in goroutines ([a4050c2](https://git.ostiwe.com/ostiwe-com/status/commit/a4050c28dc9cfb2edcc3716b91af4a8ba146637b))
|
||||||
|
* **ci:** Update release config ([dc5c363](https://git.ostiwe.com/ostiwe-com/status/commit/dc5c3635831dffd5e0e9da25e8e69b9ebf29663c))
|
||||||
|
* **ci:** Update release config ([64121d5](https://git.ostiwe.com/ostiwe-com/status/commit/64121d56c7def468b880a30cd0c1f86a25fd3398))
|
||||||
@@ -3,8 +3,9 @@ package dto
|
|||||||
import "git.ostiwe.com/ostiwe-com/status/model"
|
import "git.ostiwe.com/ostiwe-com/status/model"
|
||||||
|
|
||||||
type PublicService struct {
|
type PublicService struct {
|
||||||
|
ID int `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Description string `json:"description"`
|
Description *string `json:"description"`
|
||||||
Statuses []model.Status `json:"statuses"`
|
Statuses []model.Status `json:"statuses"`
|
||||||
Uptime float64 `json:"uptime"`
|
Uptime float64 `json:"uptime"`
|
||||||
}
|
}
|
||||||
|
|||||||
5
go.mod
5
go.mod
@@ -8,11 +8,14 @@ require (
|
|||||||
github.com/go-chi/chi/v5 v5.2.2
|
github.com/go-chi/chi/v5 v5.2.2
|
||||||
github.com/go-chi/jwtauth/v5 v5.3.3
|
github.com/go-chi/jwtauth/v5 v5.3.3
|
||||||
github.com/go-chi/render v1.0.3
|
github.com/go-chi/render v1.0.3
|
||||||
|
github.com/go-co-op/gocron/v2 v2.17.0
|
||||||
github.com/golang-jwt/jwt/v5 v5.3.0
|
github.com/golang-jwt/jwt/v5 v5.3.0
|
||||||
|
github.com/google/uuid v1.6.0
|
||||||
github.com/joho/godotenv v1.5.1
|
github.com/joho/godotenv v1.5.1
|
||||||
github.com/lestrrat-go/jwx/v2 v2.1.6
|
github.com/lestrrat-go/jwx/v2 v2.1.6
|
||||||
github.com/pressly/goose/v3 v3.24.3
|
github.com/pressly/goose/v3 v3.24.3
|
||||||
github.com/rabbitmq/amqp091-go v1.10.0
|
github.com/rabbitmq/amqp091-go v1.10.0
|
||||||
|
github.com/samber/lo v1.52.0
|
||||||
github.com/sirupsen/logrus v1.9.3
|
github.com/sirupsen/logrus v1.9.3
|
||||||
go.uber.org/mock v0.6.0
|
go.uber.org/mock v0.6.0
|
||||||
golang.org/x/crypto v0.41.0
|
golang.org/x/crypto v0.41.0
|
||||||
@@ -33,6 +36,7 @@ require (
|
|||||||
github.com/jackc/puddle/v2 v2.2.2 // indirect
|
github.com/jackc/puddle/v2 v2.2.2 // indirect
|
||||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||||
github.com/jinzhu/now v1.1.5 // indirect
|
github.com/jinzhu/now v1.1.5 // indirect
|
||||||
|
github.com/jonboulle/clockwork v0.5.0 // indirect
|
||||||
github.com/kr/pretty v0.3.1 // indirect
|
github.com/kr/pretty v0.3.1 // indirect
|
||||||
github.com/lestrrat-go/blackmagic v1.0.4 // indirect
|
github.com/lestrrat-go/blackmagic v1.0.4 // indirect
|
||||||
github.com/lestrrat-go/httpcc v1.0.1 // indirect
|
github.com/lestrrat-go/httpcc v1.0.1 // indirect
|
||||||
@@ -40,6 +44,7 @@ require (
|
|||||||
github.com/lestrrat-go/iter v1.0.2 // indirect
|
github.com/lestrrat-go/iter v1.0.2 // indirect
|
||||||
github.com/lestrrat-go/option v1.0.1 // indirect
|
github.com/lestrrat-go/option v1.0.1 // indirect
|
||||||
github.com/mfridman/interpolate v0.0.2 // indirect
|
github.com/mfridman/interpolate v0.0.2 // indirect
|
||||||
|
github.com/robfig/cron/v3 v3.0.1 // indirect
|
||||||
github.com/segmentio/asm v1.2.0 // indirect
|
github.com/segmentio/asm v1.2.0 // indirect
|
||||||
github.com/sethvargo/go-retry v0.3.0 // indirect
|
github.com/sethvargo/go-retry v0.3.0 // indirect
|
||||||
go.uber.org/multierr v1.11.0 // indirect
|
go.uber.org/multierr v1.11.0 // indirect
|
||||||
|
|||||||
32
go.sum
32
go.sum
@@ -8,8 +8,6 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
|
|||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg=
|
|
||||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0=
|
|
||||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 h1:NMZiJj8QnKe1LgsbDayM4UoHwbvwDRwnI3hwNaAHRnc=
|
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 h1:NMZiJj8QnKe1LgsbDayM4UoHwbvwDRwnI3hwNaAHRnc=
|
||||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0/go.mod h1:ZXNYxsqcloTdSy/rNShjYzMhyjf0LaoftYK0p+A3h40=
|
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0/go.mod h1:ZXNYxsqcloTdSy/rNShjYzMhyjf0LaoftYK0p+A3h40=
|
||||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||||
@@ -26,8 +24,8 @@ github.com/go-chi/jwtauth/v5 v5.3.3 h1:50Uzmacu35/ZP9ER2Ht6SazwPsnLQ9LRJy6zTZJpH
|
|||||||
github.com/go-chi/jwtauth/v5 v5.3.3/go.mod h1:O4QvPRuZLZghl9WvfVaON+ARfGzpD2PBX/QY5vUz7aQ=
|
github.com/go-chi/jwtauth/v5 v5.3.3/go.mod h1:O4QvPRuZLZghl9WvfVaON+ARfGzpD2PBX/QY5vUz7aQ=
|
||||||
github.com/go-chi/render v1.0.3 h1:AsXqd2a1/INaIfUSKq3G5uA8weYx20FOsM7uSoCyyt4=
|
github.com/go-chi/render v1.0.3 h1:AsXqd2a1/INaIfUSKq3G5uA8weYx20FOsM7uSoCyyt4=
|
||||||
github.com/go-chi/render v1.0.3/go.mod h1:/gr3hVkmYR0YlEy3LxCuVRFzEu9Ruok+gFqbIofjao0=
|
github.com/go-chi/render v1.0.3/go.mod h1:/gr3hVkmYR0YlEy3LxCuVRFzEu9Ruok+gFqbIofjao0=
|
||||||
github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA=
|
github.com/go-co-op/gocron/v2 v2.17.0 h1:e/oj6fcAM8vOOKZxv2Cgfmjo+s8AXC46po5ZPtaSea4=
|
||||||
github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
github.com/go-co-op/gocron/v2 v2.17.0/go.mod h1:Zii6he+Zfgy5W9B+JKk/KwejFOW0kZTFvHtwIpR4aBI=
|
||||||
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
||||||
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||||
github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo=
|
github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo=
|
||||||
@@ -48,12 +46,12 @@ github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
|||||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||||
|
github.com/jonboulle/clockwork v0.5.0 h1:Hyh9A8u51kptdkR+cqRpT1EebBwTn1oK9YfGYbdFz6I=
|
||||||
|
github.com/jonboulle/clockwork v0.5.0/go.mod h1:3mZlmanh0g2NDKO5TWZVJAfofYk64M7XN3SzBPjZF60=
|
||||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
github.com/lestrrat-go/blackmagic v1.0.2 h1:Cg2gVSc9h7sz9NOByczrbUvLopQmXrfFx//N+AkAr5k=
|
|
||||||
github.com/lestrrat-go/blackmagic v1.0.2/go.mod h1:UrEqBzIR2U6CnzVyUtfM6oZNMt/7O7Vohk2J0OGSAtU=
|
|
||||||
github.com/lestrrat-go/blackmagic v1.0.4 h1:IwQibdnf8l2KoO+qC3uT4OaTWsW7tuRQXy9TRN9QanA=
|
github.com/lestrrat-go/blackmagic v1.0.4 h1:IwQibdnf8l2KoO+qC3uT4OaTWsW7tuRQXy9TRN9QanA=
|
||||||
github.com/lestrrat-go/blackmagic v1.0.4/go.mod h1:6AWFyKNNj0zEXQYfTMPfZrAXUWUfTIZ5ECEUEJaijtw=
|
github.com/lestrrat-go/blackmagic v1.0.4/go.mod h1:6AWFyKNNj0zEXQYfTMPfZrAXUWUfTIZ5ECEUEJaijtw=
|
||||||
github.com/lestrrat-go/httpcc v1.0.1 h1:ydWCStUeJLkpYyjLDHihupbn2tYmZ7m22BGkcvZZrIE=
|
github.com/lestrrat-go/httpcc v1.0.1 h1:ydWCStUeJLkpYyjLDHihupbn2tYmZ7m22BGkcvZZrIE=
|
||||||
@@ -62,8 +60,6 @@ github.com/lestrrat-go/httprc v1.0.6 h1:qgmgIRhpvBqexMJjA/PmwSvhNk679oqD1RbovdCG
|
|||||||
github.com/lestrrat-go/httprc v1.0.6/go.mod h1:mwwz3JMTPBjHUkkDv/IGJ39aALInZLrhBp0X7KGUZlo=
|
github.com/lestrrat-go/httprc v1.0.6/go.mod h1:mwwz3JMTPBjHUkkDv/IGJ39aALInZLrhBp0X7KGUZlo=
|
||||||
github.com/lestrrat-go/iter v1.0.2 h1:gMXo1q4c2pHmC3dn8LzRhJfP1ceCbgSiT9lUydIzltI=
|
github.com/lestrrat-go/iter v1.0.2 h1:gMXo1q4c2pHmC3dn8LzRhJfP1ceCbgSiT9lUydIzltI=
|
||||||
github.com/lestrrat-go/iter v1.0.2/go.mod h1:Momfcq3AnRlRjI5b5O8/G5/BvpzrhoFTZcn06fEOPt4=
|
github.com/lestrrat-go/iter v1.0.2/go.mod h1:Momfcq3AnRlRjI5b5O8/G5/BvpzrhoFTZcn06fEOPt4=
|
||||||
github.com/lestrrat-go/jwx/v2 v2.1.3 h1:Ud4lb2QuxRClYAmRleF50KrbKIoM1TddXgBrneT5/Jo=
|
|
||||||
github.com/lestrrat-go/jwx/v2 v2.1.3/go.mod h1:q6uFgbgZfEmQrfJfrCo90QcQOcXFMfbI/fO0NqRtvZo=
|
|
||||||
github.com/lestrrat-go/jwx/v2 v2.1.6 h1:hxM1gfDILk/l5ylers6BX/Eq1m/pnxe9NBwW6lVfecA=
|
github.com/lestrrat-go/jwx/v2 v2.1.6 h1:hxM1gfDILk/l5ylers6BX/Eq1m/pnxe9NBwW6lVfecA=
|
||||||
github.com/lestrrat-go/jwx/v2 v2.1.6/go.mod h1:Y722kU5r/8mV7fYDifjug0r8FK8mZdw0K0GpJw/l8pU=
|
github.com/lestrrat-go/jwx/v2 v2.1.6/go.mod h1:Y722kU5r/8mV7fYDifjug0r8FK8mZdw0K0GpJw/l8pU=
|
||||||
github.com/lestrrat-go/option v1.0.1 h1:oAzP2fvZGQKWkvHa1/SAcFolBEca1oN+mQ7eooNBEYU=
|
github.com/lestrrat-go/option v1.0.1 h1:oAzP2fvZGQKWkvHa1/SAcFolBEca1oN+mQ7eooNBEYU=
|
||||||
@@ -83,9 +79,13 @@ github.com/rabbitmq/amqp091-go v1.10.0 h1:STpn5XsHlHGcecLmMFCtg7mqq0RnD+zFr4uzuk
|
|||||||
github.com/rabbitmq/amqp091-go v1.10.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o=
|
github.com/rabbitmq/amqp091-go v1.10.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o=
|
||||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
||||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||||
|
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
||||||
|
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||||
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||||
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
||||||
|
github.com/samber/lo v1.52.0 h1:Rvi+3BFHES3A8meP33VPAxiBZX/Aws5RxrschYGjomw=
|
||||||
|
github.com/samber/lo v1.52.0/go.mod h1:4+MXEGsJzbKGaUEQFKBq2xtfuznW9oz/WrgyzMzRoM0=
|
||||||
github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys=
|
github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys=
|
||||||
github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
|
github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
|
||||||
github.com/sethvargo/go-retry v0.3.0 h1:EEt31A35QhrcRZtrYFDTBg91cqZVnFL2navjDrah2SE=
|
github.com/sethvargo/go-retry v0.3.0 h1:EEt31A35QhrcRZtrYFDTBg91cqZVnFL2navjDrah2SE=
|
||||||
@@ -98,33 +98,23 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
|
|||||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||||
go.uber.org/mock v0.5.2 h1:LbtPTcP8A5k9WPXj54PPPbjcI4Y6lhyOZXn+VS7wNko=
|
|
||||||
go.uber.org/mock v0.5.2/go.mod h1:wLlUxC2vVTPTaE3UD51E0BGOAElKrILxhVSDYQLld5o=
|
|
||||||
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
|
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
|
||||||
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
|
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
|
||||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||||
golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM=
|
|
||||||
golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY=
|
|
||||||
golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4=
|
golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4=
|
||||||
golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc=
|
golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc=
|
||||||
golang.org/x/exp v0.0.0-20250718183923-645b1fa84792 h1:R9PFI6EUdfVKgwKjZef7QIwGcBKu86OEFpJ9nUEP2l4=
|
|
||||||
golang.org/x/exp v0.0.0-20250718183923-645b1fa84792/go.mod h1:A+z0yzpGtvnG90cToK5n2tu8UJVP2XUATh+r+sfOOOc=
|
|
||||||
golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b h1:DXr+pvt3nC887026GRP39Ej11UATqWDmWuS99x26cD0=
|
golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b h1:DXr+pvt3nC887026GRP39Ej11UATqWDmWuS99x26cD0=
|
||||||
golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b/go.mod h1:4QTo5u+SEIbbKW1RacMZq1YEfOBqeXa19JeshGi+zc4=
|
golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b/go.mod h1:4QTo5u+SEIbbKW1RacMZq1YEfOBqeXa19JeshGi+zc4=
|
||||||
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
|
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
|
||||||
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
||||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA=
|
|
||||||
golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
|
||||||
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
|
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
|
||||||
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||||
golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4=
|
|
||||||
golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU=
|
|
||||||
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
|
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
|
||||||
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
|
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
@@ -135,8 +125,6 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
|||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gorm.io/driver/postgres v1.6.0 h1:2dxzU8xJ+ivvqTRph34QX+WrRaJlmfyPqXmoGVjMBa4=
|
gorm.io/driver/postgres v1.6.0 h1:2dxzU8xJ+ivvqTRph34QX+WrRaJlmfyPqXmoGVjMBa4=
|
||||||
gorm.io/driver/postgres v1.6.0/go.mod h1:vUw0mrGgrTK+uPHEhAdV4sfFELrByKVGnaVRkXDhtWo=
|
gorm.io/driver/postgres v1.6.0/go.mod h1:vUw0mrGgrTK+uPHEhAdV4sfFELrByKVGnaVRkXDhtWo=
|
||||||
gorm.io/gorm v1.30.0 h1:qbT5aPv1UH8gI99OsRlvDToLxW5zR7FzS9acZDOZcgs=
|
|
||||||
gorm.io/gorm v1.30.0/go.mod h1:8Z33v652h4//uMA76KjeDH8mJXPm1QNCYrMeatR0DOE=
|
|
||||||
gorm.io/gorm v1.30.1 h1:lSHg33jJTBxs2mgJRfRZeLDG+WZaHYCk3Wtfl6Ngzo4=
|
gorm.io/gorm v1.30.1 h1:lSHg33jJTBxs2mgJRfRZeLDG+WZaHYCk3Wtfl6Ngzo4=
|
||||||
gorm.io/gorm v1.30.1/go.mod h1:8Z33v652h4//uMA76KjeDH8mJXPm1QNCYrMeatR0DOE=
|
gorm.io/gorm v1.30.1/go.mod h1:8Z33v652h4//uMA76KjeDH8mJXPm1QNCYrMeatR0DOE=
|
||||||
modernc.org/libc v1.65.0 h1:e183gLDnAp9VJh6gWKdTy0CThL9Pt7MfcR/0bgb7Y1Y=
|
modernc.org/libc v1.65.0 h1:e183gLDnAp9VJh6gWKdTy0CThL9Pt7MfcR/0bgb7Y1Y=
|
||||||
|
|||||||
8
migrations/00004_add_metric_columns_to_statuses.sql
Normal file
8
migrations/00004_add_metric_columns_to_statuses.sql
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
-- +goose Up
|
||||||
|
alter table statuses
|
||||||
|
add column response_time integer default null;
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
|
|
||||||
|
alter table statuses
|
||||||
|
drop column response_time;
|
||||||
@@ -9,23 +9,29 @@ type HTTPConfig struct {
|
|||||||
|
|
||||||
type ServiceTypeCheckConfig struct {
|
type ServiceTypeCheckConfig struct {
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
HTTPConfig *HTTPConfig `json:"http_config"`
|
HTTPConfig *HTTPConfig `json:"httpConfig"`
|
||||||
|
// MaxFails - max "ping" fails, after with the service marked as unavailable
|
||||||
|
MaxFails uint8 `json:"maxFails"`
|
||||||
|
// Interval - interval between "ping" in seconds
|
||||||
|
Interval uint64 `json:"interval"`
|
||||||
|
// Timeout - interval after which the task will be canceled
|
||||||
|
Timeout uint64 `json:"timeout"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Service struct {
|
type Service struct {
|
||||||
// Unique ID for entity
|
// Unique ID for entity
|
||||||
ID int `gorm:"primary_key;auto_increment" json:"id"`
|
ID uint64 `gorm:"primary_key;auto_increment" json:"id"`
|
||||||
// Human-readable service name
|
// Human-readable service name
|
||||||
Name string `gorm:"size:255;not null" json:"name"`
|
Name string `gorm:"size:255;not null" json:"name"`
|
||||||
// Human-readable service description
|
// Human-readable service description
|
||||||
Description string `gorm:"size:255" json:"description"`
|
Description string `gorm:"size:255" json:"description"`
|
||||||
PublicDescription string `gorm:"size:255" json:"public_description"`
|
PublicDescription string `gorm:"size:255" json:"publicDescription"`
|
||||||
Public *bool `gorm:"default:false" json:"public"`
|
Public *bool `gorm:"default:false" json:"public"`
|
||||||
// Host to check, for example 192.168.1.44
|
// Host to check, for example 192.168.1.44 or https://google.com
|
||||||
Host string `gorm:"size:255;not null" json:"host"`
|
Host string `gorm:"size:255;not null" json:"host"`
|
||||||
// Type for check, for now is TCP or HTTP
|
// Type for check, for now is TCP or HTTP or something else
|
||||||
Type string `gorm:"size:255;not null" json:"type"`
|
Type string `gorm:"size:255;not null" json:"type"`
|
||||||
TypeConfig *ServiceTypeCheckConfig `gorm:"serializer:json" json:"type_config"`
|
Config *ServiceTypeCheckConfig `gorm:"serializer:json;column:type_config" json:"typeConfig"`
|
||||||
|
|
||||||
Statuses []Status `gorm:"foreignkey:ServiceID" json:"statuses"`
|
Statuses []Status `gorm:"foreignkey:ServiceID" json:"statuses"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,17 +9,19 @@ import (
|
|||||||
type StatusCode string
|
type StatusCode string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
StatusOK StatusCode = "ok" // Means - response ok, service is alive
|
StatusOK StatusCode = "ok" // Means - response ok, service is alive
|
||||||
StatusFailed StatusCode = "failed" // Means - response failed, all tries failed, service down
|
StatusFailed StatusCode = "failed" // Means - response failed, all tries failed, service down
|
||||||
StatusWarn StatusCode = "warn" // Means - response failed after N tries and still watched
|
StatusWarn StatusCode = "warn" // Means - response failed after N tries and still watched
|
||||||
|
StatusUncheck StatusCode = "uncheck"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Status struct {
|
type Status struct {
|
||||||
ID int `gorm:"primary_key;auto_increment" json:"-"`
|
ID uint64 `gorm:"primary_key;auto_increment" json:"-"`
|
||||||
ServiceID int `gorm:"one" json:"-"`
|
ServiceID uint64 `json:"-"`
|
||||||
Status StatusCode `gorm:"size:255;not null" json:"status"`
|
Status StatusCode `gorm:"size:255;not null" json:"status"`
|
||||||
Description *string `gorm:"size:255" json:"description"`
|
Description *string `gorm:"size:255" json:"description"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
ResponseTime uint64 `json:"responseTime"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Status) TableName() string {
|
func (Status) TableName() string {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func Connect() (*gorm.DB, error) {
|
|||||||
os.Getenv("DATABASE_PASS"),
|
os.Getenv("DATABASE_PASS"),
|
||||||
os.Getenv("DATABASE_DB"),
|
os.Getenv("DATABASE_DB"),
|
||||||
os.Getenv("DATABASE_PORT"),
|
os.Getenv("DATABASE_PORT"),
|
||||||
os.Getenv("DATABASE_TZ"),
|
os.Getenv("APP_TZ"),
|
||||||
)
|
)
|
||||||
|
|
||||||
newLogger := logger.New(
|
newLogger := logger.New(
|
||||||
|
|||||||
@@ -1,19 +1,23 @@
|
|||||||
package log
|
package log
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SERVER = "server"
|
SERVER = "server"
|
||||||
SYSTEM = "system"
|
SYSTEM = "system"
|
||||||
DATABASE = "database"
|
DATABASE = "database"
|
||||||
CRON = "cron"
|
CRON = "cron"
|
||||||
QUEUE = "queue"
|
QUEUE = "queue"
|
||||||
RABBIT = "rabbit"
|
Observer = "observer"
|
||||||
internal = "internal"
|
Scheduler = "scheduler"
|
||||||
|
RABBIT = "rabbit"
|
||||||
|
internal = "internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Global *LoggerManager
|
var Global *LoggerManager
|
||||||
@@ -42,8 +46,14 @@ func (m *LoggerManager) Put(name string, logger *logrus.Logger) {
|
|||||||
m.mu.Lock()
|
m.mu.Lock()
|
||||||
defer m.mu.Unlock()
|
defer m.mu.Unlock()
|
||||||
|
|
||||||
|
l, err := logrus.ParseLevel(strings.ToLower(os.Getenv("LOG_LEVEL")))
|
||||||
|
if err != nil {
|
||||||
|
l = logrus.ErrorLevel
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Level = l
|
||||||
if _, ok := m.loggers[name]; ok {
|
if _, ok := m.loggers[name]; ok {
|
||||||
m.loggers[internal].Errorf("Logger with name '%s' already exists. Use PutForce to replace it.", name)
|
m.loggers[internal].Warnf("Logger with name '%s' already exists. Use PutForce to replace it.", name)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
package dto
|
|
||||||
|
|
||||||
type PingMessage struct {
|
|
||||||
ServiceID int `json:"serviceID"`
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
package dto
|
|
||||||
|
|
||||||
type TaskMessage struct {
|
|
||||||
Task string `json:"task"`
|
|
||||||
Payload string `json:"payload"`
|
|
||||||
}
|
|
||||||
@@ -1,187 +0,0 @@
|
|||||||
package queue
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"git.ostiwe.com/ostiwe-com/status/modules/log"
|
|
||||||
"git.ostiwe.com/ostiwe-com/status/modules/queue/dto"
|
|
||||||
"git.ostiwe.com/ostiwe-com/status/modules/queue/tasks"
|
|
||||||
rabbitModule "git.ostiwe.com/ostiwe-com/status/modules/rabbit"
|
|
||||||
"git.ostiwe.com/ostiwe-com/status/repository"
|
|
||||||
amqp "github.com/rabbitmq/amqp091-go"
|
|
||||||
)
|
|
||||||
|
|
||||||
func InitQueues() {
|
|
||||||
rabbitModule.InitConnection()
|
|
||||||
|
|
||||||
err := flushQueues()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err = createTasksForServices(); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Global.Get(log.SYSTEM).Info("Wait 5 seconds before start listen task queue")
|
|
||||||
time.Sleep(time.Second * 5)
|
|
||||||
|
|
||||||
if err = listenTaskQueue(); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func createTasksForServices() error {
|
|
||||||
log.Global.Get(log.SYSTEM).Info("Create tasks ping for services")
|
|
||||||
|
|
||||||
serviceRepository := repository.NewServiceRepository()
|
|
||||||
|
|
||||||
services, err := serviceRepository.All(context.Background(), -1, 0, false)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := range services {
|
|
||||||
pingPayload, marshallErr := json.Marshal(dto.PingMessage{ServiceID: services[i].ID})
|
|
||||||
if marshallErr != nil {
|
|
||||||
return marshallErr
|
|
||||||
}
|
|
||||||
|
|
||||||
payload := dto.TaskMessage{
|
|
||||||
Task: "ping",
|
|
||||||
Payload: string(pingPayload),
|
|
||||||
}
|
|
||||||
|
|
||||||
payloadMsg, marshallErr := json.Marshal(payload)
|
|
||||||
if marshallErr != nil {
|
|
||||||
return marshallErr
|
|
||||||
}
|
|
||||||
|
|
||||||
publishErr := rabbitModule.Channel.Publish(
|
|
||||||
"",
|
|
||||||
"tasks",
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
amqp.Publishing{Body: payloadMsg},
|
|
||||||
)
|
|
||||||
if publishErr != nil {
|
|
||||||
return publishErr
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func flushQueues() error {
|
|
||||||
log.Global.Get(log.SYSTEM).Info("Flush queues")
|
|
||||||
|
|
||||||
_, err := rabbitModule.Channel.QueuePurge("tasks", false)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func listenTaskQueue() error {
|
|
||||||
ctx := context.Background()
|
|
||||||
|
|
||||||
consume, err := rabbitModule.Channel.Consume(
|
|
||||||
"tasks",
|
|
||||||
"tasks-consumer",
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
nil,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
taskCollection := tasks.CollectionMap()
|
|
||||||
|
|
||||||
for delivery := range consume {
|
|
||||||
go handleQueueMessage(ctx, delivery, taskCollection)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func handleQueueMessage(ctx context.Context, delivery amqp.Delivery, taskCollection map[string]tasks.Task) {
|
|
||||||
queueLog := log.Global.Get(log.QUEUE)
|
|
||||||
|
|
||||||
var taskMsg dto.TaskMessage
|
|
||||||
unmarshalErr := json.Unmarshal(delivery.Body, &taskMsg)
|
|
||||||
if unmarshalErr != nil {
|
|
||||||
queueLog.WithField("body", string(delivery.Body)).Error("Failed unmarshal queue message - ", unmarshalErr)
|
|
||||||
|
|
||||||
rejectErr := delivery.Reject(false)
|
|
||||||
if rejectErr != nil {
|
|
||||||
queueLog.Error("Failed reject message - ", rejectErr)
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
task, ok := taskCollection[taskMsg.Task]
|
|
||||||
|
|
||||||
if !ok {
|
|
||||||
queueLog.Error("Undefined task with name - ", taskMsg.Task)
|
|
||||||
rejectErr := delivery.Reject(false)
|
|
||||||
if rejectErr != nil {
|
|
||||||
queueLog.Error("Failed reject message - ", rejectErr)
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
payload := []byte(taskMsg.Payload)
|
|
||||||
|
|
||||||
handleErr := task.Handle(ctx, payload)
|
|
||||||
if handleErr != nil {
|
|
||||||
queueLog.Error("Task handler return error - ", handleErr)
|
|
||||||
|
|
||||||
fallback, fallbackErr := task.Fallback(ctx, handleErr)
|
|
||||||
if fallbackErr != nil {
|
|
||||||
queueLog.Error("Task failed with error - ", handleErr, "; Task fallback handler also return error - ", fallbackErr, "; Reject message.")
|
|
||||||
|
|
||||||
rejectErr := delivery.Reject(false)
|
|
||||||
if rejectErr != nil {
|
|
||||||
queueLog.Error("Failed reject message - ", rejectErr)
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !fallback {
|
|
||||||
queueLog.Error("Task fallback unsuccessful, reject message")
|
|
||||||
|
|
||||||
rejectErr := delivery.Reject(false)
|
|
||||||
if rejectErr != nil {
|
|
||||||
queueLog.Error("Failed reject message - ", rejectErr)
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
ackErr := delivery.Ack(false)
|
|
||||||
if ackErr != nil {
|
|
||||||
queueLog.Error("Failed acknowledge message - ", ackErr)
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
ackErr := delivery.Ack(false)
|
|
||||||
if ackErr != nil {
|
|
||||||
queueLog.Error("Failed acknowledge message - ", ackErr)
|
|
||||||
}
|
|
||||||
|
|
||||||
afterHandleErr := task.AfterHandle(ctx, payload)
|
|
||||||
if afterHandleErr != nil {
|
|
||||||
queueLog.Error("Task after handler hook failed with error - ", afterHandleErr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package tasks
|
|
||||||
|
|
||||||
func Collection() []Task {
|
|
||||||
return []Task{
|
|
||||||
PingTask,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func CollectionMap() map[string]Task {
|
|
||||||
collectionMap := make(map[string]Task)
|
|
||||||
|
|
||||||
for _, task := range Collection() {
|
|
||||||
if task.Fallback == nil {
|
|
||||||
task.Fallback = DefaultFallbackFn
|
|
||||||
}
|
|
||||||
if task.AfterHandle == nil {
|
|
||||||
task.AfterHandle = DefaultAfterHandleFn
|
|
||||||
}
|
|
||||||
|
|
||||||
collectionMap[task.Name] = task
|
|
||||||
}
|
|
||||||
|
|
||||||
return collectionMap
|
|
||||||
}
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
package tasks
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"git.ostiwe.com/ostiwe-com/status/model"
|
|
||||||
"git.ostiwe.com/ostiwe-com/status/modules/log"
|
|
||||||
"git.ostiwe.com/ostiwe-com/status/modules/queue/dto"
|
|
||||||
rabbitModule "git.ostiwe.com/ostiwe-com/status/modules/rabbit"
|
|
||||||
"git.ostiwe.com/ostiwe-com/status/repository"
|
|
||||||
"git.ostiwe.com/ostiwe-com/status/service"
|
|
||||||
amqp "github.com/rabbitmq/amqp091-go"
|
|
||||||
)
|
|
||||||
|
|
||||||
var PingTask = Task{
|
|
||||||
Name: "ping",
|
|
||||||
Handle: func(ctx context.Context, msgBody []byte) error {
|
|
||||||
logger := log.Global.Get(log.QUEUE)
|
|
||||||
var msg dto.PingMessage
|
|
||||||
|
|
||||||
err := json.Unmarshal(msgBody, &msg)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.Info("Received new ping task for service - ", msg.ServiceID)
|
|
||||||
serviceRepository := repository.NewServiceRepository()
|
|
||||||
|
|
||||||
srv, err := serviceRepository.Find(ctx, msg.ServiceID)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
var lastStatus = &model.Status{Status: model.StatusWarn}
|
|
||||||
if len(srv.Statuses) > 0 {
|
|
||||||
lastStatus = &srv.Statuses[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
checker := service.NewCheck()
|
|
||||||
|
|
||||||
err = checker.Observe(ctx, srv)
|
|
||||||
if err != nil {
|
|
||||||
newStatus := model.StatusWarn
|
|
||||||
|
|
||||||
if lastStatus.Status == model.StatusWarn && srv.CountLastStatuses(model.StatusWarn) >= 10 {
|
|
||||||
newStatus = model.StatusFailed
|
|
||||||
}
|
|
||||||
|
|
||||||
if lastStatus.Status == model.StatusFailed {
|
|
||||||
newStatus = model.StatusFailed
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.Info("Observe service with id ", msg.ServiceID, " failed - ", err, " setting [", newStatus, "] status")
|
|
||||||
|
|
||||||
regErr := checker.RegisterStatus(ctx, msg.ServiceID, newStatus)
|
|
||||||
if regErr != nil {
|
|
||||||
logger.Info("Setting status for service with id ", msg.ServiceID, " failed - ", err)
|
|
||||||
|
|
||||||
return regErr
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return checker.RegisterStatus(ctx, msg.ServiceID, model.StatusOK)
|
|
||||||
},
|
|
||||||
AfterHandle: func(ctx context.Context, msgBody []byte) error {
|
|
||||||
time.Sleep(time.Second * 30)
|
|
||||||
|
|
||||||
payload := dto.TaskMessage{
|
|
||||||
Task: "ping",
|
|
||||||
Payload: string(msgBody),
|
|
||||||
}
|
|
||||||
|
|
||||||
payloadMsg, err := json.Marshal(payload)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return rabbitModule.Channel.Publish(
|
|
||||||
"",
|
|
||||||
"tasks",
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
amqp.Publishing{
|
|
||||||
Body: payloadMsg,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package tasks
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"git.ostiwe.com/ostiwe-com/status/modules/log"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
DefaultFallbackFn = func(_ context.Context, _ error) (bool, error) {
|
|
||||||
log.Global.Get(log.QUEUE).Info("Default fallback function triggered")
|
|
||||||
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
DefaultAfterHandleFn = func(_ context.Context, _ []byte) error {
|
|
||||||
log.Global.Get(log.QUEUE).Info("Default after handler function triggered")
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
// Task represents a task that can be executed in the queue.
|
|
||||||
//
|
|
||||||
// Name returns the name of the task, used for logging and identification purposes.
|
|
||||||
//
|
|
||||||
// Handle processes a message from the queue. It takes a context and the raw message body ([]byte) as arguments.
|
|
||||||
// If handling fails, it should return an error that can be caught in the Fallback method.
|
|
||||||
//
|
|
||||||
// AfterHandle performs some action after successfully processing the message with Handle.
|
|
||||||
// It takes the same arguments as Handle: a context and the raw message body ([]byte).
|
|
||||||
// Default is DefaultAfterHandleFn
|
|
||||||
//
|
|
||||||
// Fallback handles errors that occur during the execution of the Handle method.
|
|
||||||
// It takes a context and an error as arguments. The method should return a boolean indicating whether the error was handled,
|
|
||||||
// and error for additional logging or debugging information.
|
|
||||||
// Default is DefaultFallbackFn
|
|
||||||
type Task struct {
|
|
||||||
Name string
|
|
||||||
Handle func(ctx context.Context, msgBody []byte) error
|
|
||||||
AfterHandle func(ctx context.Context, msgBody []byte) error
|
|
||||||
Fallback func(ctx context.Context, err error) (bool, error)
|
|
||||||
}
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
package rabbit
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"git.ostiwe.com/ostiwe-com/status/modules/log"
|
|
||||||
"git.ostiwe.com/ostiwe-com/status/pkg/rabbit"
|
|
||||||
amqp "github.com/rabbitmq/amqp091-go"
|
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
|
||||||
|
|
||||||
var Channel *amqp.Channel
|
|
||||||
|
|
||||||
func InitConnection() {
|
|
||||||
log.Global.Put(log.RABBIT, logrus.New())
|
|
||||||
log.Global.Put(log.QUEUE, logrus.New())
|
|
||||||
|
|
||||||
rConn, err := rabbit.NewConnection(rabbit.ConnectionArgs{
|
|
||||||
Host: os.Getenv("RABBIT_HOST"),
|
|
||||||
Password: os.Getenv("RABBIT_PASSWORD"),
|
|
||||||
User: os.Getenv("RABBIT_USER"),
|
|
||||||
Port: os.Getenv("RABBIT_PORT"),
|
|
||||||
ReconnectInterval: time.Second * 5,
|
|
||||||
Logger: log.Global.Get(log.RABBIT),
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
rConn.IsAlive()
|
|
||||||
|
|
||||||
if err = declareQueues(rConn); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
channel, err := rConn.Channel()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
Channel = channel
|
|
||||||
}
|
|
||||||
|
|
||||||
func declareQueues(conn *rabbit.Connection) error {
|
|
||||||
channel, err := conn.Channel()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = channel.QueueDeclare(
|
|
||||||
"tasks",
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
nil,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
66
modules/scheduler/scheduler.go
Normal file
66
modules/scheduler/scheduler.go
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
package scheduler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"git.ostiwe.com/ostiwe-com/status/modules/log"
|
||||||
|
"github.com/go-co-op/gocron/v2"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
var GlobalAppScheduler AppScheduler
|
||||||
|
|
||||||
|
type AppScheduler interface {
|
||||||
|
NewServiceJob(serviceID uint64, jd gocron.JobDefinition, t gocron.Task, opt ...gocron.JobOption) (gocron.Job, error)
|
||||||
|
StartJobs() error
|
||||||
|
}
|
||||||
|
|
||||||
|
type appScheduler struct {
|
||||||
|
jobServiceMap map[uint64]uuid.UUID
|
||||||
|
scheduler gocron.Scheduler
|
||||||
|
logger *logrus.Logger
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewAppScheduler() (AppScheduler, error) {
|
||||||
|
log.Global.Put(log.Scheduler, logrus.New())
|
||||||
|
|
||||||
|
location, err := time.LoadLocation(os.Getenv("APP_TZ"))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
scheduler, err := gocron.NewScheduler(gocron.WithLocation(location))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &appScheduler{
|
||||||
|
scheduler: scheduler,
|
||||||
|
logger: log.Global.Get(log.Scheduler),
|
||||||
|
jobServiceMap: make(map[uint64]uuid.UUID),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *appScheduler) NewServiceJob(serviceID uint64, jd gocron.JobDefinition, t gocron.Task, opt ...gocron.JobOption) (gocron.Job, error) {
|
||||||
|
job, err := s.scheduler.NewJob(jd, t, opt...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
s.jobServiceMap[serviceID] = job.ID()
|
||||||
|
|
||||||
|
return job, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *appScheduler) StartJobs() error {
|
||||||
|
if s.scheduler == nil {
|
||||||
|
return errors.New("scheduler is nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
s.scheduler.Start()
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
12
package.json
Normal file
12
package.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"dependencies": {
|
||||||
|
"@semantic-release/changelog": "^6.0.3",
|
||||||
|
"@semantic-release/exec": "^7.1.0",
|
||||||
|
"@semantic-release/git": "^10.0.1",
|
||||||
|
"semantic-release": "25"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@semantic-release/release-notes-generator": "^14.1.0",
|
||||||
|
"conventional-changelog-conventionalcommits": "^9.1.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -87,6 +87,7 @@ func (c *Connection) listenCloseNotify() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.conn = dial
|
c.conn = dial
|
||||||
|
c.closeNotify = dial.NotifyClose(make(chan *amqp.Error))
|
||||||
|
|
||||||
c.logger.Info("Rabbit connection stabilized")
|
c.logger.Info("Rabbit connection stabilized")
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
package slice
|
|
||||||
|
|
||||||
func ChunkSlice[T any](slice []T, chunkSize int) [][]T {
|
|
||||||
|
|
||||||
}
|
|
||||||
59
release.config.cjs
Normal file
59
release.config.cjs
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
/**
|
||||||
|
* @type {import('semantic-release').GlobalConfig}
|
||||||
|
*/
|
||||||
|
module.exports = {
|
||||||
|
branches: ['main'],
|
||||||
|
plugins: [
|
||||||
|
[
|
||||||
|
'@semantic-release/commit-analyzer',
|
||||||
|
{
|
||||||
|
"preset": "conventionalcommits",
|
||||||
|
"releaseRules": [
|
||||||
|
{"type": "docs", "scope": "README", "release": "patch"},
|
||||||
|
{"type": "feat", scope: "ci", release: "patch"},
|
||||||
|
{"type": "feature", scope: "ci", release: "patch"},
|
||||||
|
{"type": "refactor", "release": "patch"},
|
||||||
|
{"type": "style", "release": "patch"}
|
||||||
|
],
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'@semantic-release/release-notes-generator',
|
||||||
|
{
|
||||||
|
"preset": "conventionalcommits",
|
||||||
|
"presetConfig": {
|
||||||
|
types: [
|
||||||
|
{"type": "breaking", "section": "Major version release", "hidden": false},
|
||||||
|
{"type": "BREAKING", "section": "Major version release", "hidden": false},
|
||||||
|
{"type": "BREAKING CHANGE", "section": "Major version release", "hidden": false},
|
||||||
|
{"type": "BREAKING CHANGES", "section": "Major version release", "hidden": false},
|
||||||
|
{"type": "feat", "section": "Features", "hidden": false},
|
||||||
|
{"type": "fix", "section": "Bug Fixes", "hidden": false},
|
||||||
|
{"type": "hotfix", "section": "Bug Fixes", "hidden": false},
|
||||||
|
{"type": "update", "section": "Updates", "hidden": false},
|
||||||
|
{"type": "upgrade", "section": "Upgrades", "hidden": false},
|
||||||
|
{"type": "docs", "section": "Documentation", "hidden": false},
|
||||||
|
{"type": "build", "section": "CI/CD Changes", "hidden": false},
|
||||||
|
{"type": "ci", "section": "CI/CD Changes", "hidden": false},
|
||||||
|
{"type": "refactor", "section": "Refactoring", "hidden": false},
|
||||||
|
{"type": "perf", "section": "Performance Improvements", "hidden": false}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"@semantic-release/exec",
|
||||||
|
{
|
||||||
|
publishCmd: 'echo "${nextRelease.notes}\n\n$(cat CHANGELOG.md)" > CHANGELOG.md; echo "${nextRelease.notes}" > "/tmp/${process.env.TMP_FILE_NAME}";',
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'@semantic-release/git',
|
||||||
|
{
|
||||||
|
assets: [
|
||||||
|
'CHANGELOG.md'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
],
|
||||||
|
};
|
||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
|
|
||||||
type Status interface {
|
type Status interface {
|
||||||
Add(ctx context.Context, status model.Status) error
|
Add(ctx context.Context, status model.Status) error
|
||||||
|
LastNStatuses(ctx context.Context, serviceID uint64, n uint) ([]model.Status, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type status struct {
|
type status struct {
|
||||||
@@ -24,3 +25,14 @@ func NewStatusRepository() Status {
|
|||||||
func (s status) Add(ctx context.Context, status model.Status) error {
|
func (s status) Add(ctx context.Context, status model.Status) error {
|
||||||
return s.db.WithContext(ctx).Create(&status).Error
|
return s.db.WithContext(ctx).Create(&status).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s status) LastNStatuses(ctx context.Context, serviceID uint64, n uint) ([]model.Status, error) {
|
||||||
|
var items = make([]model.Status, 0, n)
|
||||||
|
|
||||||
|
return items, s.db.
|
||||||
|
WithContext(ctx).
|
||||||
|
Limit(int(n)).
|
||||||
|
Order("created_at DESC").
|
||||||
|
Find(&items, "service_id = ?", serviceID).
|
||||||
|
Error
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"git.ostiwe.com/ostiwe-com/status/modules/db"
|
"git.ostiwe.com/ostiwe-com/status/modules/db"
|
||||||
appLog "git.ostiwe.com/ostiwe-com/status/modules/log"
|
appLog "git.ostiwe.com/ostiwe-com/status/modules/log"
|
||||||
"git.ostiwe.com/ostiwe-com/status/modules/queue"
|
"git.ostiwe.com/ostiwe-com/status/modules/scheduler"
|
||||||
"git.ostiwe.com/ostiwe-com/status/pkg/args"
|
"git.ostiwe.com/ostiwe-com/status/pkg/args"
|
||||||
"git.ostiwe.com/ostiwe-com/status/router"
|
"git.ostiwe.com/ostiwe-com/status/router"
|
||||||
|
"git.ostiwe.com/ostiwe-com/status/service"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -21,8 +23,24 @@ func Run(serverArgs *args.ServerCmd) {
|
|||||||
|
|
||||||
db.SetGlobal(connect)
|
db.SetGlobal(connect)
|
||||||
|
|
||||||
|
scheduler.GlobalAppScheduler, err = scheduler.NewAppScheduler()
|
||||||
|
if err != nil {
|
||||||
|
appLog.Global.Get(appLog.SYSTEM).Error(fmt.Sprintf("Startup server error, failed create scheduler: %v", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
appLog.Global.Get(appLog.SYSTEM).Info("Start service observer")
|
appLog.Global.Get(appLog.SYSTEM).Info("Start service observer")
|
||||||
go queue.InitQueues()
|
service.GlobalCheckService = service.NewCheck(scheduler.GlobalAppScheduler)
|
||||||
|
|
||||||
|
if err = service.GlobalCheckService.RegisterTasks(context.Background()); err != nil {
|
||||||
|
appLog.Global.Get(appLog.SYSTEM).Error(fmt.Sprintf("Startup server error, failed create observe jobs: %v", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = scheduler.GlobalAppScheduler.StartJobs(); err != nil {
|
||||||
|
appLog.Global.Get(appLog.SYSTEM).Error(fmt.Sprintf("Startup server error, failed start jobs: %v", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
appLog.Global.Put(appLog.SERVER, logrus.New())
|
appLog.Global.Put(appLog.SERVER, logrus.New())
|
||||||
appLog.Global.Get(appLog.SERVER).Info("Startup server on port: ", serverArgs.Port)
|
appLog.Global.Get(appLog.SERVER).Info("Startup server on port: ", serverArgs.Port)
|
||||||
|
|||||||
125
service/check.go
125
service/check.go
@@ -3,67 +3,154 @@ package service
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.ostiwe.com/ostiwe-com/status/model"
|
"git.ostiwe.com/ostiwe-com/status/model"
|
||||||
"git.ostiwe.com/ostiwe-com/status/modules/log"
|
"git.ostiwe.com/ostiwe-com/status/modules/log"
|
||||||
|
"git.ostiwe.com/ostiwe-com/status/modules/scheduler"
|
||||||
"git.ostiwe.com/ostiwe-com/status/repository"
|
"git.ostiwe.com/ostiwe-com/status/repository"
|
||||||
|
"github.com/go-co-op/gocron/v2"
|
||||||
|
"github.com/samber/lo"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
httpObserveFailed = errors.New("http observe fail")
|
httpObserveFailed = errors.New("http observe fail")
|
||||||
httpObserveMaxTries = errors.New("http observe max tries")
|
httpObserveMaxTries = errors.New("http observe max tries")
|
||||||
|
|
||||||
|
GlobalCheckService Check
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
log.Global.Put(log.CRON, logrus.New())
|
log.Global.Put(log.CRON, logrus.New())
|
||||||
|
log.Global.Put(log.Observer, logrus.New())
|
||||||
}
|
}
|
||||||
|
|
||||||
type Check interface {
|
type Check interface {
|
||||||
Observe(ctx context.Context, srv *model.Service) error
|
Observe(ctx context.Context, srv *model.Service) error
|
||||||
RegisterStatus(ctx context.Context, serviceID int, status model.StatusCode) error
|
RegisterStatus(ctx context.Context, serviceID uint64, status model.StatusCode, meta ResponseMeta) error
|
||||||
|
RegisterTasks(ctx context.Context) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type check struct {
|
type check struct {
|
||||||
serviceRepository repository.Service
|
serviceRepository repository.Service
|
||||||
statusRepository repository.Status
|
statusRepository repository.Status
|
||||||
|
appScheduler scheduler.AppScheduler
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCheck() Check {
|
func NewCheck(appScheduler scheduler.AppScheduler) Check {
|
||||||
return &check{
|
return &check{
|
||||||
serviceRepository: repository.NewServiceRepository(),
|
serviceRepository: repository.NewServiceRepository(),
|
||||||
statusRepository: repository.NewStatusRepository(),
|
statusRepository: repository.NewStatusRepository(),
|
||||||
|
appScheduler: appScheduler,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c check) Observe(ctx context.Context, srv *model.Service) error {
|
func (c *check) RegisterTasks(ctx context.Context) error {
|
||||||
return c.observeHttp(srv)
|
services, err := c.serviceRepository.All(ctx, -1, 0, false)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, service := range services {
|
||||||
|
job, jobCreateErr := c.appScheduler.NewServiceJob(
|
||||||
|
service.ID,
|
||||||
|
gocron.DurationJob(time.Duration(service.Config.Interval)*time.Second),
|
||||||
|
gocron.NewTask(c.Observe, ctx, &service),
|
||||||
|
gocron.WithName(fmt.Sprintf("task-service-%d", service.ID)),
|
||||||
|
)
|
||||||
|
if jobCreateErr != nil {
|
||||||
|
return jobCreateErr
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Global.Get(log.CRON).Infof(
|
||||||
|
"Registered service observe task for service with id - %d; task id - UUID: %s; Job interval: %d(s)",
|
||||||
|
service.ID,
|
||||||
|
job.ID().String(),
|
||||||
|
service.Config.Interval,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c check) RegisterStatus(ctx context.Context, serviceID int, status model.StatusCode) error {
|
func (c *check) Observe(ctx context.Context, srv *model.Service) error {
|
||||||
|
// If the observation of an HTTP service failed, check the last N statuses.
|
||||||
|
// If the first one has a failure status, set it as failed.
|
||||||
|
// If all statuses in the last N are warning, set it as failed.
|
||||||
|
// Otherwise, set the status as warning.
|
||||||
|
if srv.Type == "http" {
|
||||||
|
meta, err := c.ObserveHttp(ctx, srv)
|
||||||
|
if err == nil {
|
||||||
|
return c.RegisterStatus(ctx, srv.ID, model.StatusOK, *meta)
|
||||||
|
}
|
||||||
|
|
||||||
|
lastNStatuses, err := c.statusRepository.LastNStatuses(ctx, srv.ID, uint(srv.Config.MaxFails))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(lastNStatuses) > 0 && lastNStatuses[0].Status == model.StatusFailed {
|
||||||
|
return c.RegisterStatus(ctx, srv.ID, model.StatusFailed, *meta)
|
||||||
|
}
|
||||||
|
|
||||||
|
everyWarn := lo.EveryBy(lastNStatuses, func(item model.Status) bool {
|
||||||
|
return item.Status == model.StatusWarn
|
||||||
|
})
|
||||||
|
|
||||||
|
if everyWarn {
|
||||||
|
return c.RegisterStatus(ctx, srv.ID, model.StatusFailed, *meta)
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.RegisterStatus(ctx, srv.ID, model.StatusWarn, *meta)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Todo: return err
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *check) RegisterStatus(ctx context.Context, serviceID uint64, status model.StatusCode, meta ResponseMeta) error {
|
||||||
return c.statusRepository.Add(ctx, model.Status{
|
return c.statusRepository.Add(ctx, model.Status{
|
||||||
ServiceID: serviceID,
|
ServiceID: serviceID,
|
||||||
Status: status,
|
Status: status,
|
||||||
CreatedAt: time.Now(),
|
ResponseTime: meta.ResponseTime,
|
||||||
|
CreatedAt: time.Now(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c check) observeHttp(service *model.Service) error {
|
type ResponseMeta struct {
|
||||||
if service.TypeConfig == nil || service.TypeConfig.HTTPConfig == nil {
|
ResponseTime uint64
|
||||||
return errors.New("service has no config for http")
|
}
|
||||||
|
|
||||||
|
func (c *check) ObserveHttp(ctx context.Context, service *model.Service) (*ResponseMeta, error) {
|
||||||
|
var meta = &ResponseMeta{
|
||||||
|
ResponseTime: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
conf := service.TypeConfig.HTTPConfig
|
var startTime = time.Now()
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
meta.ResponseTime = uint64(time.Since(startTime).Milliseconds())
|
||||||
|
}()
|
||||||
|
|
||||||
|
if service.Config == nil || service.Config.HTTPConfig == nil {
|
||||||
|
return meta, errors.New("service has no config for http")
|
||||||
|
}
|
||||||
|
|
||||||
|
logger := log.Global.Get(log.Observer)
|
||||||
|
logger.Debugf("Start observe service - %d", service.ID)
|
||||||
|
|
||||||
|
conf := service.Config.HTTPConfig
|
||||||
|
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
Timeout: time.Second * 5,
|
Timeout: time.Duration(service.Config.Timeout) * time.Second,
|
||||||
}
|
}
|
||||||
|
|
||||||
request, err := http.NewRequest(conf.Method, service.Host, nil)
|
request, err := http.NewRequestWithContext(ctx, conf.Method, service.Host, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return meta, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for s := range conf.Headers {
|
for s := range conf.Headers {
|
||||||
@@ -71,13 +158,13 @@ func (c check) observeHttp(service *model.Service) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
response, err := client.Do(request)
|
response, err := client.Do(request)
|
||||||
if err != nil && !errors.Is(err, context.DeadlineExceeded) {
|
if err != nil {
|
||||||
return err
|
return meta, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if response.StatusCode != http.StatusOK {
|
if response.StatusCode != http.StatusOK {
|
||||||
return httpObserveFailed
|
return meta, httpObserveFailed
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return meta, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,67 @@
|
|||||||
package transform
|
package transform
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"slices"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"git.ostiwe.com/ostiwe-com/status/dto"
|
"git.ostiwe.com/ostiwe-com/status/dto"
|
||||||
"git.ostiwe.com/ostiwe-com/status/model"
|
"git.ostiwe.com/ostiwe-com/status/model"
|
||||||
|
"github.com/samber/lo"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const maxStatuses = 60
|
||||||
|
|
||||||
func PublicServices(items ...model.Service) []dto.PublicService {
|
func PublicServices(items ...model.Service) []dto.PublicService {
|
||||||
result := make([]dto.PublicService, 0, len(items))
|
result := make([]dto.PublicService, 0, len(items))
|
||||||
|
mu := new(sync.Mutex)
|
||||||
|
|
||||||
|
chunked := slices.Chunk(items, 40)
|
||||||
|
|
||||||
|
for services := range chunked {
|
||||||
|
wg := new(sync.WaitGroup)
|
||||||
|
wg.Add(len(services))
|
||||||
|
|
||||||
|
for i := range services {
|
||||||
|
go func(_wg *sync.WaitGroup, item model.Service) {
|
||||||
|
defer _wg.Done()
|
||||||
|
|
||||||
|
transformed := PublicService(item)
|
||||||
|
mu.Lock()
|
||||||
|
result = append(result, transformed)
|
||||||
|
mu.Unlock()
|
||||||
|
}(wg, services[i])
|
||||||
|
}
|
||||||
|
|
||||||
|
wg.Wait()
|
||||||
|
|
||||||
for _, item := range items {
|
|
||||||
result = append(result, PublicService(item))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func PublicService(item model.Service) dto.PublicService {
|
func PublicService(item model.Service) dto.PublicService {
|
||||||
|
statuses := make([]model.Status, maxStatuses)
|
||||||
|
itemStatusLen := len(item.Statuses)
|
||||||
|
|
||||||
|
for i := range statuses {
|
||||||
|
if i > itemStatusLen-1 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
statuses[i] = item.Statuses[i]
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := range statuses {
|
||||||
|
if statuses[i].Status == "" {
|
||||||
|
statuses[i].Status = model.StatusUncheck
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
slices.Reverse(statuses)
|
||||||
return dto.PublicService{
|
return dto.PublicService{
|
||||||
|
ID: int(item.ID),
|
||||||
Name: item.Name,
|
Name: item.Name,
|
||||||
Description: item.PublicDescription,
|
Description: lo.ToPtr(item.PublicDescription),
|
||||||
Statuses: item.Statuses,
|
Statuses: statuses,
|
||||||
Uptime: item.CalculateUptimePercent(),
|
Uptime: item.CalculateUptimePercent(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user