Подключите RabbitMQ и отдельный обработчик заданий
This commit is contained in:
+23
-3
@@ -19,11 +19,13 @@ import (
|
||||
"messenger/internal/app"
|
||||
"messenger/internal/attachment"
|
||||
"messenger/internal/chat"
|
||||
"messenger/internal/pipeline"
|
||||
"messenger/internal/platform/config"
|
||||
"messenger/internal/platform/ident"
|
||||
"messenger/internal/platform/postgres"
|
||||
"messenger/internal/platform/s3store"
|
||||
"messenger/internal/platform/valkey"
|
||||
"messenger/internal/processing"
|
||||
"messenger/internal/server"
|
||||
)
|
||||
|
||||
@@ -85,10 +87,25 @@ func run(ctx context.Context, log *slog.Logger, cfg config.Config, alias string)
|
||||
IdempotencyTTL: cfg.IdempotencyTTL,
|
||||
Blobs: blobs,
|
||||
AttachmentsCfg: attachment.Config{
|
||||
MaxBytes: cfg.S3.MaxBytes,
|
||||
MaxPixels: cfg.S3.MaxPixels,
|
||||
BarrierDir: os.Getenv("LAB5_BARRIERS"),
|
||||
MaxBytes: cfg.S3.MaxBytes,
|
||||
MaxPixels: cfg.S3.MaxPixels,
|
||||
},
|
||||
})
|
||||
var jobs config.Jobs
|
||||
var barrier func(context.Context, pipeline.Job, string) error
|
||||
if dir := os.Getenv("LAB5_BARRIERS"); dir != "" {
|
||||
if err := os.MkdirAll(dir, 0700); err != nil {
|
||||
return err
|
||||
}
|
||||
barrier = processing.FileBarrier(dir)
|
||||
}
|
||||
if blobs != nil {
|
||||
jobs, err = config.LoadJobs(os.LookupEnv)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
var debugLn net.Listener
|
||||
if cfg.DebugAddr != "" {
|
||||
if debugLn, err = net.Listen("tcp", cfg.DebugAddr); err != nil {
|
||||
@@ -99,6 +116,9 @@ func run(ctx context.Context, log *slog.Logger, cfg config.Config, alias string)
|
||||
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
var background sync.WaitGroup
|
||||
if blobs != nil {
|
||||
background.Go(func() { processing.Dispatch(ctx, log, pipeline.NewStore(pool), jobs, barrier) })
|
||||
}
|
||||
background.Go(func() { chat.RunKeyCleanup(ctx, log, a.Chats, keyCleanupEvery) })
|
||||
if reconciler != nil {
|
||||
background.Go(func() {
|
||||
@@ -151,7 +171,7 @@ func newAttachmentStorage(pool *pgxpool.Pool, cfg config.S3, lookup config.Looku
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
reconciler, err := attachment.NewReconciler(pool, reconBlobs, time.Hour)
|
||||
reconciler, err := attachment.NewReconcilerWithRetention(pool, reconBlobs, time.Hour, reconCfg.StagingRetention)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user