forked from xmidt-org/caduceus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
caduceus_type.go
62 lines (52 loc) · 1.72 KB
/
caduceus_type.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
// SPDX-FileCopyrightText: 2021 Comcast Cable Communications Management, LLC
// SPDX-License-Identifier: Apache-2.0
package main
import (
"time"
"go.uber.org/zap"
"github.com/go-kit/kit/metrics"
"github.com/xmidt-org/ancla"
"github.com/xmidt-org/wrp-go/v3"
)
// Below is the struct we're using to contain the data from a provided config file
// TODO: Try to figure out how to make bucket ranges configurable
type CaduceusConfig struct {
AuthHeader []string
NumWorkerThreads int
JobQueueSize int
Sender SenderConfig
JWTValidators []JWTValidator
Webhook ancla.Config
Listener ancla.ListenerConfig
AllowInsecureTLS bool
}
type SenderConfig struct {
NumWorkersPerSender int
QueueSizePerSender int
CutOffPeriod time.Duration
Linger time.Duration
ClientTimeout time.Duration
DisableClientHostnameValidation bool
ResponseHeaderTimeout time.Duration
IdleConnTimeout time.Duration
DeliveryRetries int
DeliveryInterval time.Duration
CustomPIDs []string
DisablePartnerIDs bool
}
type CaduceusMetricsRegistry interface {
NewCounter(name string) metrics.Counter
NewGauge(name string) metrics.Gauge
NewHistogram(name string, buckets int) metrics.Histogram
}
type RequestHandler interface {
HandleRequest(workerID int, msg *wrp.Message)
}
type CaduceusHandler struct {
senderWrapper SenderWrapper
*zap.Logger
}
func (ch *CaduceusHandler) HandleRequest(workerID int, msg *wrp.Message) {
ch.Logger.Info("Worker received a request, now passing to sender", zap.Int("workerId", workerID))
ch.senderWrapper.Queue(msg)
}