-
Notifications
You must be signed in to change notification settings - Fork 0
/
ingest_preservation_verifier.go
55 lines (49 loc) · 2.01 KB
/
ingest_preservation_verifier.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
package workers
import (
"fmt"
"time"
"github.com/APTrust/preservation-services/constants"
"github.com/APTrust/preservation-services/ingest"
"github.com/APTrust/preservation-services/models/common"
"github.com/APTrust/preservation-services/models/service"
)
type PreservationVerifier struct {
*IngestBase
}
// NewIngestPreservationVerifier creates a new PreservationVerifier worker
// to verify that files have been correctly copied to preservation
// (and replication) storage.
func NewIngestPreservationVerifier(bufSize, numWorkers, maxAttempts int) *PreservationVerifier {
_context := common.NewContext()
bufSize, numWorkers, maxAttempts = _context.Config.GetWorkerSettings(constants.IngestStorageValidation, bufSize, numWorkers, maxAttempts)
settings := &Settings{
ChannelBufferSize: bufSize,
DeleteFromReceivingAfterFatalError: false,
DeleteFromReceivingAfterMaxFailedAttempts: false,
MaxAttempts: maxAttempts,
NSQChannel: constants.IngestStorageValidation + "_worker_chan",
NSQTopic: constants.IngestStorageValidation,
NextQueueTopic: constants.IngestRecord,
NextWorkItemStage: constants.StageRecord,
NumberOfWorkers: numWorkers,
PushToCleanupAfterMaxFailedAttempts: false,
PushToCleanupOnFatalError: false,
RequeueTimeout: (1 * time.Minute),
WorkItemSuccessNote: "Finished verifying files in preservation storage",
}
worker := &PreservationVerifier{
IngestBase: NewIngestBase(
_context,
createPreservationVerifier,
settings,
),
}
err := worker.IngestBase.RegisterAsNsqConsumer()
if err != nil {
panic(fmt.Sprintf("Cannot register NSQ consumer: %v", err))
}
return worker
}
func createPreservationVerifier(context *common.Context, workItemID int64, ingestObject *service.IngestObject) ingest.Runnable {
return ingest.NewPreservationVerifier(context, workItemID, ingestObject)
}