Files
mtusi2026lab5/service/internal/service/attachment/interface.go
T
2026-11-13 12:48:18 +03:00

52 lines
2.1 KiB
Go

package attachment
import (
"context"
"gitea.privcloud.tech/mtusi2026/internal/dto"
"gitea.privcloud.tech/mtusi2026/internal/service/outbox"
"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/google/uuid"
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgxpool"
"io"
"time"
)
type TransactionManager interface {
RunInTransaction(context.Context, *pgx.TxOptions, func(pgx.Tx) error) error
}
type Outbox interface {
CreateTx(context.Context, pgx.Tx, outbox.CreateMessageReq) (outbox.CreateMessageRes, error)
}
type ObjectStore interface {
Put(context.Context, string, string, io.Reader, int64) error
Get(context.Context, string) (*s3.GetObjectOutput, error)
Head(context.Context, string) (*s3.HeadObjectOutput, error)
Delete(context.Context, string) error
Ping(context.Context) error
List(context.Context, string) (*s3.ListObjectsV2Output, error)
}
type Repository interface {
SaveVariantTx(context.Context, pgx.Tx, uuid.UUID, int, string, string, string, int64) error
Ping(context.Context) error
Get(context.Context, uuid.UUID) (*dto.AttachmentRecord, error)
GetTx(context.Context, pgx.Tx, uuid.UUID) (*dto.AttachmentRecord, error)
InsertTx(context.Context, pgx.Tx, *dto.AttachmentRecord) error
UpdateTx(context.Context, pgx.Tx, *dto.AttachmentRecord) error
JobTx(context.Context, pgx.Tx, uuid.UUID) (*dto.AttachmentJob, error)
InsertJobTx(context.Context, pgx.Tx, *dto.AttachmentJob) error
SaveJobTx(context.Context, pgx.Tx, *dto.AttachmentJob) error
ExpiredJobs(context.Context) ([]uuid.UUID, error)
PublicationDeadTx(context.Context, pgx.Tx, uuid.UUID, int) (bool, error)
FailedOutbox(context.Context) ([]uuid.UUID, error)
ListJobs(context.Context) ([]dto.AttachmentJob, error)
RetiredSources(context.Context, time.Time) ([]*dto.AttachmentRecord, error)
AuditTx(context.Context, pgx.Tx, uuid.UUID, string) error
Lock(context.Context, string) (*pgxpool.Conn, func(), error)
Exists(context.Context, *pgxpool.Conn, string) (bool, error)
Page(context.Context, uuid.UUID) ([]*dto.AttachmentRecord, error)
MarkMissing(context.Context, *pgxpool.Conn, uuid.UUID, bool) (bool, error)
CheckConn(context.Context, *pgxpool.Conn) error
}