2025-03-10 11:03:00 +00:00
|
|
|
package clientsyncrunner
|
2025-02-12 19:00:25 +00:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2025-03-05 19:49:03 +00:00
|
|
|
"log/slog"
|
2025-03-05 12:05:46 +00:00
|
|
|
|
2025-03-10 11:03:00 +00:00
|
|
|
clientsync "queryorchestration/internal/client/sync"
|
2025-02-12 19:00:25 +00:00
|
|
|
)
|
|
|
|
|
|
2025-03-10 11:03:00 +00:00
|
|
|
const Name = "clientSyncRunner"
|
2025-02-12 19:00:25 +00:00
|
|
|
|
|
|
|
|
type Services struct {
|
2025-03-10 11:03:00 +00:00
|
|
|
ClientSync *clientsync.Service
|
2025-02-12 19:00:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Runner struct {
|
2025-04-22 14:40:16 +00:00
|
|
|
svc *Services
|
2025-02-12 19:00:25 +00:00
|
|
|
}
|
|
|
|
|
|
2025-04-22 14:40:16 +00:00
|
|
|
func New(svc *Services) Runner {
|
2025-02-12 19:00:25 +00:00
|
|
|
return Runner{
|
2025-04-22 14:40:16 +00:00
|
|
|
svc: svc,
|
2025-02-12 19:00:25 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Body struct {
|
2025-04-02 18:50:03 +00:00
|
|
|
ClientID string `json:"id" validate:"required"`
|
2025-02-12 19:00:25 +00:00
|
|
|
}
|
|
|
|
|
|
2025-04-02 18:50:03 +00:00
|
|
|
func (s *Runner) Process(ctx context.Context, body Body) bool {
|
|
|
|
|
err := s.svc.ClientSync.Sync(ctx, body.ClientID)
|
2025-02-12 19:00:25 +00:00
|
|
|
if err != nil {
|
2025-03-05 19:49:03 +00:00
|
|
|
slog.Error("unable to process", "error", err)
|
|
|
|
|
return false
|
2025-02-12 19:00:25 +00:00
|
|
|
}
|
|
|
|
|
|
2025-03-05 19:49:03 +00:00
|
|
|
return true
|
2025-02-12 19:00:25 +00:00
|
|
|
}
|