feat(domain): lab5 add attachment variants and job repository contracts
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package domain
|
||||
|
||||
import "time"
|
||||
|
||||
type AttachmentVariant struct {
|
||||
AttachmentID string
|
||||
Name string
|
||||
ObjectKey string
|
||||
ContentType string
|
||||
SizeBytes int64
|
||||
Width int
|
||||
Height int
|
||||
SHA256 []byte
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
const (
|
||||
VariantThumbnail = "thumbnail"
|
||||
VariantCrop = "crop"
|
||||
VariantWebP = "webp"
|
||||
)
|
||||
|
||||
func AllVariantNames() []string {
|
||||
return []string{VariantThumbnail, VariantCrop, VariantWebP}
|
||||
}
|
||||
@@ -52,3 +52,14 @@ type OutboxRepository interface {
|
||||
ClaimBatch(ctx context.Context, limit int) ([]OutboxEntry, error)
|
||||
MarkPublished(ctx context.Context, ids []string) error
|
||||
}
|
||||
|
||||
type AttachmentJobRepository interface {
|
||||
ClaimForProcessing(ctx context.Context, id string, lease time.Duration) (*Attachment, error)
|
||||
CompleteJob(ctx context.Context, id string, pipelineVersion int, variants []AttachmentVariant) (bool, error)
|
||||
FailJob(ctx context.Context, id string, errorCode string) error
|
||||
}
|
||||
|
||||
type AttachmentVariantRepository interface {
|
||||
Upsert(ctx context.Context, tx Tx, v *AttachmentVariant) error
|
||||
ListByAttachment(ctx context.Context, id string) ([]AttachmentVariant, error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user