Compare commits
38 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 574c7cfbf0 | |||
| 3cbef93607 | |||
| 675e993353 | |||
| e1398e7472 | |||
| b786ed6986 | |||
| 2f2a407409 | |||
| 6df51fc19f | |||
| 5682c86837 | |||
| 9428c1a227 | |||
| 6b84bbe5e1 | |||
| 47b96cd598 | |||
| 19c02063e9 | |||
| 84523661e2 | |||
| 6553b4711b | |||
| 9280668d28 | |||
| ccc2fd401f | |||
| f2e4530023 | |||
| 8f333354d2 | |||
| 41e7585637 | |||
| 36f695c146 | |||
| 404c64b910 | |||
| 2cd4d8a35a | |||
| bae726dba6 | |||
| f6b0f96a34 | |||
| 61245cc77c | |||
| adab600e26 | |||
| 9ef534eafa | |||
| 9c6ea595f1 | |||
| e824274998 | |||
| 69cc4b4e80 | |||
| 37d66b073e | |||
| 954d97f71d | |||
| 4d2ff44b18 | |||
| fa86be0310 | |||
| 86ad4a76b7 | |||
| f85f09ebcf | |||
| 1f5fae973f | |||
| 41c8fffcb0 |
@@ -21,7 +21,7 @@ steps:
|
|||||||
memory: 100MiB
|
memory: 100MiB
|
||||||
|
|
||||||
- name: test
|
- name: test
|
||||||
image: golang:1.21.3
|
image: golang:1.22.1
|
||||||
volumes:
|
volumes:
|
||||||
- name: go
|
- name: go
|
||||||
path: /go
|
path: /go
|
||||||
@@ -32,7 +32,7 @@ steps:
|
|||||||
- go build ./...
|
- go build ./...
|
||||||
|
|
||||||
- name: goreleaser
|
- name: goreleaser
|
||||||
image: golang:1.21.3
|
image: golang:1.22.1
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
cpu: 6000
|
cpu: 6000
|
||||||
@@ -81,6 +81,6 @@ volumes:
|
|||||||
|
|
||||||
---
|
---
|
||||||
kind: signature
|
kind: signature
|
||||||
hmac: ad52df0920ec958bfc10c9716eed78888605ff0f5eab718212ac4f42d597773c
|
hmac: dd3e23e16a418386ae49fd99e25bd5a9a87abf87515124d76d4a744b7ba44e04
|
||||||
|
|
||||||
...
|
...
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM alpine:3.18.0
|
FROM alpine:3.19.1
|
||||||
|
|
||||||
RUN apk --no-cache upgrade
|
RUN apk --no-cache upgrade
|
||||||
RUN apk --no-cache add ca-certificates tzdata zsh jq tmux curl
|
RUN apk --no-cache add ca-certificates tzdata zsh jq tmux curl
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ func (d *ClickHouse) ServerAnswerCounts(ctx context.Context, serverIP string, da
|
|||||||
ctx, span := tracing.Tracer().Start(ctx, "ServerAnswerCounts")
|
ctx, span := tracing.Tracer().Start(ctx, "ServerAnswerCounts")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
conn := d.conn
|
conn := d.Logs
|
||||||
|
|
||||||
log := logger.Setup().With("server", serverIP)
|
log := logger.Setup().With("server", serverIP)
|
||||||
|
|
||||||
@@ -95,11 +95,14 @@ func (d *ClickHouse) ServerAnswerCounts(ctx context.Context, serverIP string, da
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *ClickHouse) AnswerTotals(ctx context.Context, qtype string, days int) (ServerTotals, error) {
|
func (d *ClickHouse) AnswerTotals(ctx context.Context, qtype string, days int) (ServerTotals, error) {
|
||||||
|
|
||||||
log := logger.Setup()
|
log := logger.Setup()
|
||||||
|
ctx, span := tracing.Tracer().Start(ctx, "AnswerTotals")
|
||||||
|
defer span.End()
|
||||||
|
|
||||||
// queries by UserCC / Qtype for the ServerIP
|
// queries by UserCC / Qtype for the ServerIP
|
||||||
rows, err := d.conn.Query(ctx, `
|
rows, err := d.Logs.Query(clickhouse.Context(ctx,
|
||||||
|
clickhouse.WithSpan(span.SpanContext()),
|
||||||
|
), `
|
||||||
select UserCC,Qtype,sum(queries) as queries
|
select UserCC,Qtype,sum(queries) as queries
|
||||||
from by_server_ip_1d
|
from by_server_ip_1d
|
||||||
where
|
where
|
||||||
|
|||||||
70
chdb/db.go
70
chdb/db.go
@@ -2,34 +2,82 @@ package chdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"log/slog"
|
|
||||||
|
|
||||||
"github.com/ClickHouse/clickhouse-go/v2"
|
"github.com/ClickHouse/clickhouse-go/v2"
|
||||||
"github.com/ClickHouse/clickhouse-go/v2/lib/driver"
|
"gopkg.in/yaml.v3"
|
||||||
|
|
||||||
|
"go.ntppool.org/common/logger"
|
||||||
"go.ntppool.org/common/version"
|
"go.ntppool.org/common/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type Config struct {
|
||||||
|
ClickHouse struct {
|
||||||
|
Scores DBConfig `yaml:"scores"`
|
||||||
|
Logs DBConfig `yaml:"logs"`
|
||||||
|
} `yaml:"clickhouse"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DBConfig struct {
|
||||||
|
Host string
|
||||||
|
Database string
|
||||||
|
}
|
||||||
|
|
||||||
type ClickHouse struct {
|
type ClickHouse struct {
|
||||||
conn clickhouse.Conn
|
Logs clickhouse.Conn
|
||||||
|
Scores clickhouse.Conn
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(ctx context.Context, dbConfigPath string) (*ClickHouse, error) {
|
func New(ctx context.Context, dbConfigPath string) (*ClickHouse, error) {
|
||||||
conn, err := setupClickhouse(ctx)
|
ch, err := setupClickhouse(ctx, dbConfigPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &ClickHouse{conn: conn}, nil
|
return ch, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupClickhouse(ctx context.Context) (driver.Conn, error) {
|
func setupClickhouse(ctx context.Context, configFile string) (*ClickHouse, error) {
|
||||||
|
|
||||||
|
log := logger.FromContext(ctx)
|
||||||
|
|
||||||
|
log.InfoContext(ctx, "opening config", "file", configFile)
|
||||||
|
|
||||||
|
dbFile, err := os.Open(configFile)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
dec := yaml.NewDecoder(dbFile)
|
||||||
|
|
||||||
|
cfg := Config{}
|
||||||
|
|
||||||
|
err = dec.Decode(&cfg)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
ch := &ClickHouse{}
|
||||||
|
|
||||||
|
ch.Logs, err = open(ctx, cfg.ClickHouse.Logs)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
ch.Scores, err = open(ctx, cfg.ClickHouse.Scores)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return ch, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func open(ctx context.Context, cfg DBConfig) (clickhouse.Conn, error) {
|
||||||
|
log := logger.Setup()
|
||||||
|
|
||||||
conn, err := clickhouse.Open(&clickhouse.Options{
|
conn, err := clickhouse.Open(&clickhouse.Options{
|
||||||
Addr: []string{"10.43.207.123:9000"},
|
Addr: []string{cfg.Host + ":9000"},
|
||||||
Auth: clickhouse.Auth{
|
Auth: clickhouse.Auth{
|
||||||
Database: "geodns3",
|
Database: cfg.Database,
|
||||||
Username: "default",
|
Username: "default",
|
||||||
Password: "",
|
Password: "",
|
||||||
},
|
},
|
||||||
@@ -68,11 +116,11 @@ func setupClickhouse(ctx context.Context) (driver.Conn, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
slog.Info("clickhouse connection", "version", v)
|
log.Info("clickhouse connection", "version", v)
|
||||||
|
|
||||||
err = conn.Ping(ctx)
|
err = conn.Ping(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("clickhouse ping", "err", err)
|
log.Error("clickhouse ping", "err", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,11 @@ package chdb
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"log/slog"
|
|
||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ClickHouse/clickhouse-go/v2"
|
"github.com/ClickHouse/clickhouse-go/v2"
|
||||||
|
"go.ntppool.org/common/logger"
|
||||||
"go.ntppool.org/common/tracing"
|
"go.ntppool.org/common/tracing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -33,13 +32,14 @@ func (s UserCountry) Less(i, j int) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *ClickHouse) UserCountryData(ctx context.Context) (*UserCountry, error) {
|
func (d *ClickHouse) UserCountryData(ctx context.Context) (*UserCountry, error) {
|
||||||
|
log := logger.Setup()
|
||||||
ctx, span := tracing.Tracer().Start(ctx, "UserCountryData")
|
ctx, span := tracing.Tracer().Start(ctx, "UserCountryData")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
rows, err := d.conn.Query(clickhouse.Context(ctx, clickhouse.WithSpan(span.SpanContext())),
|
rows, err := d.Logs.Query(clickhouse.Context(ctx, clickhouse.WithSpan(span.SpanContext())),
|
||||||
"select max(dt) as d,UserCC,Qtype,sum(queries) as queries from by_usercc_1d where dt > now() - INTERVAL 4 DAY group by rollup(Qtype,UserCC) order by UserCC,Qtype;")
|
"select max(dt) as d,UserCC,Qtype,sum(queries) as queries from by_usercc_1d where dt > now() - INTERVAL 4 DAY group by rollup(Qtype,UserCC) order by UserCC,Qtype;")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("query error", "err", err)
|
log.ErrorContext(ctx, "query error", "err", err)
|
||||||
return nil, fmt.Errorf("database error")
|
return nil, fmt.Errorf("database error")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ func (d *ClickHouse) UserCountryData(ctx context.Context) (*UserCountry, error)
|
|||||||
&Qtype,
|
&Qtype,
|
||||||
&queries,
|
&queries,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
log.Fatal(err)
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// tdt, err := time.Parse(time.RFC3339, dt)
|
// tdt, err := time.Parse(time.RFC3339, dt)
|
||||||
@@ -108,7 +108,7 @@ func (d *ClickHouse) UserCountryData(ctx context.Context) (*UserCountry, error)
|
|||||||
c = ccs[dt].CC[UserCC]
|
c = ccs[dt].CC[UserCC]
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
slog.Info("row", "dt", dt, "usercc", UserCC, "qtype", Qtype, "queries", queries)
|
log.InfoContext(ctx, "row", "dt", dt, "usercc", UserCC, "qtype", Qtype, "queries", queries)
|
||||||
|
|
||||||
if dt.UTC().Equal(time.Unix(0, 0)) {
|
if dt.UTC().Equal(time.Unix(0, 0)) {
|
||||||
continue // we skip the overall total
|
continue // we skip the overall total
|
||||||
@@ -143,7 +143,7 @@ func (d *ClickHouse) UserCountryData(ctx context.Context) (*UserCountry, error)
|
|||||||
|
|
||||||
totalDay, ok := totals[d]
|
totalDay, ok := totals[d]
|
||||||
if !ok {
|
if !ok {
|
||||||
slog.Error("no total for day", "date", d)
|
log.ErrorContext(ctx, "no total for day", "date", d)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
total4 := float64(totalDay.Count4)
|
total4 := float64(totalDay.Count4)
|
||||||
|
|||||||
108
chdb/logscores.go
Normal file
108
chdb/logscores.go
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
package chdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/ClickHouse/clickhouse-go/v2"
|
||||||
|
"go.ntppool.org/common/logger"
|
||||||
|
"go.ntppool.org/common/tracing"
|
||||||
|
"go.ntppool.org/data-api/ntpdb"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (d *ClickHouse) Logscores(ctx context.Context, serverID, monitorID int, since time.Time, limit int, fullHistory bool) ([]ntpdb.LogScore, error) {
|
||||||
|
log := logger.Setup()
|
||||||
|
ctx, span := tracing.Tracer().Start(ctx, "CH Logscores")
|
||||||
|
defer span.End()
|
||||||
|
|
||||||
|
recentFirst := true
|
||||||
|
|
||||||
|
if since.IsZero() && !fullHistory {
|
||||||
|
log.WarnContext(ctx, "resetting since to 4 days ago")
|
||||||
|
since = time.Now().Add(4 * -24 * time.Hour)
|
||||||
|
} else {
|
||||||
|
recentFirst = false
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []interface{}{serverID}
|
||||||
|
query := `select id,monitor_id,server_id,ts,
|
||||||
|
toFloat64(score),toFloat64(step),offset,
|
||||||
|
rtt,leap,warning,error
|
||||||
|
from log_scores
|
||||||
|
where
|
||||||
|
server_id = ?`
|
||||||
|
|
||||||
|
if monitorID > 0 {
|
||||||
|
query = `select id,monitor_id,server_id,ts,
|
||||||
|
toFloat64(score),toFloat64(step),offset,
|
||||||
|
rtt,leap,warning,error
|
||||||
|
from log_scores
|
||||||
|
where
|
||||||
|
server_id = ?
|
||||||
|
and monitor_id = ?`
|
||||||
|
args = []interface{}{serverID, monitorID}
|
||||||
|
}
|
||||||
|
|
||||||
|
if fullHistory {
|
||||||
|
query += " order by ts"
|
||||||
|
if recentFirst {
|
||||||
|
query += " desc"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
query += " and ts > ? order by ts "
|
||||||
|
if recentFirst {
|
||||||
|
query += "desc "
|
||||||
|
}
|
||||||
|
query += "limit ?"
|
||||||
|
args = append(args, since, limit)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.DebugContext(ctx, "clickhouse query", "query", query, "args", args)
|
||||||
|
|
||||||
|
rows, err := d.Scores.Query(
|
||||||
|
clickhouse.Context(
|
||||||
|
ctx, clickhouse.WithSpan(span.SpanContext()),
|
||||||
|
),
|
||||||
|
query, args...,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorContext(ctx, "query error", "err", err)
|
||||||
|
return nil, fmt.Errorf("database error")
|
||||||
|
}
|
||||||
|
|
||||||
|
rv := []ntpdb.LogScore{}
|
||||||
|
|
||||||
|
for rows.Next() {
|
||||||
|
|
||||||
|
row := ntpdb.LogScore{}
|
||||||
|
|
||||||
|
var leap uint8
|
||||||
|
|
||||||
|
if err := rows.Scan(
|
||||||
|
&row.ID,
|
||||||
|
&row.MonitorID,
|
||||||
|
&row.ServerID,
|
||||||
|
&row.Ts,
|
||||||
|
&row.Score,
|
||||||
|
&row.Step,
|
||||||
|
&row.Offset,
|
||||||
|
&row.Rtt,
|
||||||
|
&leap,
|
||||||
|
&row.Attributes.Warning,
|
||||||
|
&row.Attributes.Error,
|
||||||
|
); err != nil {
|
||||||
|
log.Error("could not parse row", "err", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
row.Attributes.Leap = int8(leap)
|
||||||
|
|
||||||
|
rv = append(rv, row)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// log.InfoContext(ctx, "returning data", "rv", rv)
|
||||||
|
|
||||||
|
return rv, nil
|
||||||
|
}
|
||||||
@@ -2,10 +2,17 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
"syscall"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"go.ntppool.org/common/logger"
|
||||||
|
"go.ntppool.org/common/version"
|
||||||
"go.ntppool.org/data-api/server"
|
"go.ntppool.org/data-api/server"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
)
|
)
|
||||||
@@ -25,25 +32,38 @@ func (cli *CLI) serverCmd() *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (cli *CLI) serverCLI(cmd *cobra.Command, args []string) error {
|
func (cli *CLI) serverCLI(cmd *cobra.Command, args []string) error {
|
||||||
|
log := logger.Setup()
|
||||||
|
|
||||||
// cfg := cli.Config
|
// cfg := cli.Config
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
g, ctx := errgroup.WithContext(ctx)
|
g, ctx := errgroup.WithContext(ctx)
|
||||||
|
|
||||||
g.Go(func() error {
|
log.Info("starting", "version", version.Version())
|
||||||
|
|
||||||
srv, err := server.NewServer(ctx, cfgFile)
|
srv, err := server.NewServer(ctx, cfgFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("srv setup: %s", err)
|
return fmt.Errorf("srv setup: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g.Go(func() error {
|
||||||
return srv.Run()
|
return srv.Run()
|
||||||
})
|
})
|
||||||
|
|
||||||
err := g.Wait()
|
g.Go(func() error {
|
||||||
if err != nil {
|
<-ctx.Done()
|
||||||
log.Printf("server error: %s", err)
|
shutdownCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
return srv.Shutdown(shutdownCtx)
|
||||||
|
})
|
||||||
|
|
||||||
|
err = g.Wait()
|
||||||
|
if err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||||
|
log.Error("server error", "err", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cancel()
|
// don't tell cobra something went wrong as it'll just
|
||||||
return err
|
// print usage information
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
94
go.mod
94
go.mod
@@ -1,69 +1,81 @@
|
|||||||
module go.ntppool.org/data-api
|
module go.ntppool.org/data-api
|
||||||
|
|
||||||
go 1.21.3
|
go 1.21.6
|
||||||
|
|
||||||
|
// replace github.com/samber/slog-echo => github.com/abh/slog-echo v0.0.0-20231024051244-af740639893e
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/ClickHouse/clickhouse-go/v2 v2.14.3
|
github.com/ClickHouse/clickhouse-go/v2 v2.20.0
|
||||||
github.com/go-sql-driver/mysql v1.7.1
|
github.com/go-sql-driver/mysql v1.7.1
|
||||||
github.com/labstack/echo/v4 v4.11.2
|
github.com/hashicorp/go-retryablehttp v0.7.5
|
||||||
github.com/spf13/cobra v1.7.0
|
github.com/labstack/echo-contrib v0.15.0
|
||||||
github.com/stretchr/testify v1.8.4
|
github.com/labstack/echo/v4 v4.11.4
|
||||||
go.ntppool.org/common v0.2.3
|
github.com/samber/slog-echo v1.12.2
|
||||||
go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.45.0
|
github.com/spf13/cobra v1.8.0
|
||||||
go.opentelemetry.io/otel v1.19.0
|
github.com/stretchr/testify v1.9.0
|
||||||
go.opentelemetry.io/otel/trace v1.19.0
|
go.ntppool.org/api v0.3.2
|
||||||
golang.org/x/sync v0.4.0
|
go.ntppool.org/common v0.2.8-0.20240203082131-1e8785bd321a
|
||||||
|
go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.49.0
|
||||||
|
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.49.0
|
||||||
|
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0
|
||||||
|
go.opentelemetry.io/otel v1.24.0
|
||||||
|
go.opentelemetry.io/otel/trace v1.24.0
|
||||||
|
golang.org/x/sync v0.6.0
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/ClickHouse/ch-go v0.58.2 // indirect
|
github.com/ClickHouse/ch-go v0.61.3 // indirect
|
||||||
github.com/andybalholm/brotli v1.0.6 // indirect
|
github.com/andybalholm/brotli v1.1.0 // indirect
|
||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
|
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
|
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||||
github.com/go-faster/city v1.0.1 // indirect
|
github.com/go-faster/city v1.0.1 // indirect
|
||||||
github.com/go-faster/errors v0.6.1 // indirect
|
github.com/go-faster/errors v0.7.1 // indirect
|
||||||
github.com/go-logr/logr v1.2.4 // indirect
|
github.com/go-logr/logr v1.4.1 // indirect
|
||||||
github.com/go-logr/stdr v1.2.2 // indirect
|
github.com/go-logr/stdr v1.2.2 // indirect
|
||||||
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
|
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
|
||||||
github.com/golang/protobuf v1.5.3 // indirect
|
github.com/golang/protobuf v1.5.4 // indirect
|
||||||
github.com/google/uuid v1.3.1 // indirect
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 // indirect
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // indirect
|
||||||
|
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||||
github.com/klauspost/compress v1.17.2 // indirect
|
github.com/klauspost/compress v1.17.7 // indirect
|
||||||
github.com/labstack/gommon v0.4.0 // indirect
|
github.com/labstack/gommon v0.4.2 // indirect
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
|
github.com/paulmach/orb v0.11.1 // indirect
|
||||||
github.com/paulmach/orb v0.10.0 // indirect
|
github.com/pierrec/lz4/v4 v4.1.21 // indirect
|
||||||
github.com/pierrec/lz4/v4 v4.1.18 // indirect
|
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/prometheus/client_golang v1.17.0 // indirect
|
github.com/prometheus/client_golang v1.19.0 // indirect
|
||||||
github.com/prometheus/client_model v0.5.0 // indirect
|
github.com/prometheus/client_model v0.6.0 // indirect
|
||||||
github.com/prometheus/common v0.45.0 // indirect
|
github.com/prometheus/common v0.49.0 // indirect
|
||||||
github.com/prometheus/procfs v0.12.0 // indirect
|
github.com/prometheus/procfs v0.12.0 // indirect
|
||||||
|
github.com/remychantenay/slog-otel v1.2.4 // indirect
|
||||||
|
github.com/samber/lo v1.39.0 // indirect
|
||||||
github.com/segmentio/asm v1.2.0 // indirect
|
github.com/segmentio/asm v1.2.0 // indirect
|
||||||
github.com/shopspring/decimal v1.3.1 // indirect
|
github.com/shopspring/decimal v1.3.1 // indirect
|
||||||
github.com/spf13/pflag v1.0.5 // indirect
|
github.com/spf13/pflag v1.0.5 // indirect
|
||||||
github.com/stretchr/objx v0.5.1 // indirect
|
github.com/stretchr/objx v0.5.2 // indirect
|
||||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||||
github.com/valyala/fasttemplate v1.2.2 // indirect
|
github.com/valyala/fasttemplate v1.2.2 // indirect
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 // indirect
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 // indirect
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 // indirect
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 // indirect
|
||||||
go.opentelemetry.io/otel/metric v1.19.0 // indirect
|
go.opentelemetry.io/otel/metric v1.24.0 // indirect
|
||||||
go.opentelemetry.io/otel/sdk v1.19.0 // indirect
|
go.opentelemetry.io/otel/sdk v1.24.0 // indirect
|
||||||
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
|
go.opentelemetry.io/proto/otlp v1.1.0 // indirect
|
||||||
golang.org/x/crypto v0.14.0 // indirect
|
golang.org/x/crypto v0.21.0 // indirect
|
||||||
golang.org/x/mod v0.13.0 // indirect
|
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
|
||||||
golang.org/x/net v0.17.0 // indirect
|
golang.org/x/mod v0.16.0 // indirect
|
||||||
golang.org/x/sys v0.13.0 // indirect
|
golang.org/x/net v0.22.0 // indirect
|
||||||
golang.org/x/text v0.13.0 // indirect
|
golang.org/x/sys v0.18.0 // indirect
|
||||||
golang.org/x/time v0.3.0 // indirect
|
golang.org/x/text v0.14.0 // indirect
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b // indirect
|
golang.org/x/time v0.5.0 // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect
|
google.golang.org/genproto/googleapis/api v0.0.0-20240304212257-790db918fca8 // indirect
|
||||||
google.golang.org/grpc v1.59.0 // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240304212257-790db918fca8 // indirect
|
||||||
google.golang.org/protobuf v1.31.0 // indirect
|
google.golang.org/grpc v1.62.1 // indirect
|
||||||
|
google.golang.org/protobuf v1.33.0 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
211
go.sum
211
go.sum
@@ -1,26 +1,28 @@
|
|||||||
github.com/ClickHouse/ch-go v0.58.2 h1:jSm2szHbT9MCAB1rJ3WuCJqmGLi5UTjlNu+f530UTS0=
|
github.com/ClickHouse/ch-go v0.61.3 h1:MmBwUhXrAOBZK7n/sWBzq6FdIQ01cuF2SaaO8KlDRzI=
|
||||||
github.com/ClickHouse/ch-go v0.58.2/go.mod h1:Ap/0bEmiLa14gYjCiRkYGbXvbe8vwdrfTYWhsuQ99aw=
|
github.com/ClickHouse/ch-go v0.61.3/go.mod h1:1PqXjMz/7S1ZUaKvwPA3i35W2bz2mAMFeCi6DIXgGwQ=
|
||||||
github.com/ClickHouse/clickhouse-go/v2 v2.14.3 h1:s9SuU3PfJrfJ4SDbVRo6XM2ZWlr7efvW9Z/ppUpE1vo=
|
github.com/ClickHouse/clickhouse-go/v2 v2.20.0 h1:bvlLQ31XJfl7MxIqAq2l1G6JhHYzqEXdvfpMeU6bkKc=
|
||||||
github.com/ClickHouse/clickhouse-go/v2 v2.14.3/go.mod h1:qdw8IMGH4Y+PedKlf9QEhFO1ATTSFhh4exQRVIa3y2A=
|
github.com/ClickHouse/clickhouse-go/v2 v2.20.0/go.mod h1:VQfyA+tCwCRw2G7ogfY8V0fq/r0yJWzy8UDrjiP/Lbs=
|
||||||
github.com/andybalholm/brotli v1.0.6 h1:Yf9fFpf49Zrxb9NlQaluyE92/+X7UVHlhMNJN2sxfOI=
|
github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M=
|
||||||
github.com/andybalholm/brotli v1.0.6/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
|
github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY=
|
||||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||||
github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM=
|
github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM=
|
||||||
github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
||||||
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
|
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
|
||||||
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||||
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/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
||||||
|
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||||
github.com/go-faster/city v1.0.1 h1:4WAxSZ3V2Ws4QRDrscLEDcibJY8uf41H6AhXDrNDcGw=
|
github.com/go-faster/city v1.0.1 h1:4WAxSZ3V2Ws4QRDrscLEDcibJY8uf41H6AhXDrNDcGw=
|
||||||
github.com/go-faster/city v1.0.1/go.mod h1:jKcUJId49qdW3L1qKHH/3wPeUstCVpVSXTM6vO3VcTw=
|
github.com/go-faster/city v1.0.1/go.mod h1:jKcUJId49qdW3L1qKHH/3wPeUstCVpVSXTM6vO3VcTw=
|
||||||
github.com/go-faster/errors v0.6.1 h1:nNIPOBkprlKzkThvS/0YaX8Zs9KewLCOSFQS5BU06FI=
|
github.com/go-faster/errors v0.7.1 h1:MkJTnDoEdi9pDabt1dpWf7AA8/BaSYZqibYyhZ20AYg=
|
||||||
github.com/go-faster/errors v0.6.1/go.mod h1:5MGV2/2T9yvlrbhe9pD9LO5Z/2zCSq2T8j+Jpi2LAyY=
|
github.com/go-faster/errors v0.7.1/go.mod h1:5ySTjWFiphBs07IKuiL69nxdfd5+fzh1u7FPGZP2quo=
|
||||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||||
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
|
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
|
||||||
github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||||
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
|
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
|
||||||
@@ -28,27 +30,31 @@ github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9
|
|||||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||||
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
|
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
|
||||||
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
|
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
|
||||||
github.com/golang/glog v1.1.2 h1:DVjP2PbBOzHyzA+dn3WhHIq4NdVu3Q+pvivFICf/7fo=
|
|
||||||
github.com/golang/glog v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ=
|
|
||||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||||
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||||
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||||
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 h1:RtRsiaGvWxcwd8y3BiRZxsylPT8hLWZ5SPcfI+3IDNk=
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is=
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0/go.mod h1:TzP6duP4Py2pHLVPPQp42aoYI92+PCrVotyR5e8Vqlk=
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM=
|
||||||
|
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
|
||||||
|
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
|
||||||
|
github.com/hashicorp/go-hclog v0.9.2 h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxCsHI=
|
||||||
|
github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
|
||||||
|
github.com/hashicorp/go-retryablehttp v0.7.5 h1:bJj+Pj19UZMIweq/iie+1u5YCdGrnxCT9yvm0e+Nd5M=
|
||||||
|
github.com/hashicorp/go-retryablehttp v0.7.5/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8=
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
||||||
github.com/klauspost/compress v1.17.2 h1:RlWWUY/Dr4fL8qk9YG7DTZ7PDgME2V4csBXA8L/ixi4=
|
github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg=
|
||||||
github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
|
github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
||||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
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=
|
||||||
@@ -56,64 +62,62 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
|||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
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/labstack/echo/v4 v4.11.2 h1:T+cTLQxWCDfqDEoydYm5kCobjmHwOwcv4OJAPHilmdE=
|
github.com/labstack/echo-contrib v0.15.0 h1:9K+oRU265y4Mu9zpRDv3X+DGTqUALY6oRHCSZZKCRVU=
|
||||||
github.com/labstack/echo/v4 v4.11.2/go.mod h1:UcGuQ8V6ZNRmSweBIJkPvGfwCMIlFmiqrPqiEBfPYws=
|
github.com/labstack/echo-contrib v0.15.0/go.mod h1:lei+qt5CLB4oa7VHTE0yEfQSEB9XTJI1LUqko9UWvo4=
|
||||||
github.com/labstack/gommon v0.4.0 h1:y7cvthEAEbU0yHOf4axH8ZG2NH8knB9iNSoTO8dyIk8=
|
github.com/labstack/echo/v4 v4.11.4 h1:vDZmA+qNeh1pd/cCkEicDMrjtrnMGQ1QFI9gWN1zGq8=
|
||||||
github.com/labstack/gommon v0.4.0/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM=
|
github.com/labstack/echo/v4 v4.11.4/go.mod h1:noh7EvLwqDsmh/X/HWKPUl1AjzJrhyptRyEbQJfxen8=
|
||||||
github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
|
||||||
|
github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
|
||||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
|
||||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg=
|
|
||||||
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k=
|
|
||||||
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
|
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
|
||||||
github.com/paulmach/orb v0.10.0 h1:guVYVqzxHE/CQ1KpfGO077TR0ATHSNjp4s6XGLn3W9s=
|
github.com/paulmach/orb v0.11.1 h1:3koVegMC4X/WeiXYz9iswopaTwMem53NzTJuTF20JzU=
|
||||||
github.com/paulmach/orb v0.10.0/go.mod h1:5mULz1xQfs3bmQm63QEJA6lNGujuRafwA5S/EnuLaLU=
|
github.com/paulmach/orb v0.11.1/go.mod h1:5mULz1xQfs3bmQm63QEJA6lNGujuRafwA5S/EnuLaLU=
|
||||||
github.com/paulmach/protoscan v0.2.1/go.mod h1:SpcSwydNLrxUGSDvXvO0P7g7AuhJ7lcKfDlhJCDw2gY=
|
github.com/paulmach/protoscan v0.2.1/go.mod h1:SpcSwydNLrxUGSDvXvO0P7g7AuhJ7lcKfDlhJCDw2gY=
|
||||||
github.com/pierrec/lz4/v4 v4.1.18 h1:xaKrnTkyoqfh1YItXl56+6KJNVYWlEEPuAQW9xsplYQ=
|
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
|
||||||
github.com/pierrec/lz4/v4 v4.1.18/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
|
github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
|
||||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/prometheus/client_golang v1.17.0 h1:rl2sfwZMtSthVU752MqfjQozy7blglC+1SOtjMAMh+Q=
|
github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU=
|
||||||
github.com/prometheus/client_golang v1.17.0/go.mod h1:VeL+gMmOAxkS2IqfCq0ZmHSL+LjWfWDUmp1mBz9JgUY=
|
github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k=
|
||||||
github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw=
|
github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos=
|
||||||
github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI=
|
github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8=
|
||||||
github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM=
|
github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI=
|
||||||
github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY=
|
github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE=
|
||||||
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
|
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
|
||||||
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
|
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
|
||||||
|
github.com/remychantenay/slog-otel v1.2.4 h1:Z/IwIgFPzzGqLTI460KbTuJZPm5U830dgu0gPiEpufA=
|
||||||
|
github.com/remychantenay/slog-otel v1.2.4/go.mod h1:Ar2ZBcRfIPyoKV/3Xq4oHmNgKc69juGB0QMUzo1vJOc=
|
||||||
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
||||||
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
|
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
|
||||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
|
github.com/samber/lo v1.39.0 h1:4gTz1wUhNYLhFSKl6O+8peW0v2F4BCY034GRpU9WnuA=
|
||||||
|
github.com/samber/lo v1.39.0/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA=
|
||||||
|
github.com/samber/slog-echo v1.12.2 h1:GZI9sYjDRfLwjX9uX74kR59QwVWYJ2/rWYm7hrXRTXI=
|
||||||
|
github.com/samber/slog-echo v1.12.2/go.mod h1:/f78pHjVxGrIlHlS5fzWiW+BxkWltQ+SWKk8LKMjAMQ=
|
||||||
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/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
|
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
|
||||||
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
||||||
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
|
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
|
||||||
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
|
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
|
||||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
|
||||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||||
github.com/stretchr/objx v0.5.1 h1:4VhoImhV/Bm0ToFkXFi8hXNXwpDRZ/ynw3amt82mzq0=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
github.com/stretchr/objx v0.5.1/go.mod h1:/iHQpkQwBD6DLUmQ4pE+s1TXdob1mORJ4/UFdrifcy0=
|
|
||||||
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.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
|
||||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
|
||||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
|
||||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
|
||||||
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||||
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
|
||||||
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
|
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
|
||||||
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
||||||
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
|
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
|
||||||
@@ -123,71 +127,76 @@ github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7Jul
|
|||||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
go.mongodb.org/mongo-driver v1.11.4/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g=
|
go.mongodb.org/mongo-driver v1.11.4/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g=
|
||||||
go.ntppool.org/common v0.2.3 h1:uwASMzbYkAlRt8g6Ml+ha2GIk2bYhdGqG9YuKB+Ec8o=
|
go.ntppool.org/api v0.3.2 h1:mXp27VVQbux8U/W1kaajPSKhKV5cfQoB/uJivZ4rZ0w=
|
||||||
go.ntppool.org/common v0.2.3/go.mod h1:aF2ku4VreI4JeKJZBo+QAmq7HXixbxU6xUD2S/wweZs=
|
go.ntppool.org/api v0.3.2/go.mod h1:V5H0p9ecdSkXS0AsA3oFQ42sK3BgtiJRYEzb4GgrOIY=
|
||||||
go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.45.0 h1:JJCIHAxGCB5HM3NxeIwFjHc087Xwk96TG9kaZU6TAec=
|
go.ntppool.org/common v0.2.8-0.20240203082131-1e8785bd321a h1:RGQTSW230R1PFXwxfNgZSvBDHq5VDig8fjPDwt4y/ZY=
|
||||||
go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.45.0/go.mod h1:Px9kH7SJ+NhsgWRtD/eMcs15Tyt4uL3rM7X54qv6pfA=
|
go.ntppool.org/common v0.2.8-0.20240203082131-1e8785bd321a/go.mod h1:7gNYzGKJyVDo3g4NDH96ENTu3LVFJXyumNGAgmQkkrY=
|
||||||
go.opentelemetry.io/contrib/propagators/b3 v1.20.0 h1:Yty9Vs4F3D6/liF1o6FNt0PvN85h/BJJ6DQKJ3nrcM0=
|
go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.49.0 h1:o6uIusuFp29T4+GgCM7K9+O5t+N6BlqxmTx2cyvNau0=
|
||||||
go.opentelemetry.io/contrib/propagators/b3 v1.20.0/go.mod h1:On4VgbkqYL18kbJlWsa18+cMNe6rYpBnPi1ARI/BrsU=
|
go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.49.0/go.mod h1:juGX+uK8rUXMdZiUTM7WbiHt0pxg9pjOJNr3INg1awo=
|
||||||
go.opentelemetry.io/otel v1.19.0 h1:MuS/TNf4/j4IXsZuJegVzI1cwut7Qc00344rgH7p8bs=
|
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.49.0 h1:RtcvQ4iw3w9NBB5yRwgA4sSa82rfId7n4atVpvKx3bY=
|
||||||
go.opentelemetry.io/otel v1.19.0/go.mod h1:i0QyjOq3UPoTzff0PJB2N66fb4S0+rSbSB15/oyH9fY=
|
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.49.0/go.mod h1:f/PbKbRd4cdUICWell6DmzvVJ7QrmBgFrRHjXmAXbK4=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 h1:Mne5On7VWdx7omSrSSZvM4Kw7cS7NQkOOmLcgscI51U=
|
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0/go.mod h1:IPtUMKL4O3tH5y+iXVyAXqpAwMuzC1IrxVS81rummfE=
|
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 h1:IeMeyr1aBvBiPVYihXIaeIZba6b8E1bYp7lbdxK8CQg=
|
go.opentelemetry.io/contrib/propagators/b3 v1.24.0 h1:n4xwCdTx3pZqZs2CjS/CUZAs03y3dZcGhC/FepKtEUY=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0/go.mod h1:oVdCUtjq9MK9BlS7TtucsQwUcXcymNiEDjgDD2jMtZU=
|
go.opentelemetry.io/contrib/propagators/b3 v1.24.0/go.mod h1:k5wRxKRU2uXx2F8uNJ4TaonuEO/V7/5xoz7kdsDACT8=
|
||||||
go.opentelemetry.io/otel/metric v1.19.0 h1:aTzpGtV0ar9wlV4Sna9sdJyII5jTVJEvKETPiOKwvpE=
|
go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=
|
||||||
go.opentelemetry.io/otel/metric v1.19.0/go.mod h1:L5rUsV9kM1IxCj1MmSdS+JQAcVm319EUrDVLrt7jqt8=
|
go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=
|
||||||
go.opentelemetry.io/otel/sdk v1.19.0 h1:6USY6zH+L8uMH8L3t1enZPR3WFEmSTADlqldyHtJi3o=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 h1:t6wl9SPayj+c7lEIFgm4ooDBZVb01IhLB4InpomhRw8=
|
||||||
go.opentelemetry.io/otel/sdk v1.19.0/go.mod h1:NedEbbS4w3C6zElbLdPJKOpJQOrGUJ+GfzpjUvI0v1A=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0/go.mod h1:iSDOcsnSA5INXzZtwaBPrKp/lWu/V14Dd+llD0oI2EA=
|
||||||
go.opentelemetry.io/otel/trace v1.19.0 h1:DFVQmlVbfVeOuBRrwdtaehRrWiL1JoVs9CPIQ1Dzxpg=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 h1:Xw8U6u2f8DK2XAkGRFV7BBLENgnTGX9i4rQRxJf+/vs=
|
||||||
go.opentelemetry.io/otel/trace v1.19.0/go.mod h1:mfaSyvGyEJEI0nyV2I4qhNQnbBOUUmYZpYojqMnX2vo=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0/go.mod h1:6KW1Fm6R/s6Z3PGXwSJN2K4eT6wQB3vXX6CVnYX9NmM=
|
||||||
go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I=
|
go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI=
|
||||||
go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM=
|
go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco=
|
||||||
|
go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw=
|
||||||
|
go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg=
|
||||||
|
go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI=
|
||||||
|
go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU=
|
||||||
|
go.opentelemetry.io/proto/otlp v1.1.0 h1:2Di21piLrCqJ3U3eXGCTPHE9R8Nh+0uglSnOyxikMeI=
|
||||||
|
go.opentelemetry.io/proto/otlp v1.1.0/go.mod h1:GpBHCBWiqvVLDqmHZsoMM3C5ySeKTC7ej/RNTae6MdY=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
|
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
|
||||||
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
|
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
|
||||||
|
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ=
|
||||||
|
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc=
|
||||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY=
|
golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic=
|
||||||
golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
|
golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
|
||||||
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ=
|
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
|
||||||
golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
|
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
|
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
|
||||||
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
|
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
|
||||||
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||||
@@ -196,24 +205,20 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
|
|||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a h1:fwgW9j3vHirt4ObdHoYNwuO24BEZjSzbh+zPaNWoiY8=
|
google.golang.org/genproto/googleapis/api v0.0.0-20240304212257-790db918fca8 h1:8eadJkXbwDEMNwcB5O0s5Y5eCfyuCLdvaiOIaGTrWmQ=
|
||||||
google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a/go.mod h1:EMfReVxb80Dq1hhioy0sOsY9jCE46YDgHlJ7fWVUWRE=
|
google.golang.org/genproto/googleapis/api v0.0.0-20240304212257-790db918fca8/go.mod h1:O1cOfN1Cy6QEYr7VxtjOyP5AdAuR0aJ/MYZaaof623Y=
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b h1:CIC2YMXmIhYw6evmhPxBKJ4fmLbOFtXQN/GV3XOZR8k=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240304212257-790db918fca8 h1:IR+hp6ypxjH24bkMfEJ0yHR21+gwPWdV+/IBrPQyn3k=
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:IBQ646DjkDkvUIsVq/cc03FUFQ9wbZu7yE396YcL870=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240304212257-790db918fca8/go.mod h1:UCOku4NytXMJuLQE5VuqA5lX3PcHCBo8pxNyvkf4xBs=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b h1:ZlWIi1wSK56/8hn4QcBp/j9M7Gt3U/3hZw3mC7vDICo=
|
google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:swOH3j0KzcDDgGUWr+SNpyTen5YrXjS3eyPzFYKc6lc=
|
google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE=
|
||||||
google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk=
|
|
||||||
google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98=
|
|
||||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
|
||||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
|
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
|
||||||
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||||
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=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
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=
|
||||||
|
|||||||
121
logscores/history.go
Normal file
121
logscores/history.go
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
package logscores
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"database/sql"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"go.ntppool.org/common/logger"
|
||||||
|
"go.ntppool.org/common/tracing"
|
||||||
|
"go.ntppool.org/data-api/chdb"
|
||||||
|
"go.ntppool.org/data-api/ntpdb"
|
||||||
|
"go.opentelemetry.io/otel/attribute"
|
||||||
|
"go.opentelemetry.io/otel/trace"
|
||||||
|
)
|
||||||
|
|
||||||
|
type LogScoreHistory struct {
|
||||||
|
LogScores []ntpdb.LogScore
|
||||||
|
Monitors map[int]string
|
||||||
|
// MonitorIDs []uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetHistoryClickHouse(ctx context.Context, ch *chdb.ClickHouse, db *sql.DB, serverID, monitorID uint32, since time.Time, count int, fullHistory bool) (*LogScoreHistory, error) {
|
||||||
|
log := logger.FromContext(ctx)
|
||||||
|
ctx, span := tracing.Tracer().Start(ctx, "logscores.GetHistoryClickHouse",
|
||||||
|
trace.WithAttributes(
|
||||||
|
attribute.Int("server", int(serverID)),
|
||||||
|
attribute.Int("monitor", int(monitorID)),
|
||||||
|
attribute.Bool("full_history", fullHistory),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
defer span.End()
|
||||||
|
|
||||||
|
log.DebugContext(ctx, "GetHistoryCH", "server", serverID, "monitor", monitorID, "since", since, "count", count, "full_history", fullHistory)
|
||||||
|
|
||||||
|
ls, err := ch.Logscores(ctx, int(serverID), int(monitorID), since, count, fullHistory)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorContext(ctx, "clickhouse logscores", "err", err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
q := ntpdb.NewWrappedQuerier(ntpdb.New(db))
|
||||||
|
|
||||||
|
monitors, err := getMonitorNames(ctx, ls, q)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &LogScoreHistory{
|
||||||
|
LogScores: ls,
|
||||||
|
Monitors: monitors,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetHistoryMySQL(ctx context.Context, db *sql.DB, serverID, monitorID uint32, since time.Time, count int) (*LogScoreHistory, error) {
|
||||||
|
log := logger.FromContext(ctx)
|
||||||
|
ctx, span := tracing.Tracer().Start(ctx, "logscores.GetHistoryMySQL")
|
||||||
|
defer span.End()
|
||||||
|
|
||||||
|
span.SetAttributes(
|
||||||
|
attribute.Int("server", int(serverID)),
|
||||||
|
attribute.Int("monitor", int(monitorID)),
|
||||||
|
)
|
||||||
|
|
||||||
|
log.Debug("GetHistoryMySQL", "server", serverID, "monitor", monitorID, "since", since, "count", count)
|
||||||
|
|
||||||
|
q := ntpdb.NewWrappedQuerier(ntpdb.New(db))
|
||||||
|
|
||||||
|
var ls []ntpdb.LogScore
|
||||||
|
var err error
|
||||||
|
if monitorID > 0 {
|
||||||
|
ls, err = q.GetServerLogScoresByMonitorID(ctx, ntpdb.GetServerLogScoresByMonitorIDParams{
|
||||||
|
ServerID: serverID,
|
||||||
|
MonitorID: sql.NullInt32{Int32: int32(monitorID), Valid: true},
|
||||||
|
Limit: int32(count),
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
ls, err = q.GetServerLogScores(ctx, ntpdb.GetServerLogScoresParams{
|
||||||
|
ServerID: serverID,
|
||||||
|
Limit: int32(count),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
monitors, err := getMonitorNames(ctx, ls, q)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &LogScoreHistory{
|
||||||
|
LogScores: ls,
|
||||||
|
Monitors: monitors,
|
||||||
|
// MonitorIDs: monitorIDs,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func getMonitorNames(ctx context.Context, ls []ntpdb.LogScore, q ntpdb.QuerierTx) (map[int]string, error) {
|
||||||
|
monitors := map[int]string{}
|
||||||
|
monitorIDs := []uint32{}
|
||||||
|
for _, l := range ls {
|
||||||
|
if !l.MonitorID.Valid {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
mID := uint32(l.MonitorID.Int32)
|
||||||
|
if _, ok := monitors[int(mID)]; !ok {
|
||||||
|
monitors[int(mID)] = ""
|
||||||
|
monitorIDs = append(monitorIDs, mID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dbmons, err := q.GetMonitorsByID(ctx, monitorIDs)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, m := range dbmons {
|
||||||
|
monitors[int(m.ID)] = m.DisplayName()
|
||||||
|
}
|
||||||
|
return monitors, nil
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.22.0
|
// sqlc v1.25.0
|
||||||
|
|
||||||
package ntpdb
|
package ntpdb
|
||||||
|
|
||||||
|
|||||||
289
ntpdb/models.go
289
ntpdb/models.go
@@ -1,14 +1,232 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.22.0
|
// sqlc v1.25.0
|
||||||
|
|
||||||
package ntpdb
|
package ntpdb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"database/sql"
|
||||||
"database/sql/driver"
|
"database/sql/driver"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"go.ntppool.org/common/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type MonitorsIpVersion string
|
||||||
|
|
||||||
|
const (
|
||||||
|
MonitorsIpVersionV4 MonitorsIpVersion = "v4"
|
||||||
|
MonitorsIpVersionV6 MonitorsIpVersion = "v6"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (e *MonitorsIpVersion) Scan(src interface{}) error {
|
||||||
|
switch s := src.(type) {
|
||||||
|
case []byte:
|
||||||
|
*e = MonitorsIpVersion(s)
|
||||||
|
case string:
|
||||||
|
*e = MonitorsIpVersion(s)
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("unsupported scan type for MonitorsIpVersion: %T", src)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type NullMonitorsIpVersion struct {
|
||||||
|
MonitorsIpVersion MonitorsIpVersion `json:"monitors_ip_version"`
|
||||||
|
Valid bool `json:"valid"` // Valid is true if MonitorsIpVersion is not NULL
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan implements the Scanner interface.
|
||||||
|
func (ns *NullMonitorsIpVersion) Scan(value interface{}) error {
|
||||||
|
if value == nil {
|
||||||
|
ns.MonitorsIpVersion, ns.Valid = "", false
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
ns.Valid = true
|
||||||
|
return ns.MonitorsIpVersion.Scan(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Value implements the driver Valuer interface.
|
||||||
|
func (ns NullMonitorsIpVersion) Value() (driver.Value, error) {
|
||||||
|
if !ns.Valid {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return string(ns.MonitorsIpVersion), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type MonitorsStatus string
|
||||||
|
|
||||||
|
const (
|
||||||
|
MonitorsStatusPending MonitorsStatus = "pending"
|
||||||
|
MonitorsStatusTesting MonitorsStatus = "testing"
|
||||||
|
MonitorsStatusActive MonitorsStatus = "active"
|
||||||
|
MonitorsStatusPaused MonitorsStatus = "paused"
|
||||||
|
MonitorsStatusDeleted MonitorsStatus = "deleted"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (e *MonitorsStatus) Scan(src interface{}) error {
|
||||||
|
switch s := src.(type) {
|
||||||
|
case []byte:
|
||||||
|
*e = MonitorsStatus(s)
|
||||||
|
case string:
|
||||||
|
*e = MonitorsStatus(s)
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("unsupported scan type for MonitorsStatus: %T", src)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type NullMonitorsStatus struct {
|
||||||
|
MonitorsStatus MonitorsStatus `json:"monitors_status"`
|
||||||
|
Valid bool `json:"valid"` // Valid is true if MonitorsStatus is not NULL
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan implements the Scanner interface.
|
||||||
|
func (ns *NullMonitorsStatus) Scan(value interface{}) error {
|
||||||
|
if value == nil {
|
||||||
|
ns.MonitorsStatus, ns.Valid = "", false
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
ns.Valid = true
|
||||||
|
return ns.MonitorsStatus.Scan(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Value implements the driver Valuer interface.
|
||||||
|
func (ns NullMonitorsStatus) Value() (driver.Value, error) {
|
||||||
|
if !ns.Valid {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return string(ns.MonitorsStatus), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type MonitorsType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
MonitorsTypeMonitor MonitorsType = "monitor"
|
||||||
|
MonitorsTypeScore MonitorsType = "score"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (e *MonitorsType) Scan(src interface{}) error {
|
||||||
|
switch s := src.(type) {
|
||||||
|
case []byte:
|
||||||
|
*e = MonitorsType(s)
|
||||||
|
case string:
|
||||||
|
*e = MonitorsType(s)
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("unsupported scan type for MonitorsType: %T", src)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type NullMonitorsType struct {
|
||||||
|
MonitorsType MonitorsType `json:"monitors_type"`
|
||||||
|
Valid bool `json:"valid"` // Valid is true if MonitorsType is not NULL
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan implements the Scanner interface.
|
||||||
|
func (ns *NullMonitorsType) Scan(value interface{}) error {
|
||||||
|
if value == nil {
|
||||||
|
ns.MonitorsType, ns.Valid = "", false
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
ns.Valid = true
|
||||||
|
return ns.MonitorsType.Scan(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Value implements the driver Valuer interface.
|
||||||
|
func (ns NullMonitorsType) Value() (driver.Value, error) {
|
||||||
|
if !ns.Valid {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return string(ns.MonitorsType), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type ServerScoresStatus string
|
||||||
|
|
||||||
|
const (
|
||||||
|
ServerScoresStatusNew ServerScoresStatus = "new"
|
||||||
|
ServerScoresStatusTesting ServerScoresStatus = "testing"
|
||||||
|
ServerScoresStatusActive ServerScoresStatus = "active"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (e *ServerScoresStatus) Scan(src interface{}) error {
|
||||||
|
switch s := src.(type) {
|
||||||
|
case []byte:
|
||||||
|
*e = ServerScoresStatus(s)
|
||||||
|
case string:
|
||||||
|
*e = ServerScoresStatus(s)
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("unsupported scan type for ServerScoresStatus: %T", src)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type NullServerScoresStatus struct {
|
||||||
|
ServerScoresStatus ServerScoresStatus `json:"server_scores_status"`
|
||||||
|
Valid bool `json:"valid"` // Valid is true if ServerScoresStatus is not NULL
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan implements the Scanner interface.
|
||||||
|
func (ns *NullServerScoresStatus) Scan(value interface{}) error {
|
||||||
|
if value == nil {
|
||||||
|
ns.ServerScoresStatus, ns.Valid = "", false
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
ns.Valid = true
|
||||||
|
return ns.ServerScoresStatus.Scan(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Value implements the driver Valuer interface.
|
||||||
|
func (ns NullServerScoresStatus) Value() (driver.Value, error) {
|
||||||
|
if !ns.Valid {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return string(ns.ServerScoresStatus), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type ServersIpVersion string
|
||||||
|
|
||||||
|
const (
|
||||||
|
ServersIpVersionV4 ServersIpVersion = "v4"
|
||||||
|
ServersIpVersionV6 ServersIpVersion = "v6"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (e *ServersIpVersion) Scan(src interface{}) error {
|
||||||
|
switch s := src.(type) {
|
||||||
|
case []byte:
|
||||||
|
*e = ServersIpVersion(s)
|
||||||
|
case string:
|
||||||
|
*e = ServersIpVersion(s)
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("unsupported scan type for ServersIpVersion: %T", src)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type NullServersIpVersion struct {
|
||||||
|
ServersIpVersion ServersIpVersion `json:"servers_ip_version"`
|
||||||
|
Valid bool `json:"valid"` // Valid is true if ServersIpVersion is not NULL
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan implements the Scanner interface.
|
||||||
|
func (ns *NullServersIpVersion) Scan(value interface{}) error {
|
||||||
|
if value == nil {
|
||||||
|
ns.ServersIpVersion, ns.Valid = "", false
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
ns.Valid = true
|
||||||
|
return ns.ServersIpVersion.Scan(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Value implements the driver Valuer interface.
|
||||||
|
func (ns NullServersIpVersion) Value() (driver.Value, error) {
|
||||||
|
if !ns.Valid {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return string(ns.ServersIpVersion), nil
|
||||||
|
}
|
||||||
|
|
||||||
type ZoneServerCountsIpVersion string
|
type ZoneServerCountsIpVersion string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -50,3 +268,72 @@ func (ns NullZoneServerCountsIpVersion) Value() (driver.Value, error) {
|
|||||||
}
|
}
|
||||||
return string(ns.ZoneServerCountsIpVersion), nil
|
return string(ns.ZoneServerCountsIpVersion), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type LogScore struct {
|
||||||
|
ID uint64 `db:"id" json:"id"`
|
||||||
|
MonitorID sql.NullInt32 `db:"monitor_id" json:"monitor_id"`
|
||||||
|
ServerID uint32 `db:"server_id" json:"server_id"`
|
||||||
|
Ts time.Time `db:"ts" json:"ts"`
|
||||||
|
Score float64 `db:"score" json:"score"`
|
||||||
|
Step float64 `db:"step" json:"step"`
|
||||||
|
Offset sql.NullFloat64 `db:"offset" json:"offset"`
|
||||||
|
Rtt sql.NullInt32 `db:"rtt" json:"rtt"`
|
||||||
|
Attributes types.LogScoreAttributes `db:"attributes" json:"attributes"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Monitor struct {
|
||||||
|
ID uint32 `db:"id" json:"id"`
|
||||||
|
Type MonitorsType `db:"type" json:"type"`
|
||||||
|
UserID sql.NullInt32 `db:"user_id" json:"user_id"`
|
||||||
|
AccountID sql.NullInt32 `db:"account_id" json:"account_id"`
|
||||||
|
Name string `db:"name" json:"name"`
|
||||||
|
Location string `db:"location" json:"location"`
|
||||||
|
Ip sql.NullString `db:"ip" json:"ip"`
|
||||||
|
IpVersion NullMonitorsIpVersion `db:"ip_version" json:"ip_version"`
|
||||||
|
TlsName sql.NullString `db:"tls_name" json:"tls_name"`
|
||||||
|
ApiKey sql.NullString `db:"api_key" json:"api_key"`
|
||||||
|
Status MonitorsStatus `db:"status" json:"status"`
|
||||||
|
Config string `db:"config" json:"config"`
|
||||||
|
ClientVersion string `db:"client_version" json:"client_version"`
|
||||||
|
LastSeen sql.NullTime `db:"last_seen" json:"last_seen"`
|
||||||
|
LastSubmit sql.NullTime `db:"last_submit" json:"last_submit"`
|
||||||
|
CreatedOn time.Time `db:"created_on" json:"created_on"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Server struct {
|
||||||
|
ID uint32 `db:"id" json:"id"`
|
||||||
|
Ip string `db:"ip" json:"ip"`
|
||||||
|
IpVersion ServersIpVersion `db:"ip_version" json:"ip_version"`
|
||||||
|
UserID sql.NullInt32 `db:"user_id" json:"user_id"`
|
||||||
|
AccountID sql.NullInt32 `db:"account_id" json:"account_id"`
|
||||||
|
Hostname sql.NullString `db:"hostname" json:"hostname"`
|
||||||
|
Stratum sql.NullInt32 `db:"stratum" json:"stratum"`
|
||||||
|
InPool uint32 `db:"in_pool" json:"in_pool"`
|
||||||
|
InServerList uint32 `db:"in_server_list" json:"in_server_list"`
|
||||||
|
Netspeed uint32 `db:"netspeed" json:"netspeed"`
|
||||||
|
NetspeedTarget uint32 `db:"netspeed_target" json:"netspeed_target"`
|
||||||
|
CreatedOn time.Time `db:"created_on" json:"created_on"`
|
||||||
|
UpdatedOn time.Time `db:"updated_on" json:"updated_on"`
|
||||||
|
ScoreTs sql.NullTime `db:"score_ts" json:"score_ts"`
|
||||||
|
ScoreRaw float64 `db:"score_raw" json:"score_raw"`
|
||||||
|
DeletionOn sql.NullTime `db:"deletion_on" json:"deletion_on"`
|
||||||
|
Flags string `db:"flags" json:"flags"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Zone struct {
|
||||||
|
ID uint32 `db:"id" json:"id"`
|
||||||
|
Name string `db:"name" json:"name"`
|
||||||
|
Description sql.NullString `db:"description" json:"description"`
|
||||||
|
ParentID sql.NullInt32 `db:"parent_id" json:"parent_id"`
|
||||||
|
Dns bool `db:"dns" json:"dns"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ZoneServerCount struct {
|
||||||
|
ID uint32 `db:"id" json:"id"`
|
||||||
|
ZoneID uint32 `db:"zone_id" json:"zone_id"`
|
||||||
|
IpVersion ZoneServerCountsIpVersion `db:"ip_version" json:"ip_version"`
|
||||||
|
Date time.Time `db:"date" json:"date"`
|
||||||
|
CountActive uint32 `db:"count_active" json:"count_active"`
|
||||||
|
CountRegistered uint32 `db:"count_registered" json:"count_registered"`
|
||||||
|
NetspeedActive uint32 `db:"netspeed_active" json:"netspeed_active"`
|
||||||
|
}
|
||||||
|
|||||||
23
ntpdb/monitor.go
Normal file
23
ntpdb/monitor.go
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package ntpdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (m *Monitor) DisplayName() string {
|
||||||
|
switch {
|
||||||
|
case len(m.Name) > 0:
|
||||||
|
return m.Name
|
||||||
|
case m.TlsName.Valid && len(m.TlsName.String) > 0:
|
||||||
|
name := m.TlsName.String
|
||||||
|
if idx := strings.Index(name, "."); idx > 0 {
|
||||||
|
name = name[0:idx]
|
||||||
|
}
|
||||||
|
return name
|
||||||
|
case len(m.Location) > 0:
|
||||||
|
return m.Location + " (" + strconv.Itoa(int(m.ID)) + ")" // todo: IDToken instead of ID
|
||||||
|
default:
|
||||||
|
return strconv.Itoa(int(m.ID)) // todo: IDToken
|
||||||
|
}
|
||||||
|
}
|
||||||
208
ntpdb/otel.go
208
ntpdb/otel.go
@@ -8,6 +8,7 @@ package ntpdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"database/sql"
|
||||||
|
|
||||||
"go.opentelemetry.io/otel"
|
"go.opentelemetry.io/otel"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
@@ -78,6 +79,144 @@ func (_d QuerierTxWithTracing) Commit(ctx context.Context) (err error) {
|
|||||||
return _d.QuerierTx.Commit(ctx)
|
return _d.QuerierTx.Commit(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetMonitorByName implements QuerierTx
|
||||||
|
func (_d QuerierTxWithTracing) GetMonitorByName(ctx context.Context, tlsName sql.NullString) (m1 Monitor, err error) {
|
||||||
|
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "QuerierTx.GetMonitorByName")
|
||||||
|
defer func() {
|
||||||
|
if _d._spanDecorator != nil {
|
||||||
|
_d._spanDecorator(_span, map[string]interface{}{
|
||||||
|
"ctx": ctx,
|
||||||
|
"tlsName": tlsName}, map[string]interface{}{
|
||||||
|
"m1": m1,
|
||||||
|
"err": err})
|
||||||
|
} else if err != nil {
|
||||||
|
_span.RecordError(err)
|
||||||
|
_span.SetAttributes(
|
||||||
|
attribute.String("event", "error"),
|
||||||
|
attribute.String("message", err.Error()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
_span.End()
|
||||||
|
}()
|
||||||
|
return _d.QuerierTx.GetMonitorByName(ctx, tlsName)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetMonitorsByID implements QuerierTx
|
||||||
|
func (_d QuerierTxWithTracing) GetMonitorsByID(ctx context.Context, monitorids []uint32) (ma1 []Monitor, err error) {
|
||||||
|
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "QuerierTx.GetMonitorsByID")
|
||||||
|
defer func() {
|
||||||
|
if _d._spanDecorator != nil {
|
||||||
|
_d._spanDecorator(_span, map[string]interface{}{
|
||||||
|
"ctx": ctx,
|
||||||
|
"monitorids": monitorids}, map[string]interface{}{
|
||||||
|
"ma1": ma1,
|
||||||
|
"err": err})
|
||||||
|
} else if err != nil {
|
||||||
|
_span.RecordError(err)
|
||||||
|
_span.SetAttributes(
|
||||||
|
attribute.String("event", "error"),
|
||||||
|
attribute.String("message", err.Error()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
_span.End()
|
||||||
|
}()
|
||||||
|
return _d.QuerierTx.GetMonitorsByID(ctx, monitorids)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetServerByID implements QuerierTx
|
||||||
|
func (_d QuerierTxWithTracing) GetServerByID(ctx context.Context, id uint32) (s1 Server, err error) {
|
||||||
|
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "QuerierTx.GetServerByID")
|
||||||
|
defer func() {
|
||||||
|
if _d._spanDecorator != nil {
|
||||||
|
_d._spanDecorator(_span, map[string]interface{}{
|
||||||
|
"ctx": ctx,
|
||||||
|
"id": id}, map[string]interface{}{
|
||||||
|
"s1": s1,
|
||||||
|
"err": err})
|
||||||
|
} else if err != nil {
|
||||||
|
_span.RecordError(err)
|
||||||
|
_span.SetAttributes(
|
||||||
|
attribute.String("event", "error"),
|
||||||
|
attribute.String("message", err.Error()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
_span.End()
|
||||||
|
}()
|
||||||
|
return _d.QuerierTx.GetServerByID(ctx, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetServerByIP implements QuerierTx
|
||||||
|
func (_d QuerierTxWithTracing) GetServerByIP(ctx context.Context, ip string) (s1 Server, err error) {
|
||||||
|
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "QuerierTx.GetServerByIP")
|
||||||
|
defer func() {
|
||||||
|
if _d._spanDecorator != nil {
|
||||||
|
_d._spanDecorator(_span, map[string]interface{}{
|
||||||
|
"ctx": ctx,
|
||||||
|
"ip": ip}, map[string]interface{}{
|
||||||
|
"s1": s1,
|
||||||
|
"err": err})
|
||||||
|
} else if err != nil {
|
||||||
|
_span.RecordError(err)
|
||||||
|
_span.SetAttributes(
|
||||||
|
attribute.String("event", "error"),
|
||||||
|
attribute.String("message", err.Error()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
_span.End()
|
||||||
|
}()
|
||||||
|
return _d.QuerierTx.GetServerByIP(ctx, ip)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetServerLogScores implements QuerierTx
|
||||||
|
func (_d QuerierTxWithTracing) GetServerLogScores(ctx context.Context, arg GetServerLogScoresParams) (la1 []LogScore, err error) {
|
||||||
|
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "QuerierTx.GetServerLogScores")
|
||||||
|
defer func() {
|
||||||
|
if _d._spanDecorator != nil {
|
||||||
|
_d._spanDecorator(_span, map[string]interface{}{
|
||||||
|
"ctx": ctx,
|
||||||
|
"arg": arg}, map[string]interface{}{
|
||||||
|
"la1": la1,
|
||||||
|
"err": err})
|
||||||
|
} else if err != nil {
|
||||||
|
_span.RecordError(err)
|
||||||
|
_span.SetAttributes(
|
||||||
|
attribute.String("event", "error"),
|
||||||
|
attribute.String("message", err.Error()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
_span.End()
|
||||||
|
}()
|
||||||
|
return _d.QuerierTx.GetServerLogScores(ctx, arg)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetServerLogScoresByMonitorID implements QuerierTx
|
||||||
|
func (_d QuerierTxWithTracing) GetServerLogScoresByMonitorID(ctx context.Context, arg GetServerLogScoresByMonitorIDParams) (la1 []LogScore, err error) {
|
||||||
|
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "QuerierTx.GetServerLogScoresByMonitorID")
|
||||||
|
defer func() {
|
||||||
|
if _d._spanDecorator != nil {
|
||||||
|
_d._spanDecorator(_span, map[string]interface{}{
|
||||||
|
"ctx": ctx,
|
||||||
|
"arg": arg}, map[string]interface{}{
|
||||||
|
"la1": la1,
|
||||||
|
"err": err})
|
||||||
|
} else if err != nil {
|
||||||
|
_span.RecordError(err)
|
||||||
|
_span.SetAttributes(
|
||||||
|
attribute.String("event", "error"),
|
||||||
|
attribute.String("message", err.Error()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
_span.End()
|
||||||
|
}()
|
||||||
|
return _d.QuerierTx.GetServerLogScoresByMonitorID(ctx, arg)
|
||||||
|
}
|
||||||
|
|
||||||
// GetServerNetspeed implements QuerierTx
|
// GetServerNetspeed implements QuerierTx
|
||||||
func (_d QuerierTxWithTracing) GetServerNetspeed(ctx context.Context, ip string) (u1 uint32, err error) {
|
func (_d QuerierTxWithTracing) GetServerNetspeed(ctx context.Context, ip string) (u1 uint32, err error) {
|
||||||
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "QuerierTx.GetServerNetspeed")
|
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "QuerierTx.GetServerNetspeed")
|
||||||
@@ -101,6 +240,75 @@ func (_d QuerierTxWithTracing) GetServerNetspeed(ctx context.Context, ip string)
|
|||||||
return _d.QuerierTx.GetServerNetspeed(ctx, ip)
|
return _d.QuerierTx.GetServerNetspeed(ctx, ip)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetServerScores implements QuerierTx
|
||||||
|
func (_d QuerierTxWithTracing) GetServerScores(ctx context.Context, arg GetServerScoresParams) (ga1 []GetServerScoresRow, err error) {
|
||||||
|
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "QuerierTx.GetServerScores")
|
||||||
|
defer func() {
|
||||||
|
if _d._spanDecorator != nil {
|
||||||
|
_d._spanDecorator(_span, map[string]interface{}{
|
||||||
|
"ctx": ctx,
|
||||||
|
"arg": arg}, map[string]interface{}{
|
||||||
|
"ga1": ga1,
|
||||||
|
"err": err})
|
||||||
|
} else if err != nil {
|
||||||
|
_span.RecordError(err)
|
||||||
|
_span.SetAttributes(
|
||||||
|
attribute.String("event", "error"),
|
||||||
|
attribute.String("message", err.Error()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
_span.End()
|
||||||
|
}()
|
||||||
|
return _d.QuerierTx.GetServerScores(ctx, arg)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetZoneByName implements QuerierTx
|
||||||
|
func (_d QuerierTxWithTracing) GetZoneByName(ctx context.Context, name string) (z1 Zone, err error) {
|
||||||
|
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "QuerierTx.GetZoneByName")
|
||||||
|
defer func() {
|
||||||
|
if _d._spanDecorator != nil {
|
||||||
|
_d._spanDecorator(_span, map[string]interface{}{
|
||||||
|
"ctx": ctx,
|
||||||
|
"name": name}, map[string]interface{}{
|
||||||
|
"z1": z1,
|
||||||
|
"err": err})
|
||||||
|
} else if err != nil {
|
||||||
|
_span.RecordError(err)
|
||||||
|
_span.SetAttributes(
|
||||||
|
attribute.String("event", "error"),
|
||||||
|
attribute.String("message", err.Error()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
_span.End()
|
||||||
|
}()
|
||||||
|
return _d.QuerierTx.GetZoneByName(ctx, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetZoneCounts implements QuerierTx
|
||||||
|
func (_d QuerierTxWithTracing) GetZoneCounts(ctx context.Context, zoneID uint32) (za1 []ZoneServerCount, err error) {
|
||||||
|
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "QuerierTx.GetZoneCounts")
|
||||||
|
defer func() {
|
||||||
|
if _d._spanDecorator != nil {
|
||||||
|
_d._spanDecorator(_span, map[string]interface{}{
|
||||||
|
"ctx": ctx,
|
||||||
|
"zoneID": zoneID}, map[string]interface{}{
|
||||||
|
"za1": za1,
|
||||||
|
"err": err})
|
||||||
|
} else if err != nil {
|
||||||
|
_span.RecordError(err)
|
||||||
|
_span.SetAttributes(
|
||||||
|
attribute.String("event", "error"),
|
||||||
|
attribute.String("message", err.Error()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
_span.End()
|
||||||
|
}()
|
||||||
|
return _d.QuerierTx.GetZoneCounts(ctx, zoneID)
|
||||||
|
}
|
||||||
|
|
||||||
// GetZoneStatsData implements QuerierTx
|
// GetZoneStatsData implements QuerierTx
|
||||||
func (_d QuerierTxWithTracing) GetZoneStatsData(ctx context.Context) (ga1 []GetZoneStatsDataRow, err error) {
|
func (_d QuerierTxWithTracing) GetZoneStatsData(ctx context.Context) (ga1 []GetZoneStatsDataRow, err error) {
|
||||||
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "QuerierTx.GetZoneStatsData")
|
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "QuerierTx.GetZoneStatsData")
|
||||||
|
|||||||
@@ -1,15 +1,25 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.22.0
|
// sqlc v1.25.0
|
||||||
|
|
||||||
package ntpdb
|
package ntpdb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"database/sql"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Querier interface {
|
type Querier interface {
|
||||||
|
GetMonitorByName(ctx context.Context, tlsName sql.NullString) (Monitor, error)
|
||||||
|
GetMonitorsByID(ctx context.Context, monitorids []uint32) ([]Monitor, error)
|
||||||
|
GetServerByID(ctx context.Context, id uint32) (Server, error)
|
||||||
|
GetServerByIP(ctx context.Context, ip string) (Server, error)
|
||||||
|
GetServerLogScores(ctx context.Context, arg GetServerLogScoresParams) ([]LogScore, error)
|
||||||
|
GetServerLogScoresByMonitorID(ctx context.Context, arg GetServerLogScoresByMonitorIDParams) ([]LogScore, error)
|
||||||
GetServerNetspeed(ctx context.Context, ip string) (uint32, error)
|
GetServerNetspeed(ctx context.Context, ip string) (uint32, error)
|
||||||
|
GetServerScores(ctx context.Context, arg GetServerScoresParams) ([]GetServerScoresRow, error)
|
||||||
|
GetZoneByName(ctx context.Context, name string) (Zone, error)
|
||||||
|
GetZoneCounts(ctx context.Context, zoneID uint32) ([]ZoneServerCount, error)
|
||||||
GetZoneStatsData(ctx context.Context) ([]GetZoneStatsDataRow, error)
|
GetZoneStatsData(ctx context.Context) ([]GetZoneStatsDataRow, error)
|
||||||
GetZoneStatsV2(ctx context.Context, ip string) ([]GetZoneStatsV2Row, error)
|
GetZoneStatsV2(ctx context.Context, ip string) ([]GetZoneStatsV2Row, error)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,260 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.22.0
|
// sqlc v1.25.0
|
||||||
// source: query.sql
|
// source: query.sql
|
||||||
|
|
||||||
package ntpdb
|
package ntpdb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"database/sql"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const getMonitorByName = `-- name: GetMonitorByName :one
|
||||||
|
select id, type, user_id, account_id, name, location, ip, ip_version, tls_name, api_key, status, config, client_version, last_seen, last_submit, created_on from monitors
|
||||||
|
where
|
||||||
|
tls_name like ?
|
||||||
|
order by id
|
||||||
|
limit 1
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) GetMonitorByName(ctx context.Context, tlsName sql.NullString) (Monitor, error) {
|
||||||
|
row := q.db.QueryRowContext(ctx, getMonitorByName, tlsName)
|
||||||
|
var i Monitor
|
||||||
|
err := row.Scan(
|
||||||
|
&i.ID,
|
||||||
|
&i.Type,
|
||||||
|
&i.UserID,
|
||||||
|
&i.AccountID,
|
||||||
|
&i.Name,
|
||||||
|
&i.Location,
|
||||||
|
&i.Ip,
|
||||||
|
&i.IpVersion,
|
||||||
|
&i.TlsName,
|
||||||
|
&i.ApiKey,
|
||||||
|
&i.Status,
|
||||||
|
&i.Config,
|
||||||
|
&i.ClientVersion,
|
||||||
|
&i.LastSeen,
|
||||||
|
&i.LastSubmit,
|
||||||
|
&i.CreatedOn,
|
||||||
|
)
|
||||||
|
return i, err
|
||||||
|
}
|
||||||
|
|
||||||
|
const getMonitorsByID = `-- name: GetMonitorsByID :many
|
||||||
|
select id, type, user_id, account_id, name, location, ip, ip_version, tls_name, api_key, status, config, client_version, last_seen, last_submit, created_on from monitors
|
||||||
|
where id in (/*SLICE:MonitorIDs*/?)
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) GetMonitorsByID(ctx context.Context, monitorids []uint32) ([]Monitor, error) {
|
||||||
|
query := getMonitorsByID
|
||||||
|
var queryParams []interface{}
|
||||||
|
if len(monitorids) > 0 {
|
||||||
|
for _, v := range monitorids {
|
||||||
|
queryParams = append(queryParams, v)
|
||||||
|
}
|
||||||
|
query = strings.Replace(query, "/*SLICE:MonitorIDs*/?", strings.Repeat(",?", len(monitorids))[1:], 1)
|
||||||
|
} else {
|
||||||
|
query = strings.Replace(query, "/*SLICE:MonitorIDs*/?", "NULL", 1)
|
||||||
|
}
|
||||||
|
rows, err := q.db.QueryContext(ctx, query, queryParams...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
var items []Monitor
|
||||||
|
for rows.Next() {
|
||||||
|
var i Monitor
|
||||||
|
if err := rows.Scan(
|
||||||
|
&i.ID,
|
||||||
|
&i.Type,
|
||||||
|
&i.UserID,
|
||||||
|
&i.AccountID,
|
||||||
|
&i.Name,
|
||||||
|
&i.Location,
|
||||||
|
&i.Ip,
|
||||||
|
&i.IpVersion,
|
||||||
|
&i.TlsName,
|
||||||
|
&i.ApiKey,
|
||||||
|
&i.Status,
|
||||||
|
&i.Config,
|
||||||
|
&i.ClientVersion,
|
||||||
|
&i.LastSeen,
|
||||||
|
&i.LastSubmit,
|
||||||
|
&i.CreatedOn,
|
||||||
|
); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
items = append(items, i)
|
||||||
|
}
|
||||||
|
if err := rows.Close(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return items, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
const getServerByID = `-- name: GetServerByID :one
|
||||||
|
select id, ip, ip_version, user_id, account_id, hostname, stratum, in_pool, in_server_list, netspeed, netspeed_target, created_on, updated_on, score_ts, score_raw, deletion_on, flags from servers
|
||||||
|
where
|
||||||
|
id = ?
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) GetServerByID(ctx context.Context, id uint32) (Server, error) {
|
||||||
|
row := q.db.QueryRowContext(ctx, getServerByID, id)
|
||||||
|
var i Server
|
||||||
|
err := row.Scan(
|
||||||
|
&i.ID,
|
||||||
|
&i.Ip,
|
||||||
|
&i.IpVersion,
|
||||||
|
&i.UserID,
|
||||||
|
&i.AccountID,
|
||||||
|
&i.Hostname,
|
||||||
|
&i.Stratum,
|
||||||
|
&i.InPool,
|
||||||
|
&i.InServerList,
|
||||||
|
&i.Netspeed,
|
||||||
|
&i.NetspeedTarget,
|
||||||
|
&i.CreatedOn,
|
||||||
|
&i.UpdatedOn,
|
||||||
|
&i.ScoreTs,
|
||||||
|
&i.ScoreRaw,
|
||||||
|
&i.DeletionOn,
|
||||||
|
&i.Flags,
|
||||||
|
)
|
||||||
|
return i, err
|
||||||
|
}
|
||||||
|
|
||||||
|
const getServerByIP = `-- name: GetServerByIP :one
|
||||||
|
select id, ip, ip_version, user_id, account_id, hostname, stratum, in_pool, in_server_list, netspeed, netspeed_target, created_on, updated_on, score_ts, score_raw, deletion_on, flags from servers
|
||||||
|
where
|
||||||
|
ip = ?
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) GetServerByIP(ctx context.Context, ip string) (Server, error) {
|
||||||
|
row := q.db.QueryRowContext(ctx, getServerByIP, ip)
|
||||||
|
var i Server
|
||||||
|
err := row.Scan(
|
||||||
|
&i.ID,
|
||||||
|
&i.Ip,
|
||||||
|
&i.IpVersion,
|
||||||
|
&i.UserID,
|
||||||
|
&i.AccountID,
|
||||||
|
&i.Hostname,
|
||||||
|
&i.Stratum,
|
||||||
|
&i.InPool,
|
||||||
|
&i.InServerList,
|
||||||
|
&i.Netspeed,
|
||||||
|
&i.NetspeedTarget,
|
||||||
|
&i.CreatedOn,
|
||||||
|
&i.UpdatedOn,
|
||||||
|
&i.ScoreTs,
|
||||||
|
&i.ScoreRaw,
|
||||||
|
&i.DeletionOn,
|
||||||
|
&i.Flags,
|
||||||
|
)
|
||||||
|
return i, err
|
||||||
|
}
|
||||||
|
|
||||||
|
const getServerLogScores = `-- name: GetServerLogScores :many
|
||||||
|
select id, monitor_id, server_id, ts, score, step, offset, rtt, attributes from log_scores
|
||||||
|
where
|
||||||
|
server_id = ?
|
||||||
|
order by ts desc
|
||||||
|
limit ?
|
||||||
|
`
|
||||||
|
|
||||||
|
type GetServerLogScoresParams struct {
|
||||||
|
ServerID uint32 `db:"server_id" json:"server_id"`
|
||||||
|
Limit int32 `db:"limit" json:"limit"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *Queries) GetServerLogScores(ctx context.Context, arg GetServerLogScoresParams) ([]LogScore, error) {
|
||||||
|
rows, err := q.db.QueryContext(ctx, getServerLogScores, arg.ServerID, arg.Limit)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
var items []LogScore
|
||||||
|
for rows.Next() {
|
||||||
|
var i LogScore
|
||||||
|
if err := rows.Scan(
|
||||||
|
&i.ID,
|
||||||
|
&i.MonitorID,
|
||||||
|
&i.ServerID,
|
||||||
|
&i.Ts,
|
||||||
|
&i.Score,
|
||||||
|
&i.Step,
|
||||||
|
&i.Offset,
|
||||||
|
&i.Rtt,
|
||||||
|
&i.Attributes,
|
||||||
|
); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
items = append(items, i)
|
||||||
|
}
|
||||||
|
if err := rows.Close(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return items, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
const getServerLogScoresByMonitorID = `-- name: GetServerLogScoresByMonitorID :many
|
||||||
|
select id, monitor_id, server_id, ts, score, step, offset, rtt, attributes from log_scores
|
||||||
|
where
|
||||||
|
server_id = ? AND
|
||||||
|
monitor_id = ?
|
||||||
|
order by ts desc
|
||||||
|
limit ?
|
||||||
|
`
|
||||||
|
|
||||||
|
type GetServerLogScoresByMonitorIDParams struct {
|
||||||
|
ServerID uint32 `db:"server_id" json:"server_id"`
|
||||||
|
MonitorID sql.NullInt32 `db:"monitor_id" json:"monitor_id"`
|
||||||
|
Limit int32 `db:"limit" json:"limit"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *Queries) GetServerLogScoresByMonitorID(ctx context.Context, arg GetServerLogScoresByMonitorIDParams) ([]LogScore, error) {
|
||||||
|
rows, err := q.db.QueryContext(ctx, getServerLogScoresByMonitorID, arg.ServerID, arg.MonitorID, arg.Limit)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
var items []LogScore
|
||||||
|
for rows.Next() {
|
||||||
|
var i LogScore
|
||||||
|
if err := rows.Scan(
|
||||||
|
&i.ID,
|
||||||
|
&i.MonitorID,
|
||||||
|
&i.ServerID,
|
||||||
|
&i.Ts,
|
||||||
|
&i.Score,
|
||||||
|
&i.Step,
|
||||||
|
&i.Offset,
|
||||||
|
&i.Rtt,
|
||||||
|
&i.Attributes,
|
||||||
|
); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
items = append(items, i)
|
||||||
|
}
|
||||||
|
if err := rows.Close(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return items, nil
|
||||||
|
}
|
||||||
|
|
||||||
const getServerNetspeed = `-- name: GetServerNetspeed :one
|
const getServerNetspeed = `-- name: GetServerNetspeed :one
|
||||||
select netspeed from servers where ip = ?
|
select netspeed from servers where ip = ?
|
||||||
`
|
`
|
||||||
@@ -21,6 +266,133 @@ func (q *Queries) GetServerNetspeed(ctx context.Context, ip string) (uint32, err
|
|||||||
return netspeed, err
|
return netspeed, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getServerScores = `-- name: GetServerScores :many
|
||||||
|
select
|
||||||
|
m.id, m.name, m.tls_name, m.location, m.type,
|
||||||
|
ss.score_raw, ss.score_ts, ss.status
|
||||||
|
from server_scores ss
|
||||||
|
inner join monitors m
|
||||||
|
on (m.id=ss.monitor_id)
|
||||||
|
where
|
||||||
|
server_id = ? AND
|
||||||
|
monitor_id in (/*SLICE:MonitorIDs*/?)
|
||||||
|
`
|
||||||
|
|
||||||
|
type GetServerScoresParams struct {
|
||||||
|
ServerID uint32 `db:"server_id" json:"server_id"`
|
||||||
|
MonitorIDs []uint32 `db:"MonitorIDs" json:"MonitorIDs"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetServerScoresRow struct {
|
||||||
|
ID uint32 `db:"id" json:"id"`
|
||||||
|
Name string `db:"name" json:"name"`
|
||||||
|
TlsName sql.NullString `db:"tls_name" json:"tls_name"`
|
||||||
|
Location string `db:"location" json:"location"`
|
||||||
|
Type MonitorsType `db:"type" json:"type"`
|
||||||
|
ScoreRaw float64 `db:"score_raw" json:"score_raw"`
|
||||||
|
ScoreTs sql.NullTime `db:"score_ts" json:"score_ts"`
|
||||||
|
Status ServerScoresStatus `db:"status" json:"status"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *Queries) GetServerScores(ctx context.Context, arg GetServerScoresParams) ([]GetServerScoresRow, error) {
|
||||||
|
query := getServerScores
|
||||||
|
var queryParams []interface{}
|
||||||
|
queryParams = append(queryParams, arg.ServerID)
|
||||||
|
if len(arg.MonitorIDs) > 0 {
|
||||||
|
for _, v := range arg.MonitorIDs {
|
||||||
|
queryParams = append(queryParams, v)
|
||||||
|
}
|
||||||
|
query = strings.Replace(query, "/*SLICE:MonitorIDs*/?", strings.Repeat(",?", len(arg.MonitorIDs))[1:], 1)
|
||||||
|
} else {
|
||||||
|
query = strings.Replace(query, "/*SLICE:MonitorIDs*/?", "NULL", 1)
|
||||||
|
}
|
||||||
|
rows, err := q.db.QueryContext(ctx, query, queryParams...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
var items []GetServerScoresRow
|
||||||
|
for rows.Next() {
|
||||||
|
var i GetServerScoresRow
|
||||||
|
if err := rows.Scan(
|
||||||
|
&i.ID,
|
||||||
|
&i.Name,
|
||||||
|
&i.TlsName,
|
||||||
|
&i.Location,
|
||||||
|
&i.Type,
|
||||||
|
&i.ScoreRaw,
|
||||||
|
&i.ScoreTs,
|
||||||
|
&i.Status,
|
||||||
|
); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
items = append(items, i)
|
||||||
|
}
|
||||||
|
if err := rows.Close(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return items, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
const getZoneByName = `-- name: GetZoneByName :one
|
||||||
|
select id, name, description, parent_id, dns from zones
|
||||||
|
where
|
||||||
|
name = ?
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) GetZoneByName(ctx context.Context, name string) (Zone, error) {
|
||||||
|
row := q.db.QueryRowContext(ctx, getZoneByName, name)
|
||||||
|
var i Zone
|
||||||
|
err := row.Scan(
|
||||||
|
&i.ID,
|
||||||
|
&i.Name,
|
||||||
|
&i.Description,
|
||||||
|
&i.ParentID,
|
||||||
|
&i.Dns,
|
||||||
|
)
|
||||||
|
return i, err
|
||||||
|
}
|
||||||
|
|
||||||
|
const getZoneCounts = `-- name: GetZoneCounts :many
|
||||||
|
select id, zone_id, ip_version, date, count_active, count_registered, netspeed_active from zone_server_counts
|
||||||
|
where zone_id = ?
|
||||||
|
order by date
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) GetZoneCounts(ctx context.Context, zoneID uint32) ([]ZoneServerCount, error) {
|
||||||
|
rows, err := q.db.QueryContext(ctx, getZoneCounts, zoneID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
var items []ZoneServerCount
|
||||||
|
for rows.Next() {
|
||||||
|
var i ZoneServerCount
|
||||||
|
if err := rows.Scan(
|
||||||
|
&i.ID,
|
||||||
|
&i.ZoneID,
|
||||||
|
&i.IpVersion,
|
||||||
|
&i.Date,
|
||||||
|
&i.CountActive,
|
||||||
|
&i.CountRegistered,
|
||||||
|
&i.NetspeedActive,
|
||||||
|
); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
items = append(items, i)
|
||||||
|
}
|
||||||
|
if err := rows.Close(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return items, nil
|
||||||
|
}
|
||||||
|
|
||||||
const getZoneStatsData = `-- name: GetZoneStatsData :many
|
const getZoneStatsData = `-- name: GetZoneStatsData :many
|
||||||
SELECT zc.date, z.name, zc.ip_version, count_active, count_registered, netspeed_active
|
SELECT zc.date, z.name, zc.ip_version, count_active, count_registered, netspeed_active
|
||||||
FROM zone_server_counts zc USE INDEX (date_idx)
|
FROM zone_server_counts zc USE INDEX (date_idx)
|
||||||
|
|||||||
16
ntpdb/server.go
Normal file
16
ntpdb/server.go
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package ntpdb
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
func (s *Server) DeletionAge(dur time.Duration) bool {
|
||||||
|
if !s.DeletionOn.Valid {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if dur > 0 {
|
||||||
|
dur = dur * -1
|
||||||
|
}
|
||||||
|
if s.DeletionOn.Time.Before(time.Now().Add(dur)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
@@ -3,8 +3,7 @@ package ntpdb
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"log/slog"
|
"go.ntppool.org/common/logger"
|
||||||
|
|
||||||
"go.ntppool.org/common/tracing"
|
"go.ntppool.org/common/tracing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -17,6 +16,7 @@ type ZoneStat struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetZoneStats(ctx context.Context, q Querier) (*ZoneStats, error) {
|
func GetZoneStats(ctx context.Context, q Querier) (*ZoneStats, error) {
|
||||||
|
log := logger.Setup()
|
||||||
ctx, span := tracing.Tracer().Start(ctx, "GetZoneStats")
|
ctx, span := tracing.Tracer().Start(ctx, "GetZoneStats")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ func GetZoneStats(ctx context.Context, q Querier) (*ZoneStats, error) {
|
|||||||
data := ZoneStats{}
|
data := ZoneStats{}
|
||||||
for name, cc := range ccs {
|
for name, cc := range ccs {
|
||||||
|
|
||||||
slog.Info("zone stats cc", "name", name)
|
log.InfoContext(ctx, "zone stats cc", "name", name)
|
||||||
|
|
||||||
cc.PercentTotal.V4 = (100 / total4) * float64(cc.Netspeed4)
|
cc.PercentTotal.V4 = (100 / total4) * float64(cc.Netspeed4)
|
||||||
cc.PercentTotal.V6 = (100 / total6) * float64(cc.Netspeed6)
|
cc.PercentTotal.V6 = (100 / total6) * float64(cc.Netspeed6)
|
||||||
|
|||||||
59
query.sql
59
query.sql
@@ -35,4 +35,61 @@ WHERE
|
|||||||
AND in_pool = 1
|
AND in_pool = 1
|
||||||
AND netspeed > 0
|
AND netspeed > 0
|
||||||
GROUP BY z.name)
|
GROUP BY z.name)
|
||||||
AS server_netspeed
|
AS server_netspeed;
|
||||||
|
|
||||||
|
-- name: GetServerByID :one
|
||||||
|
select * from servers
|
||||||
|
where
|
||||||
|
id = ?;
|
||||||
|
|
||||||
|
-- name: GetServerByIP :one
|
||||||
|
select * from servers
|
||||||
|
where
|
||||||
|
ip = sqlc.arg(ip);
|
||||||
|
|
||||||
|
-- name: GetMonitorByName :one
|
||||||
|
select * from monitors
|
||||||
|
where
|
||||||
|
tls_name like sqlc.arg('tls_name')
|
||||||
|
order by id
|
||||||
|
limit 1;
|
||||||
|
|
||||||
|
-- name: GetMonitorsByID :many
|
||||||
|
select * from monitors
|
||||||
|
where id in (sqlc.slice('MonitorIDs'));
|
||||||
|
|
||||||
|
-- name: GetServerScores :many
|
||||||
|
select
|
||||||
|
m.id, m.name, m.tls_name, m.location, m.type,
|
||||||
|
ss.score_raw, ss.score_ts, ss.status
|
||||||
|
from server_scores ss
|
||||||
|
inner join monitors m
|
||||||
|
on (m.id=ss.monitor_id)
|
||||||
|
where
|
||||||
|
server_id = ? AND
|
||||||
|
monitor_id in (sqlc.slice('MonitorIDs'));
|
||||||
|
|
||||||
|
-- name: GetServerLogScores :many
|
||||||
|
select * from log_scores
|
||||||
|
where
|
||||||
|
server_id = ?
|
||||||
|
order by ts desc
|
||||||
|
limit ?;
|
||||||
|
|
||||||
|
-- name: GetServerLogScoresByMonitorID :many
|
||||||
|
select * from log_scores
|
||||||
|
where
|
||||||
|
server_id = ? AND
|
||||||
|
monitor_id = ?
|
||||||
|
order by ts desc
|
||||||
|
limit ?;
|
||||||
|
|
||||||
|
-- name: GetZoneByName :one
|
||||||
|
select * from zones
|
||||||
|
where
|
||||||
|
name = sqlc.arg(name);
|
||||||
|
|
||||||
|
-- name: GetZoneCounts :many
|
||||||
|
select * from zone_server_counts
|
||||||
|
where zone_id = ?
|
||||||
|
order by date;
|
||||||
|
|||||||
115
schema.sql
115
schema.sql
@@ -1,4 +1,4 @@
|
|||||||
-- MariaDB dump 10.19 Distrib 10.6.12-MariaDB, for Linux (x86_64)
|
-- MariaDB dump 10.19 Distrib 10.11.6-MariaDB, for Linux (x86_64)
|
||||||
--
|
--
|
||||||
-- Host: ntp-db-mysql-master.ntpdb.svc.cluster.local Database: askntp
|
-- Host: ntp-db-mysql-master.ntpdb.svc.cluster.local Database: askntp
|
||||||
-- ------------------------------------------------------
|
-- ------------------------------------------------------
|
||||||
@@ -100,6 +100,7 @@ CREATE TABLE `accounts` (
|
|||||||
`organization_url` varchar(150) DEFAULT NULL,
|
`organization_url` varchar(150) DEFAULT NULL,
|
||||||
`public_profile` tinyint(1) NOT NULL DEFAULT '0',
|
`public_profile` tinyint(1) NOT NULL DEFAULT '0',
|
||||||
`url_slug` varchar(150) DEFAULT NULL,
|
`url_slug` varchar(150) DEFAULT NULL,
|
||||||
|
`flags` varchar(4096) NOT NULL DEFAULT '{}',
|
||||||
`created_on` datetime NOT NULL,
|
`created_on` datetime NOT NULL,
|
||||||
`modified_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
`modified_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
`stripe_customer_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
|
`stripe_customer_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
|
||||||
@@ -229,24 +230,6 @@ CREATE TABLE `log_scores_archive_status` (
|
|||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
|
||||||
-- Table structure for table `log_status`
|
|
||||||
--
|
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `log_status`;
|
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
||||||
/*!40101 SET character_set_client = utf8 */;
|
|
||||||
CREATE TABLE `log_status` (
|
|
||||||
`server_id` int(10) unsigned NOT NULL,
|
|
||||||
`last_check` datetime NOT NULL,
|
|
||||||
`ts_archived` datetime NOT NULL,
|
|
||||||
PRIMARY KEY (`server_id`),
|
|
||||||
KEY `log_scores_server_ts_idx` (`server_id`,`last_check`),
|
|
||||||
KEY `last_check_idx` (`last_check`),
|
|
||||||
CONSTRAINT `log_status_server` FOREIGN KEY (`server_id`) REFERENCES `servers` (`id`) ON DELETE CASCADE
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `logs`
|
-- Table structure for table `logs`
|
||||||
--
|
--
|
||||||
@@ -306,6 +289,7 @@ CREATE TABLE `monitors` (
|
|||||||
UNIQUE KEY `monitors_tls_name` (`tls_name`),
|
UNIQUE KEY `monitors_tls_name` (`tls_name`),
|
||||||
KEY `monitors_user_id` (`user_id`),
|
KEY `monitors_user_id` (`user_id`),
|
||||||
KEY `monitors_account_fk` (`account_id`),
|
KEY `monitors_account_fk` (`account_id`),
|
||||||
|
KEY `type_status` (`type`,`status`),
|
||||||
CONSTRAINT `monitors_account_fk` FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`),
|
CONSTRAINT `monitors_account_fk` FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`),
|
||||||
CONSTRAINT `monitors_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
|
CONSTRAINT `monitors_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
@@ -356,7 +340,7 @@ DROP TABLE IF EXISTS `scorer_status`;
|
|||||||
CREATE TABLE `scorer_status` (
|
CREATE TABLE `scorer_status` (
|
||||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`scorer_id` int(10) unsigned NOT NULL,
|
`scorer_id` int(10) unsigned NOT NULL,
|
||||||
`log_score_id` bigint(20) unsigned DEFAULT NULL,
|
`log_score_id` bigint(20) unsigned NOT NULL,
|
||||||
`modified_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
`modified_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
KEY `scorer_log_score_id` (`log_score_id`),
|
KEY `scorer_log_score_id` (`log_score_id`),
|
||||||
@@ -447,6 +431,56 @@ CREATE TABLE `server_urls` (
|
|||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `server_verifications`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `server_verifications`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
|
CREATE TABLE `server_verifications` (
|
||||||
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`server_id` int(10) unsigned NOT NULL,
|
||||||
|
`user_id` int(10) unsigned DEFAULT NULL,
|
||||||
|
`user_ip` varchar(45) NOT NULL DEFAULT '',
|
||||||
|
`indirect_ip` varchar(45) NOT NULL DEFAULT '',
|
||||||
|
`verified_on` datetime DEFAULT NULL,
|
||||||
|
`token` varchar(36) DEFAULT NULL,
|
||||||
|
`created_on` datetime NOT NULL,
|
||||||
|
`modified_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `server` (`server_id`),
|
||||||
|
UNIQUE KEY `token` (`token`),
|
||||||
|
KEY `server_verifications_ibfk_2` (`user_id`),
|
||||||
|
CONSTRAINT `server_verifications_ibfk_1` FOREIGN KEY (`server_id`) REFERENCES `servers` (`id`) ON DELETE CASCADE,
|
||||||
|
CONSTRAINT `server_verifications_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `server_verifications_history`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `server_verifications_history`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
|
CREATE TABLE `server_verifications_history` (
|
||||||
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`server_id` int(10) unsigned NOT NULL,
|
||||||
|
`user_id` int(10) unsigned DEFAULT NULL,
|
||||||
|
`user_ip` varchar(45) NOT NULL DEFAULT '',
|
||||||
|
`indirect_ip` varchar(45) NOT NULL DEFAULT '',
|
||||||
|
`verified_on` datetime DEFAULT NULL,
|
||||||
|
`created_on` datetime NOT NULL,
|
||||||
|
`modified_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `server_verifications_history_ibfk_1` (`server_id`),
|
||||||
|
KEY `server_verifications_history_ibfk_2` (`user_id`),
|
||||||
|
CONSTRAINT `server_verifications_history_ibfk_1` FOREIGN KEY (`server_id`) REFERENCES `servers` (`id`) ON DELETE CASCADE,
|
||||||
|
CONSTRAINT `server_verifications_history_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `server_zones`
|
-- Table structure for table `server_zones`
|
||||||
--
|
--
|
||||||
@@ -475,18 +509,20 @@ CREATE TABLE `servers` (
|
|||||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`ip` varchar(40) NOT NULL,
|
`ip` varchar(40) NOT NULL,
|
||||||
`ip_version` enum('v4','v6') NOT NULL DEFAULT 'v4',
|
`ip_version` enum('v4','v6') NOT NULL DEFAULT 'v4',
|
||||||
`user_id` int(10) unsigned NOT NULL,
|
`user_id` int(10) unsigned DEFAULT NULL,
|
||||||
`account_id` int(10) unsigned DEFAULT NULL,
|
`account_id` int(10) unsigned DEFAULT NULL,
|
||||||
`hostname` varchar(255) DEFAULT NULL,
|
`hostname` varchar(255) DEFAULT NULL,
|
||||||
`stratum` tinyint(3) unsigned DEFAULT NULL,
|
`stratum` tinyint(3) unsigned DEFAULT NULL,
|
||||||
`in_pool` tinyint(3) unsigned NOT NULL DEFAULT '0',
|
`in_pool` tinyint(3) unsigned NOT NULL DEFAULT '0',
|
||||||
`in_server_list` tinyint(3) unsigned NOT NULL DEFAULT '0',
|
`in_server_list` tinyint(3) unsigned NOT NULL DEFAULT '0',
|
||||||
`netspeed` mediumint(8) unsigned NOT NULL DEFAULT '1000',
|
`netspeed` int(10) unsigned NOT NULL DEFAULT '10000',
|
||||||
|
`netspeed_target` int(10) unsigned NOT NULL DEFAULT '10000',
|
||||||
`created_on` datetime NOT NULL,
|
`created_on` datetime NOT NULL,
|
||||||
`updated_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
`updated_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
`score_ts` datetime DEFAULT NULL,
|
`score_ts` datetime DEFAULT NULL,
|
||||||
`score_raw` double NOT NULL DEFAULT '0',
|
`score_raw` double NOT NULL DEFAULT '0',
|
||||||
`deletion_on` date DEFAULT NULL,
|
`deletion_on` date DEFAULT NULL,
|
||||||
|
`flags` varchar(4096) NOT NULL DEFAULT '{}',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `ip` (`ip`),
|
UNIQUE KEY `ip` (`ip`),
|
||||||
KEY `admin` (`user_id`),
|
KEY `admin` (`user_id`),
|
||||||
@@ -526,8 +562,8 @@ DROP TABLE IF EXISTS `system_settings`;
|
|||||||
/*!40101 SET character_set_client = utf8 */;
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
CREATE TABLE `system_settings` (
|
CREATE TABLE `system_settings` (
|
||||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`key` varchar(255) DEFAULT NULL,
|
`key` varchar(255) NOT NULL,
|
||||||
`value` text,
|
`value` text NOT NULL,
|
||||||
`created_on` datetime NOT NULL,
|
`created_on` datetime NOT NULL,
|
||||||
`modified_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
`modified_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
@@ -568,6 +604,8 @@ CREATE TABLE `user_identities` (
|
|||||||
`provider` varchar(255) NOT NULL,
|
`provider` varchar(255) NOT NULL,
|
||||||
`data` text,
|
`data` text,
|
||||||
`email` varchar(255) DEFAULT NULL,
|
`email` varchar(255) DEFAULT NULL,
|
||||||
|
`created_on` datetime NOT NULL DEFAULT '2003-01-27 00:00:00',
|
||||||
|
`modified_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `profile_id` (`profile_id`),
|
UNIQUE KEY `profile_id` (`profile_id`),
|
||||||
KEY `user_identities_user_id` (`user_id`),
|
KEY `user_identities_user_id` (`user_id`),
|
||||||
@@ -593,6 +631,28 @@ CREATE TABLE `user_privileges` (
|
|||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `user_tasks`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `user_tasks`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
|
CREATE TABLE `user_tasks` (
|
||||||
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`user_id` int(10) unsigned DEFAULT NULL,
|
||||||
|
`task` enum('download','delete') NOT NULL,
|
||||||
|
`status` text NOT NULL,
|
||||||
|
`traceid` varchar(32) NOT NULL DEFAULT '',
|
||||||
|
`execute_on` datetime DEFAULT NULL,
|
||||||
|
`created_on` datetime NOT NULL,
|
||||||
|
`modified_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `user_tasks_user_fk` (`user_id`),
|
||||||
|
CONSTRAINT `user_tasks_user_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `users`
|
-- Table structure for table `users`
|
||||||
--
|
--
|
||||||
@@ -606,6 +666,7 @@ CREATE TABLE `users` (
|
|||||||
`name` varchar(255) DEFAULT NULL,
|
`name` varchar(255) DEFAULT NULL,
|
||||||
`username` varchar(40) DEFAULT NULL,
|
`username` varchar(40) DEFAULT NULL,
|
||||||
`public_profile` tinyint(1) NOT NULL DEFAULT '0',
|
`public_profile` tinyint(1) NOT NULL DEFAULT '0',
|
||||||
|
`deletion_on` datetime DEFAULT NULL,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `email` (`email`),
|
UNIQUE KEY `email` (`email`),
|
||||||
UNIQUE KEY `username` (`username`)
|
UNIQUE KEY `username` (`username`)
|
||||||
@@ -628,6 +689,7 @@ CREATE TABLE `vendor_zones` (
|
|||||||
`client_type` enum('ntp','sntp','legacy') NOT NULL DEFAULT 'sntp',
|
`client_type` enum('ntp','sntp','legacy') NOT NULL DEFAULT 'sntp',
|
||||||
`contact_information` text,
|
`contact_information` text,
|
||||||
`request_information` text,
|
`request_information` text,
|
||||||
|
`device_information` text,
|
||||||
`device_count` int(10) unsigned DEFAULT NULL,
|
`device_count` int(10) unsigned DEFAULT NULL,
|
||||||
`opensource` tinyint(1) NOT NULL DEFAULT '0',
|
`opensource` tinyint(1) NOT NULL DEFAULT '0',
|
||||||
`opensource_info` text,
|
`opensource_info` text,
|
||||||
@@ -665,6 +727,7 @@ CREATE TABLE `zone_server_counts` (
|
|||||||
`netspeed_active` int(10) unsigned NOT NULL,
|
`netspeed_active` int(10) unsigned NOT NULL,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `zone_date` (`zone_id`,`date`,`ip_version`),
|
UNIQUE KEY `zone_date` (`zone_id`,`date`,`ip_version`),
|
||||||
|
KEY `date_idx` (`date`,`zone_id`),
|
||||||
CONSTRAINT `zone_server_counts` FOREIGN KEY (`zone_id`) REFERENCES `zones` (`id`) ON DELETE CASCADE
|
CONSTRAINT `zone_server_counts` FOREIGN KEY (`zone_id`) REFERENCES `zones` (`id`) ON DELETE CASCADE
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
@@ -701,7 +764,7 @@ CREATE TABLE `zones` (
|
|||||||
/*!50001 SET character_set_results = utf8mb4 */;
|
/*!50001 SET character_set_results = utf8mb4 */;
|
||||||
/*!50001 SET collation_connection = utf8mb4_general_ci */;
|
/*!50001 SET collation_connection = utf8mb4_general_ci */;
|
||||||
/*!50001 CREATE ALGORITHM=UNDEFINED */
|
/*!50001 CREATE ALGORITHM=UNDEFINED */
|
||||||
/*!50013 DEFINER=`askntp`@`10.%` SQL SECURITY DEFINER */
|
/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */
|
||||||
/*!50001 VIEW `monitors_data` AS select `monitors`.`id` AS `id`,`monitors`.`account_id` AS `account_id`,`monitors`.`type` AS `type`,if((`monitors`.`type` = 'score'),`monitors`.`name`,substring_index(`monitors`.`tls_name`,'.',1)) AS `name`,`monitors`.`ip` AS `ip`,`monitors`.`ip_version` AS `ip_version`,`monitors`.`status` AS `status`,`monitors`.`client_version` AS `client_version`,`monitors`.`last_seen` AS `last_seen`,`monitors`.`last_submit` AS `last_submit` from `monitors` where (not((`monitors`.`tls_name` like '%.system'))) */;
|
/*!50001 VIEW `monitors_data` AS select `monitors`.`id` AS `id`,`monitors`.`account_id` AS `account_id`,`monitors`.`type` AS `type`,if((`monitors`.`type` = 'score'),`monitors`.`name`,substring_index(`monitors`.`tls_name`,'.',1)) AS `name`,`monitors`.`ip` AS `ip`,`monitors`.`ip_version` AS `ip_version`,`monitors`.`status` AS `status`,`monitors`.`client_version` AS `client_version`,`monitors`.`last_seen` AS `last_seen`,`monitors`.`last_submit` AS `last_submit` from `monitors` where (not((`monitors`.`tls_name` like '%.system'))) */;
|
||||||
/*!50001 SET character_set_client = @saved_cs_client */;
|
/*!50001 SET character_set_client = @saved_cs_client */;
|
||||||
/*!50001 SET character_set_results = @saved_cs_results */;
|
/*!50001 SET character_set_results = @saved_cs_results */;
|
||||||
@@ -716,4 +779,4 @@ CREATE TABLE `zones` (
|
|||||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||||
|
|
||||||
-- Dump completed on 2023-05-03 5:59:38
|
-- Dump completed on 2024-03-04 4:03:49
|
||||||
|
|||||||
@@ -2,7 +2,16 @@
|
|||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
go install github.com/goreleaser/goreleaser@v1.21.2
|
go install github.com/goreleaser/goreleaser@v1.24.0
|
||||||
|
|
||||||
|
if [ ! -z "${harbor_username:-}" ]; then
|
||||||
|
DOCKER_FILE=~/.docker/config.json
|
||||||
|
if [ ! -e $DOCKER_FILE ]; then
|
||||||
|
mkdir -p ~/.docker/
|
||||||
|
export harbor_auth=`cat /dev/null | jq -s -r '[ env.harbor_username, env.harbor_password ] | join(":") | @base64'`
|
||||||
|
echo '{"auths":{"harbor.ntppool.org":{"auth":""}}}' | jq '.auths["harbor.ntppool.org"].auth=env.harbor_auth' > $DOCKER_FILE
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
DRONE_TAG=${DRONE_TAG-""}
|
DRONE_TAG=${DRONE_TAG-""}
|
||||||
|
|
||||||
@@ -12,4 +21,4 @@ if [ -z "$DRONE_TAG" ]; then
|
|||||||
is_snapshot="--snapshot"
|
is_snapshot="--snapshot"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
goreleaser release $is_snapshot -p 6 --skip-publish
|
goreleaser release $is_snapshot -p 6 --skip=publish
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log/slog"
|
"database/sql"
|
||||||
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
|
|
||||||
"go.ntppool.org/common/logger"
|
"go.ntppool.org/common/logger"
|
||||||
@@ -22,26 +24,30 @@ const pointSymbol = "‱"
|
|||||||
|
|
||||||
func (srv *Server) dnsAnswers(c echo.Context) error {
|
func (srv *Server) dnsAnswers(c echo.Context) error {
|
||||||
log := logger.Setup()
|
log := logger.Setup()
|
||||||
ctx := c.Request().Context()
|
ctx, span := tracing.Tracer().Start(c.Request().Context(), "dnsanswers")
|
||||||
|
|
||||||
ctx, span := tracing.Tracer().Start(ctx, "dnsanswers")
|
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
c.Response().Header().Set("Cache-Control", "max-age=20")
|
// for errors and 404s, a shorter cache time
|
||||||
|
c.Response().Header().Set("Cache-Control", "public,max-age=300")
|
||||||
|
|
||||||
// conn, err := srv.chConn(ctx)
|
// conn, err := srv.chConn(ctx)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// slog.Error("could not connect to clickhouse", "err", err)
|
// log.Error("could not connect to clickhouse", "err", err)
|
||||||
// return c.String(http.StatusInternalServerError, "clickhouse error")
|
// return c.String(http.StatusInternalServerError, "clickhouse error")
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
log = log.With("server_param", c.Param("server"))
|
||||||
|
span.SetAttributes(attribute.String("server_param", c.Param("server")))
|
||||||
|
|
||||||
ip, err := netip.ParseAddr(c.Param("server"))
|
ip, err := netip.ParseAddr(c.Param("server"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn("could not parse server parameter", "server", c.Param("server"), "err", err)
|
log.Warn("could not parse server parameter", "server", c.Param("server"), "err", err)
|
||||||
return c.NoContent(http.StatusNotFound)
|
return c.NoContent(http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ip.String() != c.Param("server") || len(c.QueryString()) > 0 {
|
if ip.String() != c.Param("server") || len(c.QueryString()) > 0 {
|
||||||
|
// better URLs are forever
|
||||||
|
c.Response().Header().Set("Cache-Control", "public,max-age=10400")
|
||||||
return c.Redirect(http.StatusPermanentRedirect, "https://www.ntppool.org/api/data/server/dns/answers/"+ip.String())
|
return c.Redirect(http.StatusPermanentRedirect, "https://www.ntppool.org/api/data/server/dns/answers/"+ip.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,20 +59,24 @@ func (srv *Server) dnsAnswers(c echo.Context) error {
|
|||||||
queryGroup.Go(func() error {
|
queryGroup.Go(func() error {
|
||||||
var err error
|
var err error
|
||||||
q := ntpdb.NewWrappedQuerier(ntpdb.New(srv.db))
|
q := ntpdb.NewWrappedQuerier(ntpdb.New(srv.db))
|
||||||
zoneStats, err = q.GetZoneStatsV2(ctx, ip.String())
|
|
||||||
if err != nil {
|
|
||||||
slog.Error("GetZoneStatsV2", "err", err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if zoneStats == nil {
|
|
||||||
slog.Info("didn't get zoneStats")
|
|
||||||
}
|
|
||||||
|
|
||||||
serverNetspeed, err = q.GetServerNetspeed(ctx, ip.String())
|
serverNetspeed, err = q.GetServerNetspeed(ctx, ip.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("GetServerNetspeed", "err", err)
|
if !errors.Is(err, sql.ErrNoRows) {
|
||||||
|
log.Error("GetServerNetspeed", "err", err)
|
||||||
|
}
|
||||||
|
return err // this will return if the server doesn't exist
|
||||||
|
}
|
||||||
|
|
||||||
|
zoneStats, err = q.GetZoneStatsV2(ctx, ip.String())
|
||||||
|
if err != nil {
|
||||||
|
// if we had a netspeed we expect rows here, too.
|
||||||
|
log.Error("GetZoneStatsV2", "err", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if zoneStats == nil {
|
||||||
|
log.Warn("didn't get zoneStats")
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@@ -77,9 +87,9 @@ func (srv *Server) dnsAnswers(c echo.Context) error {
|
|||||||
|
|
||||||
queryGroup.Go(func() error {
|
queryGroup.Go(func() error {
|
||||||
var err error
|
var err error
|
||||||
serverData, err = srv.ch.ServerAnswerCounts(c.Request().Context(), ip.String(), days)
|
serverData, err = srv.ch.ServerAnswerCounts(ctx, ip.String(), days)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("ServerUserCCData", "err", err)
|
log.Error("ServerUserCCData", "err", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@@ -95,16 +105,19 @@ func (srv *Server) dnsAnswers(c echo.Context) error {
|
|||||||
qtype = "AAAA"
|
qtype = "AAAA"
|
||||||
}
|
}
|
||||||
|
|
||||||
totalData, err = srv.ch.AnswerTotals(c.Request().Context(), qtype, days)
|
totalData, err = srv.ch.AnswerTotals(ctx, qtype, days)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("AnswerTotals", "err", err)
|
log.Error("AnswerTotals", "err", err)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
|
|
||||||
err = queryGroup.Wait()
|
err = queryGroup.Wait()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("query error", "err", err)
|
if errors.Is(err, sql.ErrNoRows) {
|
||||||
|
return c.String(http.StatusNotFound, "Not found")
|
||||||
|
}
|
||||||
|
log.Error("query error", "err", err)
|
||||||
return c.String(http.StatusInternalServerError, err.Error())
|
return c.String(http.StatusInternalServerError, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +129,7 @@ func (srv *Server) dnsAnswers(c echo.Context) error {
|
|||||||
zn = ""
|
zn = ""
|
||||||
}
|
}
|
||||||
zoneTotals[zn] = z.NetspeedActive // binary.BigEndian.Uint64(...)
|
zoneTotals[zn] = z.NetspeedActive // binary.BigEndian.Uint64(...)
|
||||||
// slog.Info("zone netspeed", "cc", z.ZoneName, "speed", z.NetspeedActive)
|
// log.Info("zone netspeed", "cc", z.ZoneName, "speed", z.NetspeedActive)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, cc := range serverData {
|
for _, cc := range serverData {
|
||||||
@@ -126,9 +139,15 @@ func (srv *Server) dnsAnswers(c echo.Context) error {
|
|||||||
totalName = "uk"
|
totalName = "uk"
|
||||||
}
|
}
|
||||||
if zt, ok := zoneTotals[totalName]; ok {
|
if zt, ok := zoneTotals[totalName]; ok {
|
||||||
|
// log.InfoContext(ctx, "netspeed data", "pointBasis", pointBasis, "zt", zt, "server netspeed", serverNetspeed)
|
||||||
|
if zt == 0 {
|
||||||
|
// if the recorded netspeed for the zone was zero, assume it's at least
|
||||||
|
// this servers worth instead. Otherwise the Netspeed gets to be 'infinite'.
|
||||||
|
zt = int32(serverNetspeed)
|
||||||
|
}
|
||||||
cc.Netspeed = (pointBasis / float64(zt)) * float64(serverNetspeed)
|
cc.Netspeed = (pointBasis / float64(zt)) * float64(serverNetspeed)
|
||||||
}
|
}
|
||||||
// log.Info("points", "cc", cc.CC, "points", cc.Points)
|
// log.DebugContext(ctx, "points", "cc", cc.CC, "points", cc.Points)
|
||||||
}
|
}
|
||||||
|
|
||||||
r := struct {
|
r := struct {
|
||||||
@@ -141,7 +160,7 @@ func (srv *Server) dnsAnswers(c echo.Context) error {
|
|||||||
// Totals: totalData,
|
// Totals: totalData,
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Response().Header().Set("Cache-Control", "max-age=1800")
|
c.Response().Header().Set("Cache-Control", "public,max-age=1800")
|
||||||
|
|
||||||
return c.JSONPretty(http.StatusOK, r, "")
|
return c.JSONPretty(http.StatusOK, r, "")
|
||||||
|
|
||||||
|
|||||||
46
server/functions.go
Normal file
46
server/functions.go
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"database/sql"
|
||||||
|
"errors"
|
||||||
|
"net/netip"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"go.ntppool.org/common/logger"
|
||||||
|
"go.ntppool.org/common/tracing"
|
||||||
|
"go.ntppool.org/data-api/ntpdb"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (srv *Server) FindServer(ctx context.Context, serverID string) (ntpdb.Server, error) {
|
||||||
|
log := logger.Setup()
|
||||||
|
ctx, span := tracing.Tracer().Start(ctx, "FindServer")
|
||||||
|
defer span.End()
|
||||||
|
q := ntpdb.NewWrappedQuerier(ntpdb.New(srv.db))
|
||||||
|
|
||||||
|
var serverData ntpdb.Server
|
||||||
|
var dberr error
|
||||||
|
if id, err := strconv.Atoi(serverID); id > 0 && err == nil {
|
||||||
|
serverData, dberr = q.GetServerByID(ctx, uint32(id))
|
||||||
|
} else {
|
||||||
|
ip, err := netip.ParseAddr(serverID)
|
||||||
|
if err != nil || !ip.IsValid() {
|
||||||
|
return ntpdb.Server{}, nil // 404 error
|
||||||
|
}
|
||||||
|
serverData, dberr = q.GetServerByIP(ctx, ip.String())
|
||||||
|
}
|
||||||
|
if dberr != nil {
|
||||||
|
if !errors.Is(dberr, sql.ErrNoRows) {
|
||||||
|
log.Error("could not query server id", "err", dberr)
|
||||||
|
return serverData, dberr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if serverData.ID == 0 || (serverData.DeletionOn.Valid && serverData.DeletionOn.Time.Before(time.Now().Add(-1*time.Hour*24*30*24))) {
|
||||||
|
// no data and no error to produce 404 errors
|
||||||
|
return ntpdb.Server{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return serverData, nil
|
||||||
|
}
|
||||||
149
server/graph_image.go
Normal file
149
server/graph_image.go
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"net/http/httptrace"
|
||||||
|
"net/url"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/hashicorp/go-retryablehttp"
|
||||||
|
"github.com/labstack/echo/v4"
|
||||||
|
"go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace"
|
||||||
|
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
|
||||||
|
"go.opentelemetry.io/otel/attribute"
|
||||||
|
"go.opentelemetry.io/otel/trace"
|
||||||
|
|
||||||
|
"go.ntppool.org/common/logger"
|
||||||
|
"go.ntppool.org/common/tracing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (srv *Server) graphImage(c echo.Context) error {
|
||||||
|
log := logger.Setup()
|
||||||
|
ctx, span := tracing.Tracer().Start(c.Request().Context(), "graphImage")
|
||||||
|
defer span.End()
|
||||||
|
|
||||||
|
// cache errors briefly
|
||||||
|
c.Response().Header().Set("Cache-Control", "public,max-age=240")
|
||||||
|
|
||||||
|
serverID := c.Param("server")
|
||||||
|
imageType := c.Param("type")
|
||||||
|
log = log.With("serverID", serverID).With("type", imageType)
|
||||||
|
log.InfoContext(ctx, "graph parameters")
|
||||||
|
|
||||||
|
span.SetAttributes(attribute.String("url.server_parameter", serverID))
|
||||||
|
|
||||||
|
if imageType != "offset.png" {
|
||||||
|
return c.String(http.StatusNotFound, "invalid image name")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(c.QueryString()) > 0 {
|
||||||
|
// people breaking the varnish cache by adding query parameters
|
||||||
|
redirectURL := c.Request().URL
|
||||||
|
redirectURL.RawQuery = ""
|
||||||
|
log.InfoContext(ctx, "redirecting", "url", redirectURL.String())
|
||||||
|
return c.Redirect(308, redirectURL.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
serverData, err := srv.FindServer(ctx, serverID)
|
||||||
|
if err != nil {
|
||||||
|
span.RecordError(err)
|
||||||
|
return c.String(http.StatusInternalServerError, "server error")
|
||||||
|
}
|
||||||
|
if serverData.ID == 0 {
|
||||||
|
return c.String(http.StatusNotFound, "not found")
|
||||||
|
}
|
||||||
|
if serverData.DeletionAge(7 * 24 * time.Hour) {
|
||||||
|
return c.String(http.StatusNotFound, "not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
if serverData.Ip != serverID {
|
||||||
|
return c.Redirect(308, fmt.Sprintf("/graph/%s/offset.png", serverData.Ip))
|
||||||
|
}
|
||||||
|
|
||||||
|
contentType, data, err := srv.fetchGraph(ctx, serverData.Ip)
|
||||||
|
if err != nil {
|
||||||
|
span.RecordError(err)
|
||||||
|
return c.String(http.StatusInternalServerError, "server error")
|
||||||
|
|
||||||
|
}
|
||||||
|
if len(data) == 0 {
|
||||||
|
span.RecordError(fmt.Errorf("no data"))
|
||||||
|
return c.String(http.StatusInternalServerError, "server error")
|
||||||
|
}
|
||||||
|
|
||||||
|
ttl := 1800
|
||||||
|
c.Response().Header().Set("Cache-Control",
|
||||||
|
fmt.Sprintf("public,max-age=%d,s-maxage=%.0f",
|
||||||
|
ttl, float64(ttl)*0.75,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
return c.Blob(http.StatusOK, contentType, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (srv *Server) fetchGraph(ctx context.Context, serverIP string) (string, []byte, error) {
|
||||||
|
log := logger.Setup()
|
||||||
|
ctx, span := tracing.Tracer().Start(ctx, "fetchGraph")
|
||||||
|
defer span.End()
|
||||||
|
|
||||||
|
// q := url.Values{}
|
||||||
|
// q.Set("graph_only", "1")
|
||||||
|
// pagePath := srv.config.WebURL("/scores/" + serverIP, q)
|
||||||
|
|
||||||
|
serviceHost := os.Getenv("screensnap_service")
|
||||||
|
if len(serviceHost) == 0 {
|
||||||
|
serviceHost = "screensnap"
|
||||||
|
}
|
||||||
|
|
||||||
|
reqURL := url.URL{
|
||||||
|
Scheme: "http",
|
||||||
|
Host: serviceHost,
|
||||||
|
Path: fmt.Sprintf("/image/offset/%s", serverIP),
|
||||||
|
}
|
||||||
|
|
||||||
|
client := retryablehttp.NewClient()
|
||||||
|
client.Logger = log
|
||||||
|
client.HTTPClient.Transport = otelhttp.NewTransport(
|
||||||
|
client.HTTPClient.Transport,
|
||||||
|
otelhttp.WithClientTrace(func(ctx context.Context) *httptrace.ClientTrace {
|
||||||
|
return otelhttptrace.NewClientTrace(ctx)
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
|
req, err := retryablehttp.NewRequestWithContext(ctx, "GET", reqURL.String(), nil)
|
||||||
|
if err != nil {
|
||||||
|
return "", nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return "", nil, err
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
if resp.StatusCode != 200 {
|
||||||
|
span.AddEvent("unexpected status code", trace.WithAttributes(attribute.Int64("http.status", int64(resp.StatusCode))))
|
||||||
|
return "text/plain", nil, fmt.Errorf("upstream error %d", resp.StatusCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
b, err := io.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
return "", nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp.Header.Get("Content-Type"), b, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// # my $data = JSON::encode_json(
|
||||||
|
// # { url => $url->as_string(),
|
||||||
|
// # timeout => 10,
|
||||||
|
// # viewport => "501x233",
|
||||||
|
// # height => 233,
|
||||||
|
// # resource_timeout => 5,
|
||||||
|
// # wait => 0.5,
|
||||||
|
// # scale_method => "vector",
|
||||||
|
// # }
|
||||||
|
// # );
|
||||||
387
server/history.go
Normal file
387
server/history.go
Normal file
@@ -0,0 +1,387 @@
|
|||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"database/sql"
|
||||||
|
"encoding/csv"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"math"
|
||||||
|
"net/http"
|
||||||
|
"net/netip"
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/labstack/echo/v4"
|
||||||
|
"go.ntppool.org/common/logger"
|
||||||
|
"go.ntppool.org/common/tracing"
|
||||||
|
"go.ntppool.org/data-api/logscores"
|
||||||
|
"go.ntppool.org/data-api/ntpdb"
|
||||||
|
)
|
||||||
|
|
||||||
|
type historyMode uint8
|
||||||
|
|
||||||
|
const (
|
||||||
|
historyModeUnknown historyMode = iota
|
||||||
|
historyModeLog
|
||||||
|
historyModeJSON
|
||||||
|
historyModeMonitor
|
||||||
|
)
|
||||||
|
|
||||||
|
func paramHistoryMode(s string) historyMode {
|
||||||
|
switch s {
|
||||||
|
case "log":
|
||||||
|
return historyModeLog
|
||||||
|
case "json":
|
||||||
|
return historyModeJSON
|
||||||
|
case "monitor":
|
||||||
|
return historyModeMonitor
|
||||||
|
default:
|
||||||
|
return historyModeUnknown
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type historyParameters struct {
|
||||||
|
limit int
|
||||||
|
monitorID int
|
||||||
|
server ntpdb.Server
|
||||||
|
since time.Time
|
||||||
|
fullHistory bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (srv *Server) getHistoryParameters(ctx context.Context, c echo.Context) (historyParameters, error) {
|
||||||
|
log := logger.FromContext(ctx)
|
||||||
|
|
||||||
|
p := historyParameters{}
|
||||||
|
|
||||||
|
limit := 0
|
||||||
|
if limitParam, err := strconv.Atoi(c.QueryParam("limit")); err == nil {
|
||||||
|
limit = limitParam
|
||||||
|
} else {
|
||||||
|
limit = 100
|
||||||
|
}
|
||||||
|
|
||||||
|
if limit > 10000 {
|
||||||
|
limit = 10000
|
||||||
|
}
|
||||||
|
p.limit = limit
|
||||||
|
|
||||||
|
q := ntpdb.NewWrappedQuerier(ntpdb.New(srv.db))
|
||||||
|
|
||||||
|
monitorParam := c.QueryParam("monitor")
|
||||||
|
|
||||||
|
var monitorID uint32 = 0
|
||||||
|
switch monitorParam {
|
||||||
|
case "":
|
||||||
|
name := "recentmedian.scores.ntp.dev"
|
||||||
|
monitor, err := q.GetMonitorByName(ctx, sql.NullString{Valid: true, String: name})
|
||||||
|
if err != nil {
|
||||||
|
log.Warn("could not find monitor", "name", name, "err", err)
|
||||||
|
}
|
||||||
|
monitorID = monitor.ID
|
||||||
|
case "*":
|
||||||
|
monitorID = 0 // don't filter on monitor ID
|
||||||
|
default:
|
||||||
|
mID, err := strconv.ParseUint(monitorParam, 10, 32)
|
||||||
|
if err == nil {
|
||||||
|
monitorID = uint32(mID)
|
||||||
|
} else {
|
||||||
|
// only accept the name prefix; no wildcards; trust the database
|
||||||
|
// to filter out any other crazy
|
||||||
|
if strings.ContainsAny(monitorParam, "_%. \t\n") {
|
||||||
|
return p, echo.NewHTTPError(http.StatusNotFound, "monitor not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
monitorParam = monitorParam + ".%"
|
||||||
|
monitor, err := q.GetMonitorByName(ctx, sql.NullString{Valid: true, String: monitorParam})
|
||||||
|
if err != nil {
|
||||||
|
log.Warn("could not find monitor", "name", monitorParam, "err", err)
|
||||||
|
return p, echo.NewHTTPError(http.StatusNotFound, "monitor not found")
|
||||||
|
}
|
||||||
|
monitorID = monitor.ID
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
p.monitorID = int(monitorID)
|
||||||
|
log.DebugContext(ctx, "monitor param", "monitor", monitorID)
|
||||||
|
|
||||||
|
since, _ := strconv.ParseInt(c.QueryParam("since"), 10, 64) // defaults to 0 so don't care if it parses
|
||||||
|
if since > 0 {
|
||||||
|
p.since = time.Unix(since, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
clientIP, err := netip.ParseAddr(c.RealIP())
|
||||||
|
if err != nil {
|
||||||
|
return p, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// log.DebugContext(ctx, "client ip", "client_ip", clientIP.String())
|
||||||
|
|
||||||
|
if clientIP.IsPrivate() || clientIP.IsLoopback() { // don't allow this through the ingress or CDN
|
||||||
|
if fullParam := c.QueryParam("full_history"); len(fullParam) > 0 {
|
||||||
|
if t, _ := strconv.ParseBool(fullParam); t {
|
||||||
|
p.fullHistory = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return p, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (srv *Server) getHistoryMySQL(ctx context.Context, _ echo.Context, p historyParameters) (*logscores.LogScoreHistory, error) {
|
||||||
|
ls, err := logscores.GetHistoryMySQL(ctx, srv.db, p.server.ID, uint32(p.monitorID), p.since, p.limit)
|
||||||
|
return ls, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (srv *Server) history(c echo.Context) error {
|
||||||
|
log := logger.Setup()
|
||||||
|
ctx, span := tracing.Tracer().Start(c.Request().Context(), "history")
|
||||||
|
defer span.End()
|
||||||
|
|
||||||
|
// just cache for a short time by default
|
||||||
|
c.Response().Header().Set("Cache-Control", "public,max-age=240")
|
||||||
|
|
||||||
|
mode := paramHistoryMode(c.Param("mode"))
|
||||||
|
if mode == historyModeUnknown {
|
||||||
|
return echo.NewHTTPError(http.StatusNotFound, "invalid mode")
|
||||||
|
}
|
||||||
|
|
||||||
|
p, err := srv.getHistoryParameters(ctx, c)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("get history parameters", "err", err)
|
||||||
|
span.RecordError(err)
|
||||||
|
return echo.NewHTTPError(http.StatusInternalServerError, "internal error")
|
||||||
|
}
|
||||||
|
|
||||||
|
server, err := srv.FindServer(ctx, c.Param("server"))
|
||||||
|
if err != nil {
|
||||||
|
log.Error("find server", "err", err)
|
||||||
|
span.RecordError(err)
|
||||||
|
return echo.NewHTTPError(http.StatusInternalServerError, "internal error")
|
||||||
|
}
|
||||||
|
if server.DeletionAge(30 * 24 * time.Hour) {
|
||||||
|
span.AddEvent("server deleted")
|
||||||
|
return echo.NewHTTPError(http.StatusNotFound, "server not found")
|
||||||
|
}
|
||||||
|
if server.ID == 0 {
|
||||||
|
span.AddEvent("server not found")
|
||||||
|
return echo.NewHTTPError(http.StatusNotFound, "server not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
p.server = server
|
||||||
|
|
||||||
|
var history *logscores.LogScoreHistory
|
||||||
|
|
||||||
|
sourceParam := c.QueryParam("source")
|
||||||
|
switch sourceParam {
|
||||||
|
case "m":
|
||||||
|
case "c":
|
||||||
|
default:
|
||||||
|
sourceParam = os.Getenv("default_source")
|
||||||
|
}
|
||||||
|
|
||||||
|
if sourceParam == "m" {
|
||||||
|
history, err = srv.getHistoryMySQL(ctx, c, p)
|
||||||
|
} else {
|
||||||
|
history, err = logscores.GetHistoryClickHouse(ctx, srv.ch, srv.db, p.server.ID, uint32(p.monitorID), p.since, p.limit, p.fullHistory)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
var httpError *echo.HTTPError
|
||||||
|
if errors.As(err, &httpError) {
|
||||||
|
if httpError.Code >= 500 {
|
||||||
|
log.Error("get history", "err", err)
|
||||||
|
span.RecordError(err)
|
||||||
|
}
|
||||||
|
return httpError
|
||||||
|
} else {
|
||||||
|
log.Error("get history", "err", err)
|
||||||
|
span.RecordError(err)
|
||||||
|
return c.String(http.StatusInternalServerError, "internal error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
c.Response().Header().Set("Access-Control-Allow-Origin", "*")
|
||||||
|
|
||||||
|
switch mode {
|
||||||
|
case historyModeLog:
|
||||||
|
return srv.historyCSV(ctx, c, history)
|
||||||
|
case historyModeJSON:
|
||||||
|
return srv.historyJSON(ctx, c, server, history)
|
||||||
|
default:
|
||||||
|
return c.String(http.StatusNotFound, "not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (srv *Server) historyJSON(ctx context.Context, c echo.Context, server ntpdb.Server, history *logscores.LogScoreHistory) error {
|
||||||
|
log := logger.Setup()
|
||||||
|
ctx, span := tracing.Tracer().Start(ctx, "history.json")
|
||||||
|
defer span.End()
|
||||||
|
|
||||||
|
type ScoresEntry struct {
|
||||||
|
TS int64 `json:"ts"`
|
||||||
|
Offset *float64 `json:"offset,omitempty"`
|
||||||
|
Step float64 `json:"step"`
|
||||||
|
Score float64 `json:"score"`
|
||||||
|
MonitorID int `json:"monitor_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type MonitorEntry struct {
|
||||||
|
ID uint32 `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Ts string `json:"ts"`
|
||||||
|
Score float64 `json:"score"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
}
|
||||||
|
res := struct {
|
||||||
|
History []ScoresEntry `json:"history"`
|
||||||
|
Monitors []MonitorEntry `json:"monitors"`
|
||||||
|
Server struct {
|
||||||
|
IP string `json:"ip"`
|
||||||
|
} `json:"server"`
|
||||||
|
}{
|
||||||
|
History: make([]ScoresEntry, len(history.LogScores)),
|
||||||
|
}
|
||||||
|
res.Server.IP = server.Ip
|
||||||
|
|
||||||
|
// log.InfoContext(ctx, "monitor id list", "ids", history.MonitorIDs)
|
||||||
|
|
||||||
|
monitorIDs := []uint32{}
|
||||||
|
for k := range history.Monitors {
|
||||||
|
monitorIDs = append(monitorIDs, uint32(k))
|
||||||
|
}
|
||||||
|
|
||||||
|
q := ntpdb.NewWrappedQuerier(ntpdb.New(srv.db))
|
||||||
|
logScoreMonitors, err := q.GetServerScores(ctx,
|
||||||
|
ntpdb.GetServerScoresParams{
|
||||||
|
MonitorIDs: monitorIDs,
|
||||||
|
ServerID: server.ID,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
span.RecordError(err)
|
||||||
|
log.ErrorContext(ctx, "GetServerScores", "err", err)
|
||||||
|
return c.String(http.StatusInternalServerError, "err")
|
||||||
|
}
|
||||||
|
|
||||||
|
// log.InfoContext(ctx, "got logScoreMonitors", "count", len(logScoreMonitors))
|
||||||
|
|
||||||
|
for _, lsm := range logScoreMonitors {
|
||||||
|
score := math.Round(lsm.ScoreRaw*10) / 10 // round to one decimal
|
||||||
|
|
||||||
|
tempMon := ntpdb.Monitor{
|
||||||
|
Name: lsm.Name,
|
||||||
|
TlsName: lsm.TlsName,
|
||||||
|
Location: lsm.Location,
|
||||||
|
ID: lsm.ID,
|
||||||
|
}
|
||||||
|
name := tempMon.DisplayName()
|
||||||
|
|
||||||
|
me := MonitorEntry{
|
||||||
|
ID: lsm.ID,
|
||||||
|
Name: name,
|
||||||
|
Type: string(lsm.Type),
|
||||||
|
Ts: lsm.ScoreTs.Time.Format(time.RFC3339),
|
||||||
|
Score: score,
|
||||||
|
Status: string(lsm.Status),
|
||||||
|
}
|
||||||
|
res.Monitors = append(res.Monitors, me)
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, ls := range history.LogScores {
|
||||||
|
x := float64(1000000000000)
|
||||||
|
score := math.Round(ls.Score*x) / x
|
||||||
|
res.History[i] = ScoresEntry{
|
||||||
|
TS: ls.Ts.Unix(),
|
||||||
|
MonitorID: int(ls.MonitorID.Int32),
|
||||||
|
Step: ls.Step,
|
||||||
|
Score: score,
|
||||||
|
}
|
||||||
|
if ls.Offset.Valid {
|
||||||
|
offset := ls.Offset.Float64
|
||||||
|
res.History[i].Offset = &offset
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(history.LogScores) == 0 ||
|
||||||
|
history.LogScores[len(history.LogScores)-1].Ts.After(time.Now().Add(-8*time.Hour)) {
|
||||||
|
// cache for longer if data hasn't updated for a while
|
||||||
|
c.Request().Header.Set("Cache-Control", "s-maxage=3600,max-age=1800")
|
||||||
|
} else {
|
||||||
|
c.Request().Header.Set("Cache-Control", "s-maxage=300,max-age=240")
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.JSON(http.StatusOK, res)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (srv *Server) historyCSV(ctx context.Context, c echo.Context, history *logscores.LogScoreHistory) error {
|
||||||
|
log := logger.Setup()
|
||||||
|
ctx, span := tracing.Tracer().Start(ctx, "history.csv")
|
||||||
|
b := bytes.NewBuffer([]byte{})
|
||||||
|
w := csv.NewWriter(b)
|
||||||
|
|
||||||
|
ff := func(f float64) string {
|
||||||
|
s := fmt.Sprintf("%.9f", f)
|
||||||
|
s = strings.TrimRight(s, "0")
|
||||||
|
s = strings.TrimRight(s, ".")
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
w.Write([]string{"ts_epoch", "ts", "offset", "step", "score", "monitor_id", "monitor_name", "leap", "error"})
|
||||||
|
for _, l := range history.LogScores {
|
||||||
|
// log.Debug("csv line", "id", l.ID, "n", i)
|
||||||
|
|
||||||
|
var offset string
|
||||||
|
if l.Offset.Valid {
|
||||||
|
offset = ff(l.Offset.Float64)
|
||||||
|
}
|
||||||
|
|
||||||
|
step := ff(l.Step)
|
||||||
|
score := ff(l.Score)
|
||||||
|
var monName string
|
||||||
|
if l.MonitorID.Valid {
|
||||||
|
monName = history.Monitors[int(l.MonitorID.Int32)]
|
||||||
|
}
|
||||||
|
var leap string
|
||||||
|
if l.Attributes.Leap != 0 {
|
||||||
|
leap = fmt.Sprintf("%d", l.Attributes.Leap)
|
||||||
|
}
|
||||||
|
|
||||||
|
err := w.Write([]string{
|
||||||
|
strconv.Itoa(int(l.Ts.Unix())),
|
||||||
|
// l.Ts.Format(time.RFC3339),
|
||||||
|
l.Ts.Format("2006-01-02 15:04:05"),
|
||||||
|
offset,
|
||||||
|
step,
|
||||||
|
score,
|
||||||
|
fmt.Sprintf("%d", l.MonitorID.Int32),
|
||||||
|
monName,
|
||||||
|
leap,
|
||||||
|
l.Attributes.Error,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
log.Warn("csv encoding error", "ls_id", l.ID, "err", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
w.Flush()
|
||||||
|
if err := w.Error(); err != nil {
|
||||||
|
log.ErrorContext(ctx, "could not flush csv", "err", err)
|
||||||
|
span.End()
|
||||||
|
return c.String(http.StatusInternalServerError, "csv error")
|
||||||
|
}
|
||||||
|
|
||||||
|
// log.Info("entries", "count", len(history.LogScores), "out_bytes", b.Len())
|
||||||
|
|
||||||
|
c.Response().Header().Set("Cache-Control", "s-maxage=150,max-age=120")
|
||||||
|
c.Response().Header().Set("Content-Disposition", "inline")
|
||||||
|
// Chrome and Firefox force-download text/csv files, so use text/plain
|
||||||
|
// https://bugs.chromium.org/p/chromium/issues/detail?id=152911
|
||||||
|
return c.Blob(http.StatusOK, "text/plain", b.Bytes())
|
||||||
|
|
||||||
|
}
|
||||||
158
server/server.go
158
server/server.go
@@ -3,20 +3,30 @@ package server
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log/slog"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"golang.org/x/sync/errgroup"
|
||||||
|
|
||||||
|
"github.com/labstack/echo-contrib/echoprometheus"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"github.com/labstack/echo/v4/middleware"
|
"github.com/labstack/echo/v4/middleware"
|
||||||
|
slogecho "github.com/samber/slog-echo"
|
||||||
|
|
||||||
"go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho"
|
"go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho"
|
||||||
otrace "go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"golang.org/x/sync/errgroup"
|
"go.opentelemetry.io/otel/trace"
|
||||||
|
|
||||||
"go.ntppool.org/common/health"
|
"go.ntppool.org/common/health"
|
||||||
"go.ntppool.org/common/logger"
|
"go.ntppool.org/common/logger"
|
||||||
"go.ntppool.org/common/metricsserver"
|
"go.ntppool.org/common/metricsserver"
|
||||||
"go.ntppool.org/common/tracing"
|
"go.ntppool.org/common/tracing"
|
||||||
|
"go.ntppool.org/common/version"
|
||||||
|
"go.ntppool.org/common/xff/fastlyxff"
|
||||||
|
|
||||||
|
"go.ntppool.org/api/config"
|
||||||
|
|
||||||
chdb "go.ntppool.org/data-api/chdb"
|
chdb "go.ntppool.org/data-api/chdb"
|
||||||
"go.ntppool.org/data-api/ntpdb"
|
"go.ntppool.org/data-api/ntpdb"
|
||||||
@@ -25,14 +35,17 @@ import (
|
|||||||
type Server struct {
|
type Server struct {
|
||||||
db *sql.DB
|
db *sql.DB
|
||||||
ch *chdb.ClickHouse
|
ch *chdb.ClickHouse
|
||||||
|
config *config.Config
|
||||||
|
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
|
|
||||||
metrics *metricsserver.Metrics
|
metrics *metricsserver.Metrics
|
||||||
tracer otrace.Tracer
|
tpShutdown []tracing.TpShutdownFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewServer(ctx context.Context, configFile string) (*Server, error) {
|
func NewServer(ctx context.Context, configFile string) (*Server, error) {
|
||||||
|
log := logger.Setup()
|
||||||
|
|
||||||
ch, err := chdb.New(ctx, configFile)
|
ch, err := chdb.New(ctx, configFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("clickhouse open: %w", err)
|
return nil, fmt.Errorf("clickhouse open: %w", err)
|
||||||
@@ -42,34 +55,43 @@ func NewServer(ctx context.Context, configFile string) (*Server, error) {
|
|||||||
return nil, fmt.Errorf("mysql open: %w", err)
|
return nil, fmt.Errorf("mysql open: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
conf := config.New()
|
||||||
|
if !conf.Valid() {
|
||||||
|
log.Error("invalid ntppool config")
|
||||||
|
}
|
||||||
|
|
||||||
srv := &Server{
|
srv := &Server{
|
||||||
ch: ch,
|
ch: ch,
|
||||||
db: db,
|
db: db,
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
|
config: conf,
|
||||||
metrics: metricsserver.New(),
|
metrics: metricsserver.New(),
|
||||||
}
|
}
|
||||||
|
|
||||||
err = tracing.InitTracer(ctx, &tracing.TracerConfig{
|
tpShutdown, err := tracing.InitTracer(ctx, &tracing.TracerConfig{
|
||||||
ServiceName: "data-api",
|
ServiceName: "data-api",
|
||||||
Environment: "",
|
Environment: conf.DeploymentMode(),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
srv.tracer = tracing.Tracer()
|
srv.tpShutdown = append(srv.tpShutdown, tpShutdown)
|
||||||
return srv, nil
|
return srv, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (srv *Server) Run() error {
|
func (srv *Server) Run() error {
|
||||||
log := logger.Setup()
|
log := logger.Setup()
|
||||||
|
|
||||||
|
ntpconf := config.New()
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(srv.ctx)
|
ctx, cancel := context.WithCancel(srv.ctx)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
g, _ := errgroup.WithContext(ctx)
|
g, _ := errgroup.WithContext(ctx)
|
||||||
|
|
||||||
g.Go(func() error {
|
g.Go(func() error {
|
||||||
|
version.RegisterMetric("dataapi", srv.metrics.Registry())
|
||||||
return srv.metrics.ListenAndServe(ctx, 9020)
|
return srv.metrics.ListenAndServe(ctx, 9020)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -78,9 +100,70 @@ func (srv *Server) Run() error {
|
|||||||
})
|
})
|
||||||
|
|
||||||
e := echo.New()
|
e := echo.New()
|
||||||
e.Use(otelecho.Middleware("data-api"))
|
srv.tpShutdown = append(srv.tpShutdown, e.Shutdown)
|
||||||
|
|
||||||
e.Use(middleware.Logger())
|
trustOptions := []echo.TrustOption{
|
||||||
|
echo.TrustLoopback(true),
|
||||||
|
echo.TrustLinkLocal(false),
|
||||||
|
echo.TrustPrivateNet(true),
|
||||||
|
}
|
||||||
|
|
||||||
|
if fileName := os.Getenv("FASTLY_IPS"); len(fileName) > 0 {
|
||||||
|
xff, err := fastlyxff.New(fileName)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
cdnTrustRanges, err := xff.EchoTrustOption()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
trustOptions = append(trustOptions, cdnTrustRanges...)
|
||||||
|
} else {
|
||||||
|
log.Warn("Fastly IPs not configured (FASTLY_IPS)")
|
||||||
|
}
|
||||||
|
|
||||||
|
e.IPExtractor = echo.ExtractIPFromXFFHeader(trustOptions...)
|
||||||
|
|
||||||
|
e.Use(echoprometheus.NewMiddlewareWithConfig(echoprometheus.MiddlewareConfig{
|
||||||
|
Registerer: srv.metrics.Registry(),
|
||||||
|
}))
|
||||||
|
e.Use(otelecho.Middleware("data-api"))
|
||||||
|
e.Use(slogecho.NewWithConfig(log,
|
||||||
|
slogecho.Config{
|
||||||
|
WithTraceID: false, // done by logger already
|
||||||
|
// WithRequestHeader: true,
|
||||||
|
},
|
||||||
|
))
|
||||||
|
|
||||||
|
e.Use(
|
||||||
|
func(next echo.HandlerFunc) echo.HandlerFunc {
|
||||||
|
return func(c echo.Context) error {
|
||||||
|
request := c.Request()
|
||||||
|
|
||||||
|
span := trace.SpanFromContext(request.Context())
|
||||||
|
span.SetAttributes(attribute.String("http.real_ip", c.RealIP()))
|
||||||
|
|
||||||
|
// since the Go library (temporarily?) isn't including this
|
||||||
|
span.SetAttributes(attribute.String("url.path", c.Request().RequestURI))
|
||||||
|
if q := c.QueryString(); len(q) > 0 {
|
||||||
|
span.SetAttributes(attribute.String("url.query", q))
|
||||||
|
}
|
||||||
|
|
||||||
|
c.Response().Header().Set("Traceparent", span.SpanContext().TraceID().String())
|
||||||
|
|
||||||
|
return next(c)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
e.Use(func(next echo.HandlerFunc) echo.HandlerFunc {
|
||||||
|
vinfo := version.VersionInfo()
|
||||||
|
v := "data-api/" + vinfo.Version + "+" + vinfo.GitRevShort
|
||||||
|
return func(c echo.Context) error {
|
||||||
|
c.Response().Header().Set(echo.HeaderServer, v)
|
||||||
|
return next(c)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
|
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
|
||||||
AllowOrigins: []string{
|
AllowOrigins: []string{
|
||||||
@@ -92,13 +175,45 @@ func (srv *Server) Run() error {
|
|||||||
AllowHeaders: []string{echo.HeaderOrigin, echo.HeaderContentType, echo.HeaderAccept},
|
AllowHeaders: []string{echo.HeaderOrigin, echo.HeaderContentType, echo.HeaderAccept},
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
e.Use(middleware.RecoverWithConfig(middleware.RecoverConfig{
|
||||||
|
LogErrorFunc: func(c echo.Context, err error, stack []byte) error {
|
||||||
|
log.ErrorContext(c.Request().Context(), err.Error(), "stack", string(stack))
|
||||||
|
fmt.Println(string(stack))
|
||||||
|
return err
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
|
||||||
e.GET("/hello", func(c echo.Context) error {
|
e.GET("/hello", func(c echo.Context) error {
|
||||||
|
ctx := c.Request().Context()
|
||||||
|
ctx, span := tracing.Tracer().Start(ctx, "hello")
|
||||||
|
defer span.End()
|
||||||
|
|
||||||
|
log.InfoContext(ctx, "hello log")
|
||||||
return c.String(http.StatusOK, "Hello")
|
return c.String(http.StatusOK, "Hello")
|
||||||
})
|
})
|
||||||
|
|
||||||
e.GET("/api/usercc", srv.userCountryData)
|
e.GET("/api/usercc", srv.userCountryData)
|
||||||
|
|
||||||
e.GET("/api/server/dns/answers/:server", srv.dnsAnswers)
|
e.GET("/api/server/dns/answers/:server", srv.dnsAnswers)
|
||||||
|
e.GET("/api/server/scores/:server/:mode", srv.history)
|
||||||
|
|
||||||
|
if len(ntpconf.WebHostname()) > 0 {
|
||||||
|
e.POST("/api/server/scores/:server/:mode", func(c echo.Context) error {
|
||||||
|
// POST requests used to work, so make them not error out
|
||||||
|
mode := c.Param("mode")
|
||||||
|
server := c.Param("server")
|
||||||
|
query := c.Request().URL.Query()
|
||||||
|
return c.Redirect(
|
||||||
|
http.StatusSeeOther,
|
||||||
|
ntpconf.WebURL(
|
||||||
|
fmt.Sprintf("/scores/%s/%s", server, mode),
|
||||||
|
&query,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
e.GET("/graph/:server/:type", srv.graphImage)
|
||||||
|
|
||||||
|
e.GET("/api/zone/counts/:zone_name", srv.zoneCounts)
|
||||||
|
|
||||||
g.Go(func() error {
|
g.Go(func() error {
|
||||||
return e.Start(":8030")
|
return e.Start(":8030")
|
||||||
@@ -107,23 +222,36 @@ func (srv *Server) Run() error {
|
|||||||
return g.Wait()
|
return g.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (srv *Server) userCountryData(c echo.Context) error {
|
func (srv *Server) Shutdown(ctx context.Context) error {
|
||||||
|
logger.Setup().Info("Shutting down")
|
||||||
|
errs := []error{}
|
||||||
|
for _, fn := range srv.tpShutdown {
|
||||||
|
err := fn(ctx)
|
||||||
|
if err != nil {
|
||||||
|
errs = append(errs, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return errors.Join(errs...)
|
||||||
|
}
|
||||||
|
|
||||||
ctx := c.Request().Context()
|
func (srv *Server) userCountryData(c echo.Context) error {
|
||||||
|
log := logger.Setup()
|
||||||
|
ctx, span := tracing.Tracer().Start(c.Request().Context(), "userCountryData")
|
||||||
|
defer span.End()
|
||||||
|
|
||||||
q := ntpdb.NewWrappedQuerier(ntpdb.New(srv.db))
|
q := ntpdb.NewWrappedQuerier(ntpdb.New(srv.db))
|
||||||
zoneStats, err := ntpdb.GetZoneStats(ctx, q)
|
zoneStats, err := ntpdb.GetZoneStats(ctx, q)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("GetZoneStats", "err", err)
|
log.ErrorContext(ctx, "GetZoneStats", "err", err)
|
||||||
return c.String(http.StatusInternalServerError, err.Error())
|
return c.String(http.StatusInternalServerError, err.Error())
|
||||||
}
|
}
|
||||||
if zoneStats == nil {
|
if zoneStats == nil {
|
||||||
slog.Info("didn't get zoneStats")
|
log.InfoContext(ctx, "didn't get zoneStats")
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := srv.ch.UserCountryData(c.Request().Context())
|
data, err := srv.ch.UserCountryData(c.Request().Context())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("UserCountryData", "err", err)
|
log.ErrorContext(ctx, "UserCountryData", "err", err)
|
||||||
return c.String(http.StatusInternalServerError, err.Error())
|
return c.String(http.StatusInternalServerError, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
148
server/zones.go
Normal file
148
server/zones.go
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"database/sql"
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/labstack/echo/v4"
|
||||||
|
"go.ntppool.org/common/logger"
|
||||||
|
"go.ntppool.org/common/tracing"
|
||||||
|
"go.ntppool.org/data-api/ntpdb"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (srv *Server) zoneCounts(c echo.Context) error {
|
||||||
|
log := logger.Setup()
|
||||||
|
ctx, span := tracing.Tracer().Start(c.Request().Context(), "zoneCounts")
|
||||||
|
defer span.End()
|
||||||
|
|
||||||
|
// just cache for a short time by default
|
||||||
|
c.Response().Header().Set("Cache-Control", "public,max-age=240")
|
||||||
|
c.Response().Header().Set("Access-Control-Allow-Origin", "*")
|
||||||
|
c.Response().Header().Del("Vary")
|
||||||
|
|
||||||
|
q := ntpdb.NewWrappedQuerier(ntpdb.New(srv.db))
|
||||||
|
|
||||||
|
zone, err := q.GetZoneByName(ctx, c.Param("zone_name"))
|
||||||
|
if err != nil || zone.ID == 0 {
|
||||||
|
if errors.Is(err, sql.ErrNoRows) {
|
||||||
|
return c.String(http.StatusNotFound, "Not found")
|
||||||
|
}
|
||||||
|
log.ErrorContext(ctx, "could not query for zone", "err", err)
|
||||||
|
span.RecordError(err)
|
||||||
|
return echo.NewHTTPError(http.StatusInternalServerError, "internal error")
|
||||||
|
}
|
||||||
|
|
||||||
|
counts, err := q.GetZoneCounts(ctx, zone.ID)
|
||||||
|
if err != nil {
|
||||||
|
if !errors.Is(err, sql.ErrNoRows) {
|
||||||
|
log.ErrorContext(ctx, "get counts", "err", err)
|
||||||
|
span.RecordError(err)
|
||||||
|
return c.String(http.StatusInternalServerError, "internal error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type historyEntry struct {
|
||||||
|
D string `json:"d"` // date
|
||||||
|
Ts int `json:"ts"` // epoch timestamp
|
||||||
|
Rc int `json:"rc"` // count registered
|
||||||
|
Ac int `json:"ac"` // count active
|
||||||
|
W int `json:"w"` // netspeed active
|
||||||
|
Iv string `json:"iv"` // ip version
|
||||||
|
}
|
||||||
|
|
||||||
|
rv := struct {
|
||||||
|
History []historyEntry `json:"history"`
|
||||||
|
}{}
|
||||||
|
|
||||||
|
skipCount := 0.0
|
||||||
|
limit := 0
|
||||||
|
|
||||||
|
if limitParam := c.QueryParam("limit"); len(limitParam) > 0 {
|
||||||
|
if limitInt, err := strconv.Atoi(limitParam); err == nil && limitInt > 0 {
|
||||||
|
limit = limitInt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var mostRecentDate int64 = -1
|
||||||
|
if limit > 0 {
|
||||||
|
count := 0
|
||||||
|
dates := map[int64]bool{}
|
||||||
|
for _, c := range counts {
|
||||||
|
ep := c.Date.Unix()
|
||||||
|
if _, ok := dates[ep]; !ok {
|
||||||
|
count++
|
||||||
|
dates[ep] = true
|
||||||
|
mostRecentDate = ep
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if limit < count {
|
||||||
|
if limit > 1 {
|
||||||
|
skipCount = float64(count) / float64(limit-1)
|
||||||
|
} else {
|
||||||
|
// skip everything and use the special logic that we always include the most recent date
|
||||||
|
skipCount = float64(count) + 1
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.DebugContext(ctx, "mod", "count", count, "limit", limit, "mod", count%limit, "skipCount", skipCount)
|
||||||
|
// log.Info("limit plan", "date count", count, "limit", limit, "skipCount", skipCount)
|
||||||
|
}
|
||||||
|
|
||||||
|
toSkip := 0.0
|
||||||
|
if limit == 1 {
|
||||||
|
toSkip = skipCount // we just want to look for the last entry
|
||||||
|
}
|
||||||
|
lastDate := int64(0)
|
||||||
|
lastSkip := int64(0)
|
||||||
|
skipThreshold := 0.5
|
||||||
|
for _, c := range counts {
|
||||||
|
cDate := c.Date.Unix()
|
||||||
|
if (toSkip <= skipThreshold && cDate != lastSkip) ||
|
||||||
|
lastDate == cDate ||
|
||||||
|
mostRecentDate == cDate {
|
||||||
|
// log.Info("adding date", "date", c.Date.Format(time.DateOnly))
|
||||||
|
rv.History = append(rv.History, historyEntry{
|
||||||
|
D: c.Date.Format(time.DateOnly),
|
||||||
|
Ts: int(cDate),
|
||||||
|
Ac: int(c.CountActive),
|
||||||
|
Rc: int(c.CountRegistered),
|
||||||
|
W: int(c.NetspeedActive),
|
||||||
|
Iv: string(c.IpVersion),
|
||||||
|
})
|
||||||
|
lastDate = cDate
|
||||||
|
} else {
|
||||||
|
// log.Info("skipping date", "date", c.Date.Format(time.DateOnly))
|
||||||
|
if lastSkip == cDate {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
toSkip--
|
||||||
|
lastSkip = cDate
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if toSkip <= skipThreshold && skipCount > 0 {
|
||||||
|
toSkip += skipCount
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if limit > 0 {
|
||||||
|
count := 0
|
||||||
|
dates := map[int]bool{}
|
||||||
|
for _, c := range rv.History {
|
||||||
|
ep := c.Ts
|
||||||
|
if _, ok := dates[ep]; !ok {
|
||||||
|
count++
|
||||||
|
dates[ep] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.DebugContext(ctx, "result counts", "skipCount", skipCount, "limit", limit, "got", count)
|
||||||
|
}
|
||||||
|
|
||||||
|
c.Response().Header().Set("Cache-Control", "s-maxage=28800, max-age=7200")
|
||||||
|
return c.JSON(http.StatusOK, rv)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -12,6 +12,10 @@ sql:
|
|||||||
omit_unused_structs: true
|
omit_unused_structs: true
|
||||||
emit_interface: true
|
emit_interface: true
|
||||||
# emit_all_enum_values: true
|
# emit_all_enum_values: true
|
||||||
|
rename:
|
||||||
|
servers.Ip: IP
|
||||||
overrides:
|
overrides:
|
||||||
|
- column: log_scores.attributes
|
||||||
|
go_type: go.ntppool.org/common/types.LogScoreAttributes
|
||||||
- column: "server_netspeed.netspeed_active"
|
- column: "server_netspeed.netspeed_active"
|
||||||
go_type: "uint64"
|
go_type: "uint64"
|
||||||
|
|||||||
Reference in New Issue
Block a user