Compare commits

...

2 commits

45 changed files with 61 additions and 58 deletions

1
.gitignore vendored
View file

@ -4,6 +4,7 @@ mydb.sql
client/calls/ client/calls/
!client/calls/.gitkeep !client/calls/.gitkeep
/gordio /gordio
/stillbox
/calls /calls
Session.vim Session.vim
*.log *.log

View file

@ -4,15 +4,15 @@ BUILDDATE!=date '+%Y%m%d'
LDFLAGS=-ldflags="-X '${VPKG}.Version=${VER}' -X '${VPKG}.Built=${BUILDDATE}'" LDFLAGS=-ldflags="-X '${VPKG}.Version=${VER}' -X '${VPKG}.Built=${BUILDDATE}'"
all: checkcalls 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/ go build -o calls ${GOFLAGS} ${LDFLAGS} ./cmd/calls/
buildpprof: buildpprof:
go build -o gordio-pprof ${GOFLAGS} ${LDFLAGS} -tags pprof ./cmd/gordio go build -o stillbox-pprof ${GOFLAGS} ${LDFLAGS} -tags pprof ./cmd/stillbox
clean: clean:
rm -rf client/calls/ && mkdir client/calls && touch client/calls/.gitkeep rm -rf client/calls/ && mkdir client/calls && touch client/calls/.gitkeep
rm -f gordio calls gordio-pprof rm -f stillbox calls stillbox-pprof
checkcalls: checkcalls:
@test -e client/calls/index.html || make getcalls @test -e client/calls/index.html || make getcalls

View file

@ -1,10 +1,10 @@
# stillbox # stillbox
A Golang scanner call server (`gordio`), with the Calls webapp. A Golang scanner call server.
**NOTE** **NOTE**
If this message is still here, the database schema *initial migration* and protobuf definitions are **still subject to change**. 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). protobuf best practices (i.e. not changing field numbers).

View file

@ -9,9 +9,9 @@ import (
"dynatron.me/x/stillbox/internal/common" "dynatron.me/x/stillbox/internal/common"
"dynatron.me/x/stillbox/internal/version" "dynatron.me/x/stillbox/internal/version"
"dynatron.me/x/stillbox/pkg/gordio" "dynatron.me/x/stillbox/pkg/cmd/serve"
"dynatron.me/x/stillbox/pkg/gordio/admin" "dynatron.me/x/stillbox/pkg/cmd/admin"
"dynatron.me/x/stillbox/pkg/gordio/config" "dynatron.me/x/stillbox/pkg/config"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -20,7 +20,7 @@ func main() {
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr, TimeFormat: common.TimeFormat}) log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr, TimeFormat: common.TimeFormat})
rootCmd := &cobra.Command{ rootCmd := &cobra.Command{
Use: gordio.AppName, Use: common.AppName,
} }
rootCmd.PersistentFlags().BoolP("version", "V", false, "show version") rootCmd.PersistentFlags().BoolP("version", "V", false, "show version")
cfg := config.New(rootCmd) 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...) rootCmd.AddCommand(cmds...)
err := rootCmd.Execute() err := rootCmd.Execute()

View file

@ -7,6 +7,8 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
const AppName = "stillbox"
const ( const (
TimeFormat = "Jan 2 15:04:05" TimeFormat = "Jan 2 15:04:05"
) )

View file

