Compare commits

..

1 Commits

Author SHA1 Message Date
cuddle-please
4b96d64ccf chore(release): 0.1.0
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2025-01-06 21:03:20 +00:00
13 changed files with 2 additions and 111 deletions

1
.env
View File

@ -1 +0,0 @@
ORBIS_LOG_LEVEL=debug

1
.gitignore vendored
View File

@ -1,3 +1,2 @@
.cuddle/
bin/
tmp/

View File

@ -13,8 +13,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- add default
### Other
- add basic scheduler
- add utility scripts
- add utility scripts
- add logger

View File

@ -5,16 +5,9 @@ import (
"os"
"git.front.kjuulh.io/kjuulh/orbis/internal/app"
"github.com/joho/godotenv"
)
func main() {
err := godotenv.Load()
if err != nil {
fmt.Printf("%s\n", err)
os.Exit(1)
}
app := app.NewApp()
if err := newRoot(app).Execute(); err != nil {

View File

@ -1,8 +1,6 @@
package main
import (
"fmt"
"git.front.kjuulh.io/kjuulh/orbis/internal/app"
"github.com/spf13/cobra"
)
@ -15,13 +13,8 @@ func newRoot(app *app.App) *cobra.Command {
Short: "Orbis is a data workflow scheduler for all your batch and real-time needs",
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
logger.Info("starting orbis")
if err := app.Scheduler().Execute(ctx); err != nil {
return fmt.Errorf("scheduler failed with error: %w", err)
}
return nil
},
}

1
go.mod
View File

@ -6,7 +6,6 @@ require github.com/spf13/cobra v1.8.1
require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/joho/godotenv v1.5.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
gitlab.com/greyxor/slogor v1.6.0 // indirect
golang.org/x/sys v0.28.0 // indirect

2
go.sum
View File

@ -1,8 +1,6 @@
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=

View File

@ -2,8 +2,6 @@ package app
import (
"log/slog"
"git.front.kjuulh.io/kjuulh/orbis/internal/scheduler"
)
type App struct {
@ -19,7 +17,3 @@ func NewApp() *App {
func (a *App) Logger() *slog.Logger {
return a.logger
}
func (a *App) Scheduler() *scheduler.Scheduler {
return scheduler.NewScheduler(a.logger)
}

View File

@ -3,26 +3,10 @@ package app
import (
"log/slog"
"os"
"strings"
"gitlab.com/greyxor/slogor"
)
func setupLogging() *slog.Logger {
logLevelRaw := os.Getenv("ORBIS_LOG_LEVEL")
var logLevel slog.Leveler
switch strings.ToLower(logLevelRaw) {
case "debug":
logLevel = slog.LevelDebug
case "info":
logLevel = slog.LevelInfo
case "warn":
logLevel = slog.LevelWarn
case "error":
logLevel = slog.LevelError
default:
logLevel = slog.LevelInfo
}
return slog.New(slogor.NewHandler(os.Stderr, slogor.SetLevel(logLevel)))
return slog.New(slogor.NewHandler(os.Stderr))
}

View File

@ -1 +0,0 @@
package lifecycles

View File

@ -1,41 +0,0 @@
package scheduler
import (
"context"
"fmt"
"log/slog"
"time"
)
type Scheduler struct {
logger *slog.Logger
}
func NewScheduler(logger *slog.Logger) *Scheduler {
return &Scheduler{
logger: logger,
}
}
func (s *Scheduler) Execute(ctx context.Context) error {
for {
select {
case <-ctx.Done():
s.logger.Info("gracefully shutting down scheduler")
return nil
default:
if err := s.process(ctx); err != nil {
return fmt.Errorf("scheduler failed: %w", err)
}
}
}
}
func (s *Scheduler) process(ctx context.Context) error {
s.logger.Debug("scheduler processing items")
// FIXME: simulate work
time.Sleep(time.Second * 5)
return nil
}

View File

@ -1,25 +0,0 @@
package utilities
import (
"fmt"
"sync"
)
func Singleton[T any](init func() (T, error)) func() T {
var (
once sync.Once
t T
)
return func() T {
once.Do(func() {
var err error
t, err = init()
if err != nil {
panic(fmt.Sprintf("creating %T failed: %s", t, err))
}
})
return t
}
}

1
tmp/build-errors.log Normal file
View File

@ -0,0 +1 @@
exit status 1exit status 1exit status 1exit status 1