-
Notifications
You must be signed in to change notification settings - Fork 71
/
repo.go
73 lines (61 loc) · 2.3 KB
/
repo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package db // import "github.com/NYTimes/video-transcoding-api/db"
import (
"errors"
"time"
)
var (
// ErrJobNotFound is the error returned when the job is not found on GetJob or
// DeleteJob.
ErrJobNotFound = errors.New("job not found")
// ErrPresetMapNotFound is the error returned when the presetmap is not found
// on GetPresetMap, UpdatePresetMap or DeletePresetMap.
ErrPresetMapNotFound = errors.New("presetmap not found")
// ErrPresetMapAlreadyExists is the error returned when the presetmap already
// exists.
ErrPresetMapAlreadyExists = errors.New("presetmap already exists")
// ErrLocalPresetNotFound is the error returned when the local preset is not found
// on GetPresetMap, UpdatePresetMap or DeletePresetMap.
ErrLocalPresetNotFound = errors.New("local preset not found")
// ErrLocalPresetAlreadyExists is the error returned when the local preset already
// exists.
ErrLocalPresetAlreadyExists = errors.New("local preset already exists")
)
// Repository represents the repository for persisting types of the API.
type Repository interface {
JobRepository
PresetMapRepository
LocalPresetRepository
}
// JobRepository is the interface that defines the set of methods for managing Job
// persistence.
type JobRepository interface {
CreateJob(*Job) error
DeleteJob(*Job) error
GetJob(id string) (*Job, error)
ListJobs(JobFilter) ([]Job, error)
}
// JobFilter contains a set of parameters for filtering the list of jobs in
// JobRepository.
type JobFilter struct {
// Filter jobs since the given time.
Since time.Time
// Limit the number of jobs in the result. 0 means no limit.
Limit uint
}
// PresetMapRepository is the interface that defines the set of methods for
// managing PresetMap persistence.
type PresetMapRepository interface {
CreatePresetMap(*PresetMap) error
UpdatePresetMap(*PresetMap) error
DeletePresetMap(*PresetMap) error
GetPresetMap(name string) (*PresetMap, error)
ListPresetMaps() ([]PresetMap, error)
}
// LocalPresetRepository provides an interface that defines the set of methods for
// managing presets when the provider don't have the ability to store/manage it.
type LocalPresetRepository interface {
CreateLocalPreset(*LocalPreset) error
UpdateLocalPreset(*LocalPreset) error
DeleteLocalPreset(*LocalPreset) error
GetLocalPreset(name string) (*LocalPreset, error)
}