From bb3247d3918f4b73ff8ba422ca96fa9978d03644 Mon Sep 17 00:00:00 2001 From: Anton Vakhrushev Date: Tue, 12 Aug 2025 14:19:42 +0300 Subject: [PATCH] Split contract package --- internal/contract/contract.go | 28 ---------------------------- internal/contract/error.go | 12 ++++++++++++ internal/contract/repository.go | 19 +++++++++++++++++++ 3 files changed, 31 insertions(+), 28 deletions(-) create mode 100644 internal/contract/error.go create mode 100644 internal/contract/repository.go diff --git a/internal/contract/contract.go b/internal/contract/contract.go index 9f6cdf6..847037e 100644 --- a/internal/contract/contract.go +++ b/internal/contract/contract.go @@ -1,33 +1,5 @@ package contract -import ( - "fmt" - "time" - - "git.vakhrushev.me/av/transcriber/internal/entity" -) - -type JobNotFoundError struct { - State string - Message string -} - -func (e *JobNotFoundError) Error() string { - return fmt.Sprintf("%s - %s", e.State, e.Message) -} - -type FileRepository interface { - Create(file *entity.File) error - GetByID(id string) (*entity.File, error) -} - -type TranscriptJobRepository interface { - Create(job *entity.TranscribeJob) error - Save(job *entity.TranscribeJob) error - GetByID(id string) (*entity.TranscribeJob, error) - FindAndAcquire(state, acquisitionId string, rottingTime time.Time) (*entity.TranscribeJob, error) -} - type ObjectStorage interface { } diff --git a/internal/contract/error.go b/internal/contract/error.go new file mode 100644 index 0000000..3254a64 --- /dev/null +++ b/internal/contract/error.go @@ -0,0 +1,12 @@ +package contract + +import "fmt" + +type JobNotFoundError struct { + State string + Message string +} + +func (e *JobNotFoundError) Error() string { + return fmt.Sprintf("%s - %s", e.State, e.Message) +} diff --git a/internal/contract/repository.go b/internal/contract/repository.go new file mode 100644 index 0000000..0115670 --- /dev/null +++ b/internal/contract/repository.go @@ -0,0 +1,19 @@ +package contract + +import ( + "time" + + "git.vakhrushev.me/av/transcriber/internal/entity" +) + +type FileRepository interface { + Create(file *entity.File) error + GetByID(id string) (*entity.File, error) +} + +type TranscriptJobRepository interface { + Create(job *entity.TranscribeJob) error + Save(job *entity.TranscribeJob) error + GetByID(id string) (*entity.TranscribeJob, error) + FindAndAcquire(state, acquisitionId string, rottingTime time.Time) (*entity.TranscribeJob, error) +}