Compare commits

..

1 Commits

Author SHA1 Message Date
cuddle-please
1819b214a6 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-18 11:17:27 +00:00
8 changed files with 3 additions and 34 deletions

View File

@ -9,7 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.1.0] - 2025-01-18
### Added
- prune old workers
- deregister worker on close
- add worker distributor and model registry
- enable worker process

View File

@ -26,7 +26,7 @@ func (a *App) Logger() *slog.Logger {
}
func (a *App) Scheduler() *scheduler.Scheduler {
return scheduler.NewScheduler(a.logger.With("component", "scheduler"), Postgres(), a.Executor(), a.Worker())
return scheduler.NewScheduler(a.logger.With("component", "scheduler"), Postgres(), a.Executor())
}
func (a *App) Executor() *executor.Executor {

View File

@ -9,7 +9,6 @@ import (
"time"
"git.front.kjuulh.io/kjuulh/orbis/internal/executor"
"git.front.kjuulh.io/kjuulh/orbis/internal/worker"
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgxpool"
)
@ -18,15 +17,13 @@ type Scheduler struct {
logger *slog.Logger
db *pgxpool.Pool
executor *executor.Executor
worker *worker.Worker
}
func NewScheduler(logger *slog.Logger, db *pgxpool.Pool, executor *executor.Executor, worker *worker.Worker) *Scheduler {
func NewScheduler(logger *slog.Logger, db *pgxpool.Pool, executor *executor.Executor) *Scheduler {
return &Scheduler{
logger: logger,
db: db,
executor: executor,
worker: worker,
}
}
@ -99,10 +96,6 @@ func (s *Scheduler) acquireLeader(ctx context.Context) (bool, error) {
}
func (s *Scheduler) process(ctx context.Context) error {
if err := s.worker.Prune(ctx); err != nil {
return fmt.Errorf("failed to prune error: %w", err)
}
if err := s.executor.DispatchEvents(ctx); err != nil {
return fmt.Errorf("failed to dispatch events: %w", err)
}

View File

@ -26,8 +26,3 @@ WHERE
DELETE FROM worker_register
WHERE
worker_id = $1;
-- name: PruneWorker :exec
DELETE FROM worker_register
WHERE
heart_beat <= now() - INTERVAL '10 minutes';

View File

@ -14,7 +14,6 @@ type Querier interface {
DeregisterWorker(ctx context.Context, workerID uuid.UUID) error
GetWorkers(ctx context.Context) ([]*GetWorkersRow, error)
Ping(ctx context.Context) (int32, error)
PruneWorker(ctx context.Context) error
RegisterWorker(ctx context.Context, arg *RegisterWorkerParams) error
UpdateWorkerHeartbeat(ctx context.Context, workerID uuid.UUID) error
}

View File

@ -66,17 +66,6 @@ func (q *Queries) Ping(ctx context.Context) (int32, error) {
return column_1, err
}
const pruneWorker = `-- name: PruneWorker :exec
DELETE FROM worker_register
WHERE
heart_beat <= now() - INTERVAL '10 minutes'
`
func (q *Queries) PruneWorker(ctx context.Context) error {
_, err := q.db.Exec(ctx, pruneWorker)
return err
}
const registerWorker = `-- name: RegisterWorker :exec
INSERT INTO worker_register (worker_id, capacity)
VALUES (

View File

@ -173,9 +173,3 @@ func (w *Worker) updateHeartBeat(ctx context.Context) error {
func (w *Worker) processWorkQueue(ctx context.Context) error {
return w.workProcessor.ProcessNext(ctx, w.workerID)
}
func (w *Worker) Prune(ctx context.Context) error {
repo := repositories.New(w.db)
return repo.PruneWorker(ctx)
}

View File

@ -40,7 +40,7 @@ func (w *WorkProcessor) ProcessNext(ctx context.Context, workerID uuid.UUID) err
return fmt.Errorf("failed to start processing items: %w", err)
}
time.Sleep(time.Millisecond * 10)
time.Sleep(10 * time.Second)
if err := w.workscheduler.Archive(ctx, *schedule); err != nil {
return fmt.Errorf("failed to archive item: %w", err)