diff --git a/.gitignore b/.gitignore index 0c54f47..5c93d4c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ mydb.sql client/calls/ !client/calls/.gitkeep /gordio +/stillbox /calls Session.vim *.log diff --git a/Makefile b/Makefile index 12e3fb5..86d1ac0 100644 --- a/Makefile +++ b/Makefile @@ -4,15 +4,15 @@ BUILDDATE!=date '+%Y%m%d' LDFLAGS=-ldflags="-X '${VPKG}.Version=${VER}' -X '${VPKG}.Built=${BUILDDATE}'" all: checkcalls - go build -o gordio ${GOFLAGS} ${LDFLAGS} ./cmd/gordio/ + go build -o stillbox ${GOFLAGS} ${LDFLAGS} ./cmd/stillbox/ go build -o calls ${GOFLAGS} ${LDFLAGS} ./cmd/calls/ buildpprof: - go build -o gordio-pprof ${GOFLAGS} ${LDFLAGS} -tags pprof ./cmd/gordio + go build -o stillbox-pprof ${GOFLAGS} ${LDFLAGS} -tags pprof ./cmd/stillbox clean: rm -rf client/calls/ && mkdir client/calls && touch client/calls/.gitkeep - rm -f gordio calls gordio-pprof + rm -f stillbox calls stillbox-pprof checkcalls: @test -e client/calls/index.html || make getcalls diff --git a/README.md b/README.md index ee51125..54a3c19 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # stillbox -A Golang scanner call server (`gordio`), with the Calls webapp. +A Golang scanner call server. **NOTE** If this message is still here, the database schema *initial migration* and protobuf definitions are **still subject to change**. -Once `gordio` is actually usable (but not necessarily feature-complete), I will remove this note, and start using DB migrations and +Once `stillbox` is actually usable (but not necessarily feature-complete), I will remove this note, and start using DB migrations and protobuf best practices (i.e. not changing field numbers). diff --git a/cmd/gordio/main.go b/cmd/stillbox/main.go similarity index 76% rename from cmd/gordio/main.go rename to cmd/stillbox/main.go index a3b971c..93235f1 100644 --- a/cmd/gordio/main.go +++ b/cmd/stillbox/main.go @@ -9,9 +9,9 @@ import ( "dynatron.me/x/stillbox/internal/common" "dynatron.me/x/stillbox/internal/version" - "dynatron.me/x/stillbox/pkg/gordio" - "dynatron.me/x/stillbox/pkg/gordio/admin" - "dynatron.me/x/stillbox/pkg/gordio/config" + "dynatron.me/x/stillbox/pkg/cmd/serve" + "dynatron.me/x/stillbox/pkg/cmd/admin" + "dynatron.me/x/stillbox/pkg/config" "github.com/spf13/cobra" ) @@ -20,7 +20,7 @@ func main() { log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr, TimeFormat: common.TimeFormat}) rootCmd := &cobra.Command{ - Use: gordio.AppName, + Use: common.AppName, } rootCmd.PersistentFlags().BoolP("version", "V", false, "show version") cfg := config.New(rootCmd) @@ -32,7 +32,7 @@ func main() { } } - cmds := append([]*cobra.Command{gordio.Command(cfg)}, admin.Command(cfg)...) + cmds := append([]*cobra.Command{serve.Command(cfg)}, admin.Command(cfg)...) rootCmd.AddCommand(cmds...) err := rootCmd.Execute() diff --git a/internal/common/common.go b/internal/common/common.go index 226b022..ca3b18c 100644 --- a/internal/common/common.go +++ b/internal/common/common.go @@ -7,6 +7,8 @@ import ( "github.com/spf13/cobra" ) +const AppName = "stillbox" + const ( TimeFormat = "Jan 2 15:04:05" ) diff --git a/internal/forms/forms_test.go b/internal/forms/forms_test.go index d185455..c75b839 100644 --- a/internal/forms/forms_test.go +++ b/internal/forms/forms_test.go @@ -11,8 +11,8 @@ import ( "dynatron.me/x/stillbox/internal/forms" "dynatron.me/x/stillbox/internal/jsontime" - "dynatron.me/x/stillbox/pkg/gordio/alerting" - "dynatron.me/x/stillbox/pkg/gordio/config" + "dynatron.me/x/stillbox/pkg/alerting" + "dynatron.me/x/stillbox/pkg/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/internal/version/version.go b/internal/version/version.go index 52111ec..50241f7 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -3,17 +3,19 @@ package version import ( "fmt" "runtime" + + "dynatron.me/x/stillbox/internal/common" ) var ( - Name = "gordio" + Name = common.AppName Version = "unset" Built = "unset" ) func String() string { - return fmt.Sprintf("gordio %s\nbuilt %s for %s-%s\n", - Version, Built, runtime.GOOS, runtime.GOARCH) + return fmt.Sprintf("%s %s\nbuilt %s for %s-%s\n", + Name, Version, Built, runtime.GOOS, runtime.GOARCH) } func HttpString(app string) string { diff --git a/pkg/gordio/alerting/alerting.go b/pkg/alerting/alerting.go similarity index 98% rename from pkg/gordio/alerting/alerting.go rename to pkg/alerting/alerting.go index 555c692..b70fa3e 100644 --- a/pkg/gordio/alerting/alerting.go +++ b/pkg/alerting/alerting.go @@ -12,10 +12,10 @@ import ( "time" cl "dynatron.me/x/stillbox/pkg/calls" - "dynatron.me/x/stillbox/pkg/gordio/config" - "dynatron.me/x/stillbox/pkg/gordio/database" - "dynatron.me/x/stillbox/pkg/gordio/notify" - "dynatron.me/x/stillbox/pkg/gordio/sinks" + "dynatron.me/x/stillbox/pkg/config" + "dynatron.me/x/stillbox/pkg/database" + "dynatron.me/x/stillbox/pkg/notify" + "dynatron.me/x/stillbox/pkg/sinks" "dynatron.me/x/stillbox/internal/timeseries" "dynatron.me/x/stillbox/internal/trending" diff --git a/pkg/gordio/alerting/simulate.go b/pkg/alerting/simulate.go similarity index 98% rename from pkg/gordio/alerting/simulate.go rename to pkg/alerting/simulate.go index 6863615..326b7b5 100644 --- a/pkg/gordio/alerting/simulate.go +++ b/pkg/alerting/simulate.go @@ -13,7 +13,7 @@ import ( "dynatron.me/x/stillbox/internal/jsontime" "dynatron.me/x/stillbox/internal/trending" cl "dynatron.me/x/stillbox/pkg/calls" - "dynatron.me/x/stillbox/pkg/gordio/config" + "dynatron.me/x/stillbox/pkg/config" "github.com/rs/zerolog/log" ) diff --git a/pkg/gordio/alerting/stats.go b/pkg/alerting/stats.go similarity index 96% rename from pkg/gordio/alerting/stats.go rename to pkg/alerting/stats.go index c6b1180..80d7777 100644 --- a/pkg/gordio/alerting/stats.go +++ b/pkg/alerting/stats.go @@ -8,8 +8,8 @@ import ( "time" "dynatron.me/x/stillbox/pkg/calls" - "dynatron.me/x/stillbox/pkg/gordio/config" - "dynatron.me/x/stillbox/pkg/gordio/database" + "dynatron.me/x/stillbox/pkg/config" + "dynatron.me/x/stillbox/pkg/database" "dynatron.me/x/stillbox/internal/common" "dynatron.me/x/stillbox/internal/jsontime" diff --git a/pkg/gordio/alerting/stats.html b/pkg/alerting/stats.html similarity index 100% rename from pkg/gordio/alerting/stats.html rename to pkg/alerting/stats.html diff --git a/pkg/gordio/auth/apikey.go b/pkg/auth/apikey.go similarity index 96% rename from pkg/gordio/auth/apikey.go rename to pkg/auth/apikey.go index 70cfae6..d18a303 100644 --- a/pkg/gordio/auth/apikey.go +++ b/pkg/auth/apikey.go @@ -6,7 +6,7 @@ import ( "encoding/base64" "time" - "dynatron.me/x/stillbox/pkg/gordio/database" + "dynatron.me/x/stillbox/pkg/database" "github.com/google/uuid" "github.com/rs/zerolog/log" diff --git a/pkg/gordio/auth/auth.go b/pkg/auth/auth.go similarity index 96% rename from pkg/gordio/auth/auth.go rename to pkg/auth/auth.go index c61aeaa..5184aae 100644 --- a/pkg/gordio/auth/auth.go +++ b/pkg/auth/auth.go @@ -4,7 +4,7 @@ import ( "errors" "net/http" - "dynatron.me/x/stillbox/pkg/gordio/config" + "dynatron.me/x/stillbox/pkg/config" "github.com/go-chi/jwtauth/v5" ) diff --git a/pkg/gordio/auth/jwt.go b/pkg/auth/jwt.go similarity index 99% rename from pkg/gordio/auth/jwt.go rename to pkg/auth/jwt.go index d7d6cee..ea65a92 100644 --- a/pkg/gordio/auth/jwt.go +++ b/pkg/auth/jwt.go @@ -10,7 +10,7 @@ import ( "golang.org/x/crypto/bcrypt" - "dynatron.me/x/stillbox/pkg/gordio/database" + "dynatron.me/x/stillbox/pkg/database" "github.com/go-chi/chi/v5" "github.com/go-chi/jwtauth/v5" diff --git a/pkg/calls/call.go b/pkg/calls/call.go index f9b3361..ea9c3a2 100644 --- a/pkg/calls/call.go +++ b/pkg/calls/call.go @@ -5,7 +5,7 @@ import ( "time" "dynatron.me/x/stillbox/internal/audio" - "dynatron.me/x/stillbox/pkg/gordio/auth" + "dynatron.me/x/stillbox/pkg/auth" "dynatron.me/x/stillbox/pkg/pb" "google.golang.org/protobuf/types/known/timestamppb" diff --git a/pkg/calls/filter.go b/pkg/calls/filter.go index cdeb3da..fe45cd4 100644 --- a/pkg/calls/filter.go +++ b/pkg/calls/filter.go @@ -3,7 +3,7 @@ package calls import ( "context" - "dynatron.me/x/stillbox/pkg/gordio/database" + "dynatron.me/x/stillbox/pkg/database" "dynatron.me/x/stillbox/pkg/pb" ) diff --git a/pkg/calls/talkgroups.go b/pkg/calls/talkgroups.go index b9dba95..6d554b7 100644 --- a/pkg/calls/talkgroups.go +++ b/pkg/calls/talkgroups.go @@ -6,7 +6,7 @@ import ( "sync" "time" - "dynatron.me/x/stillbox/pkg/gordio/database" + "dynatron.me/x/stillbox/pkg/database" "dynatron.me/x/stillbox/internal/ruletime" "dynatron.me/x/stillbox/internal/trending" diff --git a/pkg/gordio/admin/admin.go b/pkg/cmd/admin/admin.go similarity index 97% rename from pkg/gordio/admin/admin.go rename to pkg/cmd/admin/admin.go index bf90ac4..725c654 100644 --- a/pkg/gordio/admin/admin.go +++ b/pkg/cmd/admin/admin.go @@ -6,8 +6,8 @@ import ( "fmt" "syscall" - "dynatron.me/x/stillbox/pkg/gordio/config" - "dynatron.me/x/stillbox/pkg/gordio/database" + "dynatron.me/x/stillbox/pkg/config" + "dynatron.me/x/stillbox/pkg/database" "github.com/spf13/cobra" "golang.org/x/crypto/bcrypt" "golang.org/x/term" diff --git a/pkg/gordio/gordio.go b/pkg/cmd/serve/serve.go similarity index 83% rename from pkg/gordio/gordio.go rename to pkg/cmd/serve/serve.go index e8f2c7b..314504f 100644 --- a/pkg/gordio/gordio.go +++ b/pkg/cmd/serve/serve.go @@ -1,4 +1,4 @@ -package gordio +package serve import ( "context" @@ -6,14 +6,12 @@ import ( "os/signal" "dynatron.me/x/stillbox/internal/common" - "dynatron.me/x/stillbox/pkg/gordio/config" - "dynatron.me/x/stillbox/pkg/gordio/server" + "dynatron.me/x/stillbox/pkg/config" + "dynatron.me/x/stillbox/pkg/server" "github.com/spf13/cobra" ) -const AppName = "gordio" - type ServeOptions struct { cfg *config.Config } @@ -22,7 +20,7 @@ func Command(cfg *config.Config) *cobra.Command { opts := makeOptions(cfg) serveCmd := &cobra.Command{ Use: "serve", - Short: "starts the" + AppName + " server", + Short: "starts the" + common.AppName + " server", PersistentPreRunE: cfg.PreRunE(), RunE: common.RunE(opts), } diff --git a/pkg/gordio/config/config.go b/pkg/config/config.go similarity index 97% rename from pkg/gordio/config/config.go rename to pkg/config/config.go index 89fdc2a..2003723 100644 --- a/pkg/gordio/config/config.go +++ b/pkg/config/config.go @@ -116,7 +116,7 @@ func (c *Config) ReadConfig() error { return err } - log.Info().Str("configPath", c.configPath).Msg("read gordio config") + log.Info().Str("configPath", c.configPath).Msg("read config") return nil } diff --git a/pkg/gordio/database/calls.sql.go b/pkg/database/calls.sql.go similarity index 100% rename from pkg/gordio/database/calls.sql.go rename to pkg/database/calls.sql.go diff --git a/pkg/gordio/database/database.go b/pkg/database/database.go similarity index 97% rename from pkg/gordio/database/database.go rename to pkg/database/database.go index 591f02c..37794ff 100644 --- a/pkg/gordio/database/database.go +++ b/pkg/database/database.go @@ -5,7 +5,7 @@ import ( "errors" "strings" - "dynatron.me/x/stillbox/pkg/gordio/config" + "dynatron.me/x/stillbox/pkg/config" sqlembed "dynatron.me/x/stillbox/sql" "github.com/golang-migrate/migrate/v4" _ "github.com/golang-migrate/migrate/v4/database/pgx/v5" diff --git a/pkg/gordio/database/db.go b/pkg/database/db.go similarity index 100% rename from pkg/gordio/database/db.go rename to pkg/database/db.go diff --git a/pkg/gordio/database/models.go b/pkg/database/models.go similarity index 100% rename from pkg/gordio/database/models.go rename to pkg/database/models.go diff --git a/pkg/gordio/database/querier.go b/pkg/database/querier.go similarity index 100% rename from pkg/gordio/database/querier.go rename to pkg/database/querier.go diff --git a/pkg/gordio/database/talkgroups.sql.go b/pkg/database/talkgroups.sql.go similarity index 100% rename from pkg/gordio/database/talkgroups.sql.go rename to pkg/database/talkgroups.sql.go diff --git a/pkg/gordio/database/users.sql.go b/pkg/database/users.sql.go similarity index 100% rename from pkg/gordio/database/users.sql.go rename to pkg/database/users.sql.go diff --git a/pkg/gordio/nexus/client.go b/pkg/nexus/client.go similarity index 97% rename from pkg/gordio/nexus/client.go rename to pkg/nexus/client.go index 6366578..61ff4d8 100644 --- a/pkg/gordio/nexus/client.go +++ b/pkg/nexus/client.go @@ -9,7 +9,7 @@ import ( "dynatron.me/x/stillbox/internal/version" "dynatron.me/x/stillbox/pkg/calls" - "dynatron.me/x/stillbox/pkg/gordio/database" + "dynatron.me/x/stillbox/pkg/database" "dynatron.me/x/stillbox/pkg/pb" "github.com/rs/zerolog/log" diff --git a/pkg/gordio/nexus/commands.go b/pkg/nexus/commands.go similarity index 98% rename from pkg/gordio/nexus/commands.go rename to pkg/nexus/commands.go index b1059d6..6d5a55f 100644 --- a/pkg/gordio/nexus/commands.go +++ b/pkg/nexus/commands.go @@ -5,7 +5,7 @@ import ( "encoding/json" "dynatron.me/x/stillbox/pkg/calls" - "dynatron.me/x/stillbox/pkg/gordio/database" + "dynatron.me/x/stillbox/pkg/database" "dynatron.me/x/stillbox/pkg/pb" "github.com/jackc/pgx/v5" diff --git a/pkg/gordio/nexus/nexus.go b/pkg/nexus/nexus.go similarity index 100% rename from pkg/gordio/nexus/nexus.go rename to pkg/nexus/nexus.go diff --git a/pkg/gordio/nexus/websocket.go b/pkg/nexus/websocket.go similarity index 100% rename from pkg/gordio/nexus/websocket.go rename to pkg/nexus/websocket.go diff --git a/pkg/gordio/notify/notify.go b/pkg/notify/notify.go similarity index 97% rename from pkg/gordio/notify/notify.go rename to pkg/notify/notify.go index 1207946..82bd034 100644 --- a/pkg/gordio/notify/notify.go +++ b/pkg/notify/notify.go @@ -5,7 +5,7 @@ import ( stdhttp "net/http" "time" - "dynatron.me/x/stillbox/pkg/gordio/config" + "dynatron.me/x/stillbox/pkg/config" "github.com/nikoksr/notify" "github.com/nikoksr/notify/service/http" diff --git a/pkg/gordio/server/ingest.go b/pkg/server/ingest.go similarity index 100% rename from pkg/gordio/server/ingest.go rename to pkg/server/ingest.go diff --git a/pkg/gordio/server/logging.go b/pkg/server/logging.go similarity index 98% rename from pkg/gordio/server/logging.go rename to pkg/server/logging.go index 602193d..4697189 100644 --- a/pkg/gordio/server/logging.go +++ b/pkg/server/logging.go @@ -10,7 +10,7 @@ import ( "time" "dynatron.me/x/stillbox/internal/common" - "dynatron.me/x/stillbox/pkg/gordio/config" + "dynatron.me/x/stillbox/pkg/config" "github.com/go-chi/chi/v5/middleware" "github.com/rs/zerolog" diff --git a/pkg/gordio/server/noprofile.go b/pkg/server/noprofile.go similarity index 100% rename from pkg/gordio/server/noprofile.go rename to pkg/server/noprofile.go diff --git a/pkg/gordio/server/profile.go b/pkg/server/profile.go similarity index 100% rename from pkg/gordio/server/profile.go rename to pkg/server/profile.go diff --git a/pkg/gordio/server/routes.go b/pkg/server/routes.go similarity index 93% rename from pkg/gordio/server/routes.go rename to pkg/server/routes.go index 0b00455..1d6b87b 100644 --- a/pkg/gordio/server/routes.go +++ b/pkg/server/routes.go @@ -7,8 +7,8 @@ import ( "dynatron.me/x/stillbox/client" "dynatron.me/x/stillbox/internal/version" - "dynatron.me/x/stillbox/pkg/gordio/config" - "dynatron.me/x/stillbox/pkg/gordio/database" + "dynatron.me/x/stillbox/pkg/config" + "dynatron.me/x/stillbox/pkg/database" "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" "github.com/go-chi/httprate" @@ -75,7 +75,7 @@ func (s *Server) clientRoute(r chi.Router, clientRoot fs.FS) { } func ServerHeaderAdd(next http.Handler) http.Handler { - serverString := version.HttpString("gordio") + serverString := version.HttpString(version.Name) hfn := func(w http.ResponseWriter, r *http.Request) { w.Header().Set(serverHeader, serverString) next.ServeHTTP(w, r) diff --git a/pkg/gordio/server/server.go b/pkg/server/server.go similarity index 88% rename from pkg/gordio/server/server.go rename to pkg/server/server.go index 92efbcc..be6bc56 100644 --- a/pkg/gordio/server/server.go +++ b/pkg/server/server.go @@ -7,14 +7,14 @@ import ( "time" "dynatron.me/x/stillbox/pkg/calls" - "dynatron.me/x/stillbox/pkg/gordio/alerting" - "dynatron.me/x/stillbox/pkg/gordio/auth" - "dynatron.me/x/stillbox/pkg/gordio/config" - "dynatron.me/x/stillbox/pkg/gordio/database" - "dynatron.me/x/stillbox/pkg/gordio/nexus" - "dynatron.me/x/stillbox/pkg/gordio/notify" - "dynatron.me/x/stillbox/pkg/gordio/sinks" - "dynatron.me/x/stillbox/pkg/gordio/sources" + "dynatron.me/x/stillbox/pkg/alerting" + "dynatron.me/x/stillbox/pkg/auth" + "dynatron.me/x/stillbox/pkg/config" + "dynatron.me/x/stillbox/pkg/database" + "dynatron.me/x/stillbox/pkg/nexus" + "dynatron.me/x/stillbox/pkg/notify" + "dynatron.me/x/stillbox/pkg/sinks" + "dynatron.me/x/stillbox/pkg/sources" "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" "github.com/go-chi/cors" diff --git a/pkg/gordio/server/signals.go b/pkg/server/signals.go similarity index 93% rename from pkg/gordio/server/signals.go rename to pkg/server/signals.go index c4eef39..35ad4df 100644 --- a/pkg/gordio/server/signals.go +++ b/pkg/server/signals.go @@ -5,7 +5,7 @@ import ( "os/signal" "syscall" - "dynatron.me/x/stillbox/pkg/gordio/config" + "dynatron.me/x/stillbox/pkg/config" "github.com/rs/zerolog/log" ) diff --git a/pkg/gordio/sinks/database.go b/pkg/sinks/database.go similarity index 97% rename from pkg/gordio/sinks/database.go rename to pkg/sinks/database.go index a2ff46d..2cf9d60 100644 --- a/pkg/gordio/sinks/database.go +++ b/pkg/sinks/database.go @@ -6,7 +6,7 @@ import ( "dynatron.me/x/stillbox/internal/common" "dynatron.me/x/stillbox/pkg/calls" - "dynatron.me/x/stillbox/pkg/gordio/database" + "dynatron.me/x/stillbox/pkg/database" "github.com/jackc/pgx/v5/pgtype" "github.com/rs/zerolog/log" diff --git a/pkg/gordio/sinks/nexus.go b/pkg/sinks/nexus.go similarity index 90% rename from pkg/gordio/sinks/nexus.go rename to pkg/sinks/nexus.go index 9b590fb..0e56e1b 100644 --- a/pkg/gordio/sinks/nexus.go +++ b/pkg/sinks/nexus.go @@ -4,7 +4,7 @@ import ( "context" "dynatron.me/x/stillbox/pkg/calls" - "dynatron.me/x/stillbox/pkg/gordio/nexus" + "dynatron.me/x/stillbox/pkg/nexus" ) type NexusSink struct { diff --git a/pkg/gordio/sinks/sinks.go b/pkg/sinks/sinks.go similarity index 100% rename from pkg/gordio/sinks/sinks.go rename to pkg/sinks/sinks.go diff --git a/pkg/gordio/sources/http.go b/pkg/sources/http.go similarity index 98% rename from pkg/gordio/sources/http.go rename to pkg/sources/http.go index 5d39f46..4ecefee 100644 --- a/pkg/gordio/sources/http.go +++ b/pkg/sources/http.go @@ -8,7 +8,7 @@ import ( "dynatron.me/x/stillbox/internal/common" "dynatron.me/x/stillbox/internal/forms" "dynatron.me/x/stillbox/pkg/calls" - "dynatron.me/x/stillbox/pkg/gordio/auth" + "dynatron.me/x/stillbox/pkg/auth" "github.com/go-chi/chi/v5" "github.com/rs/zerolog/log" ) diff --git a/pkg/gordio/sources/source.go b/pkg/sources/source.go similarity index 100% rename from pkg/gordio/sources/source.go rename to pkg/sources/source.go diff --git a/sql/sqlc.yaml b/sql/sqlc.yaml index a65204f..c0e573a 100644 --- a/sql/sqlc.yaml +++ b/sql/sqlc.yaml @@ -6,7 +6,7 @@ sql: gen: go: package: "database" - out: "../pkg/gordio/database" + out: "../pkg/database" sql_package: "pgx/v5" query_parameter_limit: 3 emit_json_tags: true