-
Notifications
You must be signed in to change notification settings - Fork 0
/
Repository.go
71 lines (51 loc) · 1.55 KB
/
Repository.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
package recipientsRepository
type MailSendingFailure struct {
Recipient string
Cause string
}
type IndividualJobStatus struct {
Status string
Message string
NumberOfRecipients int
NumberOfSentMails int
NumberOfSendingFailures int
NumberOfCurrentlySendingMails int64
}
type JobStatus struct {
Jobs map[string]IndividualJobStatus
Summary IndividualJobStatus
}
type LeaseExtensionRepository interface {
/*
* Extends the lease of the given already popped recipient.
*/
ExtendLease(jobId, recipient string) error
}
type Repository interface {
LeaseExtensionRepository
GetRandomOpenJob() (jobId string, err error)
/*
* Creates a new job with the given jobId or returns an
* error if this job already exists.
*/
CreateJob(jobId string, templates string) error
AbortAndRemoveJob(jobId string) error
GetJobStatus(jobIds []string) (status JobStatus, err error)
WriteSendingFailuresToFile(targetFile string, jobIds []string) (err error)
/**
* marks the job as fully prepared and sets the total number of recipients
*/
FinishPreparation(jobId string, numberOfRecipients int) error
MarkJobAsFailed(jobId, reason string) error
AddRecipient(jobId, recipient string) error
/*
* Pops the next remaining recipient for the given job id.
*
* see ExtendLease
* see RemoveRemaining
*/
GetNextOpenRecipient(jobId string) (recipient string, err error)
MarkRecipientAsDone(jobId, recipient string) error
MarkRecipientAsFailed(jobId, recipient, recipientId string, cause error) error
GetTemplates(jobId string) (templates Templates, err error)
}