-
Notifications
You must be signed in to change notification settings - Fork 316
/
types.go
95 lines (81 loc) · 2.34 KB
/
types.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package jobs
import (
"context"
"database/sql"
"encoding/json"
"time"
"github.com/rudderlabs/rudder-server/services/pgnotifier"
"github.com/rudderlabs/rudder-server/utils/logger"
)
var pkgLogger logger.Logger
// For processing requests payload in handlers.go
type StartJobReqPayload struct {
SourceID string `json:"source_id"`
Type string `json:"type"`
Channel string `json:"channel"`
DestinationID string `json:"destination_id"`
StartTime string `json:"start_time"`
JobRunID string `json:"job_run_id"`
TaskRunID string `json:"task_run_id"`
AsyncJobType string `json:"async_job_type"`
}
type AsyncJobWhT struct {
dbHandle *sql.DB
enabled bool
pgnotifier *pgnotifier.PgNotifierT
context context.Context
}
type WhJobsMetaData struct {
JobRunID string `json:"job_run_id"`
TaskRunID string `json:"task_run_id"`
JobType string `json:"jobtype"`
StartTime string `json:"start_time"`
}
// For creating job payload to wh_async_jobs table
type AsyncJobPayloadT struct {
Id string `json:"id"`
SourceID string `json:"source_id"`
DestinationID string `json:"destination_id"`
TableName string `json:"tablename"`
AsyncJobType string `json:"async_job_type"`
MetaData json.RawMessage `json:"metadata"`
}
const (
WhJobWaiting string = "waiting"
WhJobExecuting string = "executing"
WhJobSucceeded string = "succeeded"
WhJobAborted string = "aborted"
WhJobFailed string = "failed"
AsyncJobType string = "async_job"
)
type PGNotifierOutput struct {
Id string `json:"id"`
}
type WhAddJobResponse struct {
JobIds []int64 `json:"jobids"`
Err error `json:"error"`
}
type WhStatusResponse struct {
Status string
Err string
}
type WhAsyncJobRunner interface {
startAsyncJobRunner(context.Context)
getTableNamesBy(context.Context, string, string)
getPendingAsyncJobs(context.Context) ([]AsyncJobPayloadT, error)
getStatusAsyncJob(*StartJobReqPayload) (string, error)
updateMultipleAsyncJobs(*[]AsyncJobPayloadT, string, string)
}
type AsyncJobsStatusMap struct {
Id string
Status string
Error error
}
const (
MaxBatchSizeToProcess int = 10
MaxCleanUpRetries int = 5
MaxQueryRetries int = 3
RetryTimeInterval = 10 * time.Second
MaxAttemptsPerJob int = 3
WhAsyncJobTimeOut = 10 * time.Second
)