style: format Go code with gofumpt
Apply consistent formatting to Go source files using gofumpt as required by pre-commit guidelines.
This commit is contained in:
@@ -24,15 +24,16 @@ type ServerTotals map[string]uint64
|
|||||||
func (s ServerQueries) Len() int {
|
func (s ServerQueries) Len() int {
|
||||||
return len(s)
|
return len(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s ServerQueries) Swap(i, j int) {
|
func (s ServerQueries) Swap(i, j int) {
|
||||||
s[i], s[j] = s[j], s[i]
|
s[i], s[j] = s[j], s[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s ServerQueries) Less(i, j int) bool {
|
func (s ServerQueries) Less(i, j int) bool {
|
||||||
return s[i].Count > s[j].Count
|
return s[i].Count > s[j].Count
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *ClickHouse) ServerAnswerCounts(ctx context.Context, serverIP string, days int) (ServerQueries, error) {
|
func (d *ClickHouse) ServerAnswerCounts(ctx context.Context, serverIP string, days int) (ServerQueries, error) {
|
||||||
|
|
||||||
ctx, span := tracing.Tracer().Start(ctx, "ServerAnswerCounts")
|
ctx, span := tracing.Tracer().Start(ctx, "ServerAnswerCounts")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
|
|||||||
@@ -214,7 +214,9 @@ func (d *ClickHouse) LogscoresTimeRange(ctx context.Context, serverID, monitorID
|
|||||||
"sample_rows", func() []map[string]interface{} {
|
"sample_rows", func() []map[string]interface{} {
|
||||||
samples := make([]map[string]interface{}, 0, 3)
|
samples := make([]map[string]interface{}, 0, 3)
|
||||||
for i, row := range rv {
|
for i, row := range rv {
|
||||||
if i >= 3 { break }
|
if i >= 3 {
|
||||||
|
break
|
||||||
|
}
|
||||||
samples = append(samples, map[string]interface{}{
|
samples = append(samples, map[string]interface{}{
|
||||||
"id": row.ID,
|
"id": row.ID,
|
||||||
"monitor_id": row.MonitorID,
|
"monitor_id": row.MonitorID,
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ func NewCLI() *CLI {
|
|||||||
|
|
||||||
// RootCmd represents the base command when called without any subcommands
|
// RootCmd represents the base command when called without any subcommands
|
||||||
func (cli *CLI) rootCmd() *cobra.Command {
|
func (cli *CLI) rootCmd() *cobra.Command {
|
||||||
var cmd = &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "data-api",
|
Use: "data-api",
|
||||||
Short: "A brief description of your application",
|
Short: "A brief description of your application",
|
||||||
// Uncomment the following line if your bare application
|
// Uncomment the following line if your bare application
|
||||||
@@ -47,7 +47,6 @@ func (cli *CLI) rootCmd() *cobra.Command {
|
|||||||
// Execute adds all child commands to the root command and sets flags appropriately.
|
// Execute adds all child commands to the root command and sets flags appropriately.
|
||||||
// This is called by main.main(). It only needs to happen once to the rootCmd.
|
// This is called by main.main(). It only needs to happen once to the rootCmd.
|
||||||
func Execute() {
|
func Execute() {
|
||||||
|
|
||||||
cli := NewCLI()
|
cli := NewCLI()
|
||||||
|
|
||||||
if err := cli.root.Execute(); err != nil {
|
if err := cli.root.Execute(); err != nil {
|
||||||
@@ -57,7 +56,6 @@ func Execute() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (cli *CLI) init(cmd *cobra.Command) {
|
func (cli *CLI) init(cmd *cobra.Command) {
|
||||||
|
|
||||||
logger.Setup()
|
logger.Setup()
|
||||||
|
|
||||||
cmd.PersistentFlags().StringVar(&cfgFile, "database-config", "database.yaml", "config file (default is $HOME/.data-api.yaml)")
|
cmd.PersistentFlags().StringVar(&cfgFile, "database-config", "database.yaml", "config file (default is $HOME/.data-api.yaml)")
|
||||||
|
|||||||
@@ -18,8 +18,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (cli *CLI) serverCmd() *cobra.Command {
|
func (cli *CLI) serverCmd() *cobra.Command {
|
||||||
|
serverCmd := &cobra.Command{
|
||||||
var serverCmd = &cobra.Command{
|
|
||||||
Use: "server",
|
Use: "server",
|
||||||
Short: "server starts the API server",
|
Short: "server starts the API server",
|
||||||
Long: `starts the API server on (default) port 8000`,
|
Long: `starts the API server on (default) port 8000`,
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ func GetHistoryClickHouse(ctx context.Context, ch *chdb.ClickHouse, db *sql.DB,
|
|||||||
log.DebugContext(ctx, "GetHistoryCH", "server", serverID, "monitor", monitorID, "since", since, "count", count, "full_history", fullHistory)
|
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)
|
ls, err := ch.Logscores(ctx, int(serverID), int(monitorID), since, count, fullHistory)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorContext(ctx, "clickhouse logscores", "err", err)
|
log.ErrorContext(ctx, "clickhouse logscores", "err", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ func (d Driver) Driver() driver.Driver {
|
|||||||
|
|
||||||
func (d Driver) Connect(ctx context.Context) (driver.Conn, error) {
|
func (d Driver) Connect(ctx context.Context) (driver.Conn, error) {
|
||||||
connector, err := d.CreateConnectorFunc()
|
connector, err := d.CreateConnectorFunc()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error creating connector from function: %w", err)
|
return nil, fmt.Errorf("error creating connector from function: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,7 +145,6 @@ func (ns NullMonitorsType) Value() (driver.Value, error) {
|
|||||||
type ServerScoresStatus string
|
type ServerScoresStatus string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ServerScoresStatusNew ServerScoresStatus = "new"
|
|
||||||
ServerScoresStatusCandidate ServerScoresStatus = "candidate"
|
ServerScoresStatusCandidate ServerScoresStatus = "candidate"
|
||||||
ServerScoresStatusTesting ServerScoresStatus = "testing"
|
ServerScoresStatusTesting ServerScoresStatus = "testing"
|
||||||
ServerScoresStatusActive ServerScoresStatus = "active"
|
ServerScoresStatusActive ServerScoresStatus = "active"
|
||||||
|
|||||||
@@ -16,8 +16,10 @@ import (
|
|||||||
"go.ntppool.org/data-api/ntpdb"
|
"go.ntppool.org/data-api/ntpdb"
|
||||||
)
|
)
|
||||||
|
|
||||||
const pointBasis float64 = 10000
|
const (
|
||||||
const pointSymbol = "‱"
|
pointBasis float64 = 10000
|
||||||
|
pointSymbol = "‱"
|
||||||
|
)
|
||||||
|
|
||||||
// const pointBasis = 1000
|
// const pointBasis = 1000
|
||||||
// const pointSymbol = "‰"
|
// const pointSymbol = "‰"
|
||||||
@@ -163,5 +165,4 @@ func (srv *Server) dnsAnswers(c echo.Context) error {
|
|||||||
c.Response().Header().Set("Cache-Control", "public,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, "")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ func (srv *Server) zoneCounts(c echo.Context) error {
|
|||||||
} else {
|
} else {
|
||||||
// skip everything and use the special logic that we always include the most recent date
|
// skip everything and use the special logic that we always include the most recent date
|
||||||
skipCount = float64(count) + 1
|
skipCount = float64(count) + 1
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,5 +143,4 @@ func (srv *Server) zoneCounts(c echo.Context) error {
|
|||||||
|
|
||||||
c.Response().Header().Set("Cache-Control", "s-maxage=28800, max-age=7200")
|
c.Response().Header().Set("Cache-Control", "s-maxage=28800, max-age=7200")
|
||||||
return c.JSON(http.StatusOK, rv)
|
return c.JSON(http.StatusOK, rv)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user