Compare commits
9 Commits
change_mod
...
7e9653606e
| Author | SHA1 | Date | |
|---|---|---|---|
|
7e9653606e
|
|||
|
e7592e8737
|
|||
|
334c0c1480
|
|||
|
abc87abe88
|
|||
|
1367783e8a
|
|||
|
|
51e48dd842 | ||
|
3a3580b6ed
|
|||
|
f5d780fb1b
|
|||
|
a4050c28dc
|
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'
|
||||
9
.github/workflows/release.yml
vendored
9
.github/workflows/release.yml
vendored
@@ -3,14 +3,13 @@ name: Release
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
- master
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
goreleaser:
|
||||
release:
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -21,10 +20,8 @@ jobs:
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '^1.25'
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 22.18
|
||||
- name: Install go release
|
||||
run: go install github.com/goreleaser/goreleaser/v2@latest
|
||||
- name: Release
|
||||
run: |
|
||||
yarn install
|
||||
|
||||
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
|
||||
13
CHANGELOG.md
Normal file
13
CHANGELOG.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# [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"
|
||||
|
||||
type PublicService struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Description *string `json:"description"`
|
||||
Statuses []model.Status `json:"statuses"`
|
||||
Uptime float64 `json:"uptime"`
|
||||
}
|
||||
|
||||
@@ -9,9 +9,10 @@ import (
|
||||
type StatusCode string
|
||||
|
||||
const (
|
||||
StatusOK StatusCode = "ok" // Means - response ok, service is alive
|
||||
StatusFailed StatusCode = "failed" // Means - response failed, all tries failed, service down
|
||||
StatusWarn StatusCode = "warn" // Means - response failed after N tries and still watched
|
||||
StatusOK StatusCode = "ok" // Means - response ok, service is alive
|
||||
StatusFailed StatusCode = "failed" // Means - response failed, all tries failed, service down
|
||||
StatusWarn StatusCode = "warn" // Means - response failed after N tries and still watched
|
||||
StatusUncheck StatusCode = "uncheck"
|
||||
)
|
||||
|
||||
type Status struct {
|
||||
|
||||
@@ -87,6 +87,7 @@ func (c *Connection) listenCloseNotify() {
|
||||
}
|
||||
|
||||
c.conn = dial
|
||||
c.closeNotify = dial.NotifyClose(make(chan *amqp.Error))
|
||||
|
||||
c.logger.Info("Rabbit connection stabilized")
|
||||
|
||||
|
||||
@@ -2,14 +2,16 @@
|
||||
* @type {import('semantic-release').GlobalConfig}
|
||||
*/
|
||||
module.exports = {
|
||||
branches: ['master', { name: 'dev', prerelease: false, channel: 'dev'}],
|
||||
branches: ['main'],
|
||||
plugins: [
|
||||
[
|
||||
'@semantic-release/commit-analyzer',
|
||||
{
|
||||
"preset": "angular",
|
||||
"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"}
|
||||
],
|
||||
@@ -18,11 +20,39 @@ module.exports = {
|
||||
[
|
||||
'@semantic-release/release-notes-generator',
|
||||
{
|
||||
"preset": "angular",
|
||||
"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 -e "${nextRelease.notes}\n\n$(cat CHANGELOG.md)" > CHANGELOG.md'
|
||||
}
|
||||
],
|
||||
[
|
||||
'@semantic-release/git',
|
||||
{
|
||||
"assets": ["CHANGELOG.md"]
|
||||
}
|
||||
],
|
||||
'@semantic-release/changelog',
|
||||
'@semantic-release/git',
|
||||
[
|
||||
"@semantic-release/exec",
|
||||
{
|
||||
|
||||
@@ -1,25 +1,67 @@
|
||||
package transform
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"sync"
|
||||
|
||||
"git.ostiwe.com/ostiwe-com/status/dto"
|
||||
"git.ostiwe.com/ostiwe-com/status/model"
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
const maxStatuses = 60
|
||||
|
||||
func PublicServices(items ...model.Service) []dto.PublicService {
|
||||
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
|
||||
}
|
||||
|
||||
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{
|
||||
ID: int(item.ID),
|
||||
Name: item.Name,
|
||||
Description: item.PublicDescription,
|
||||
Statuses: item.Statuses,
|
||||
Description: lo.ToPtr(item.PublicDescription),
|
||||
Statuses: statuses,
|
||||
Uptime: item.CalculateUptimePercent(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user