@ -11,8 +11,8 @@ import (
"dynatron.me/x/stillbox/internal/forms" "dynatron.me/x/stillbox/internal/forms"
"dynatron.me/x/stillbox/internal/jsontime" "dynatron.me/x/stillbox/internal/jsontime"
"dynatron.me/x/stillbox/pkg/gordio/alerting" "dynatron.me/x/stillbox/pkg/alerting"
"dynatron.me/x/stillbox/pkg/gordio/config" "dynatron.me/x/stillbox/pkg/config"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"

View file

@ -3,17 +3,19 @@ package version
import ( import (
"fmt" "fmt"
"runtime" "runtime"
"dynatron.me/x/stillbox/internal/common"
) )
var ( var (
Name = "gordio" Name = common.AppName
Version = "unset" Version = "unset"
Built = "unset" Built = "unset"
) )
func String() string { func String() string {
return fmt.Sprintf("gordio %s\nbuilt %s for %s-%s\n", return fmt.Sprintf("%s %s\nbuilt %s for %s-%s\n",
Version, Built, runtime.GOOS, runtime.GOARCH) Name, Version, Built, runtime.GOOS, runtime.GOARCH)
} }
func HttpString(app string) string { func HttpString(app string) string {

View file

@ -12,10 +12,10 @@ import (
"time" "time"
cl "dynatron.me/x/stillbox/pkg/calls" cl "dynatron.me/x/stillbox/pkg/calls"
"dynatron.me/x/stillbox/pkg/gordio/config" "dynatron.me/x/stillbox/pkg/config"
"dynatron.me/x/stillbox/pkg/gordio/database" "dynatron.me/x/stillbox/pkg/database"
"dynatron.me/x/stillbox/pkg/gordio/notify" "dynatron.me/x/stillbox/pkg/notify"
"dynatron.me/x/stillbox/pkg/gordio/sinks" "dynatron.me/x/stillbox/pkg/sinks"
"dynatron.me/x/stillbox/internal/timeseries" "dynatron.me/x/stillbox/internal/timeseries"
"dynatron.me/x/stillbox/internal/trending" "dynatron.me/x/stillbox/internal/trending"

View file

@ -13,7 +13,7 @@ import (
"dynatron.me/x/stillbox/internal/jsontime" "dynatron.me/x/stillbox/internal/jsontime"
"dynatron.me/x/stillbox/internal/trending" "dynatron.me/x/stillbox/internal/trending"
cl "dynatron.me/x/stillbox/pkg/calls" 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" "github.com/rs/zerolog/log"
) )

View file

@ -8,8 +8,8 @@ import (
"time" "time"
"dynatron.me/x/stillbox/pkg/calls" "dynatron.me/x/stillbox/pkg/calls"
"dynatron.me/x/stillbox/pkg/gordio/config" "dynatron.me/x/stillbox/pkg/config"
"dynatron.me/x/stillbox/pkg/gordio/database" "dynatron.me/x/stillbox/pkg/database"
"dynatron.me/x/stillbox/internal/common" "dynatron.me/x/stillbox/internal/common"
"dynatron.me/x/stillbox/internal/jsontime" "dynatron.me/x/stillbox/internal/jsontime"

View file

@ -6,7 +6,7 @@ import (
"encoding/base64" "encoding/base64"
"time" "time"
"dynatron.me/x/stillbox/pkg/gordio/database" "dynatron.me/x/stillbox/pkg/database"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"

View file

@ -4,7 +4,7 @@ import (
"errors" "errors"
"net/http" "net/http"
"dynatron.me/x/stillbox/pkg/gordio/config" "dynatron.me/x/stillbox/pkg/config"
"github.com/go-chi/jwtauth/v5" "github.com/go-chi/jwtauth/v5"
) )

View file

@ -10,7 +10,7 @@ import (
"golang.org/x/crypto/bcrypt" "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/chi/v5"
"github.com/go-chi/jwtauth/v5" "github.com/go-chi/jwtauth/v5"

View file

@ -5,7 +5,7 @@ import (
"time" "time"
"dynatron.me/x/stillbox/internal/audio" "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" "dynatron.me/x/stillbox/pkg/pb"
"google.golang.org/protobuf/types/known/timestamppb" "google.golang.org/protobuf/types/known/timestamppb"

View file

@ -3,7 +3,7 @@ package calls
import ( import (
"context" "context"
"dynatron.me/x/stillbox/pkg/gordio/database" "dynatron.me/x/stillbox/pkg/database"
"dynatron.me/x/stillbox/pkg/pb" "dynatron.me/x/stillbox/pkg/pb"
) )

View file

@ -6,7 +6,7 @@ import (
"sync" "sync"
"time" "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/ruletime"
"dynatron.me/x/stillbox/internal/trending" "dynatron.me/x/stillbox/internal/trending"

View file

@ -6,8 +6,8 @@ import (
"fmt" "fmt"
"syscall" "syscall"
"dynatron.me/x/stillbox/pkg/gordio/config" "dynatron.me/x/stillbox/pkg/config"
"dynatron.me/x/stillbox/pkg/gordio/database" "dynatron.me/x/stillbox/pkg/database"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"golang.org/x/crypto/bcrypt" "golang.org/x/crypto/bcrypt"
"golang.org/x/term" "golang.org/x/term"

View file

@ -1,4 +1,4 @@
package gordio package serve
import ( import (
"context" "context"
@ -6,14 +6,12 @@ import (
"os/signal" "os/signal"
"dynatron.me/x/stillbox/internal/common" "dynatron.me/x/stillbox/internal/common"
"dynatron.me/x/stillbox/pkg/gordio/config" "dynatron.me/x/stillbox/pkg/config"
"dynatron.me/x/stillbox/pkg/gordio/server" "dynatron.me/x/stillbox/pkg/server"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
const AppName = "gordio"
type ServeOptions struct { type ServeOptions struct {
cfg *config.Config cfg *config.Config
} }
@ -22,7 +20,7 @@ func Command(cfg *config.Config) *cobra.Command {
opts := makeOptions(cfg) opts := makeOptions(cfg)
serveCmd := &cobra.Command{ serveCmd := &cobra.Command{
Use: "serve", Use: "serve",
Short: "starts the" + AppName + " server", Short: "starts the" + common.AppName + " server",
PersistentPreRunE: cfg.PreRunE(), PersistentPreRunE: cfg.PreRunE(),
RunE: common.RunE(opts), RunE: common.RunE(opts),
} }

View file

@ -116,7 +116,7 @@ func (c *Config) ReadConfig() error {
return err return err
} }
log.Info().Str("configPath", c.configPath).Msg("read gordio config") log.Info().Str("configPath", c.configPath).Msg("read config")
return nil return nil
} }

View file

@ -5,7 +5,7 @@ import (
"errors" "errors"
"strings" "strings"
"dynatron.me/x/stillbox/pkg/gordio/config" "dynatron.me/x/stillbox/pkg/config"
sqlembed "dynatron.me/x/stillbox/sql" sqlembed "dynatron.me/x/stillbox/sql"
"github.com/golang-migrate/migrate/v4" "github.com/golang-migrate/migrate/v4"
_ "github.com/golang-migrate/migrate/v4/database/pgx/v5" _ "github.com/golang-migrate/migrate/v4/database/pgx/v5"

View file

@ -9,7 +9,7 @@ import (
"dynatron.me/x/stillbox/internal/version" "dynatron.me/x/stillbox/internal/version"
"dynatron.me/x/stillbox/pkg/calls" "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" "dynatron.me/x/stillbox/pkg/pb"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"

View file

@ -5,7 +5,7 @@ import (
"encoding/json" "encoding/json"
"dynatron.me/x/stillbox/pkg/calls" "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" "dynatron.me/x/stillbox/pkg/pb"
"github.com/jackc/pgx/v5" "github.com/jackc/pgx/v5"

View file

@ -5,7 +5,7 @@ import (
stdhttp "net/http" stdhttp "net/http"
"time" "time"
"dynatron.me/x/stillbox/pkg/gordio/config" "dynatron.me/x/stillbox/pkg/config"
"github.com/nikoksr/notify" "github.com/nikoksr/notify"
"github.com/nikoksr/notify/service/http" "github.com/nikoksr/notify/service/http"

View file

@ -10,7 +10,7 @@ import (
"time" "time"
"dynatron.me/x/stillbox/internal/common" "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/go-chi/chi/v5/middleware"
"github.com/rs/zerolog" "github.com/rs/zerolog"

View file

@ -7,8 +7,8 @@ import (
"dynatron.me/x/stillbox/client" "dynatron.me/x/stillbox/client"
"dynatron.me/x/stillbox/internal/version" "dynatron.me/x/stillbox/internal/version"
"dynatron.me/x/stillbox/pkg/gordio/config" "dynatron.me/x/stillbox/pkg/config"
"dynatron.me/x/stillbox/pkg/gordio/database" "dynatron.me/x/stillbox/pkg/database"
"github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware" "github.com/go-chi/chi/v5/middleware"
"github.com/go-chi/httprate" "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 { func ServerHeaderAdd(next http.Handler) http.Handler {
serverString := version.HttpString("gordio") serverString := version.HttpString(version.Name)
hfn := func(w http.ResponseWriter, r *http.Request) { hfn := func(w http.ResponseWriter, r *http.Request) {
w.Header().Set(serverHeader, serverString) w.Header().Set(serverHeader, serverString)
next.ServeHTTP(w, r) next.ServeHTTP(w, r)

View file

@ -7,14 +7,14 @@ import (
"time" "time"
"dynatron.me/x/stillbox/pkg/calls" "dynatron.me/x/stillbox/pkg/calls"
"dynatron.me/x/stillbox/pkg/gordio/alerting" "dynatron.me/x/stillbox/pkg/alerting"
"dynatron.me/x/stillbox/pkg/gordio/auth" "dynatron.me/x/stillbox/pkg/auth"
"dynatron.me/x/stillbox/pkg/gordio/config" "dynatron.me/x/stillbox/pkg/config"
"dynatron.me/x/stillbox/pkg/gordio/database" "dynatron.me/x/stillbox/pkg/database"
"dynatron.me/x/stillbox/pkg/gordio/nexus" "dynatron.me/x/stillbox/pkg/nexus"
"dynatron.me/x/stillbox/pkg/gordio/notify" "dynatron.me/x/stillbox/pkg/notify"
"dynatron.me/x/stillbox/pkg/gordio/sinks" "dynatron.me/x/stillbox/pkg/sinks"
"dynatron.me/x/stillbox/pkg/gordio/sources" "dynatron.me/x/stillbox/pkg/sources"
"github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware" "github.com/go-chi/chi/v5/middleware"
"github.com/go-chi/cors" "github.com/go-chi/cors"

View file

@ -5,7 +5,7 @@ import (
"os/signal" "os/signal"
"syscall" "syscall"
"dynatron.me/x/stillbox/pkg/gordio/config" "dynatron.me/x/stillbox/pkg/config"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
) )

View file

@ -6,7 +6,7 @@ import (
"dynatron.me/x/stillbox/internal/common" "dynatron.me/x/stillbox/internal/common"
"dynatron.me/x/stillbox/pkg/calls" "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/jackc/pgx/v5/pgtype"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"

View file

@ -4,7 +4,7 @@ import (
"context" "context"
"dynatron.me/x/stillbox/pkg/calls" "dynatron.me/x/stillbox/pkg/calls"
"dynatron.me/x/stillbox/pkg/gordio/nexus" "dynatron.me/x/stillbox/pkg/nexus"
) )
type NexusSink struct { type NexusSink struct {

View file

@ -8,7 +8,7 @@ import (
"dynatron.me/x/stillbox/internal/common" "dynatron.me/x/stillbox/internal/common"
"dynatron.me/x/stillbox/internal/forms" "dynatron.me/x/stillbox/internal/forms"
"dynatron.me/x/stillbox/pkg/calls" "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/go-chi/chi/v5"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
) )

View file

@ -6,7 +6,7 @@ sql:
gen: gen:
go: go:
package: "database" package: "database"
out: "../pkg/gordio/database" out: "../pkg/database"
sql_package: "pgx/v5" sql_package: "pgx/v5"
query_parameter_limit: 3 query_parameter_limit: 3
emit_json_tags: true emit_json_tags: true