-
Notifications
You must be signed in to change notification settings - Fork 14
/
config.go
83 lines (73 loc) · 2.3 KB
/
config.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
package messagebroker
import (
"os"
"path/filepath"
"time"
)
// BrokerConfig holds broker's configuration
type BrokerConfig struct {
// A list of host/port pairs to use for establishing the initial connection to the broker cluster
Brokers []string
EnableTLS bool
UserCertificate string
UserKey string
CACertificate string
CertDir string
Version string
DebugEnabled bool
OperationTimeoutMs int
ConnectionTimeoutMs int
Producer *ProducerConfig
Consumer *ConsumerConfig
Admin *AdminConfig
}
// ProducerConfig holds producer's configuration'
type ProducerConfig struct {
RetryBackoff time.Duration
Partitioner string
MaxRetry int
MaxMessages int
CompressionEnabled bool
CompressionType string
RetryAck string
}
// ConsumerConfig holds consumer's configuration
type ConsumerConfig struct {
SubscriptionType int
OffsetReset string
EnableAutoCommit bool
}
// AdminConfig holds configuration for admin APIs
type AdminConfig struct {
EnableTopicCleanUp bool
}
// ConsumerClientOptions holds client specific configuration for consumer
type ConsumerClientOptions struct {
// Specify a list of topics to consume messages from
Topics []string
// Specify the subscription name for this consumer. Only used for pulsar
Subscription string
// A unique string that identifies the consumer group this consumer belongs to.
GroupID string
// A unique identifier of the consumer instance provided by the end user.
// Only non-empty strings are permitted. If set, the consumer is treated as a static member,
// which means that only one instance with this ID is allowed in the consumer group at any time
GroupInstanceID string
// Specify the auto offset reset value in case no offset is committed yet.
AutoOffsetReset string
}
// ProducerClientOptions holds client specific configuration for producer
type ProducerClientOptions struct {
Topic string
TimeoutMs int64
}
// AdminClientOptions holds client specific configuration for admin
type AdminClientOptions struct{}
func getCertFile(certDir, filename string) (string, error) {
configPath := certDir + filename
_, err := os.Stat(configPath)
if err == nil {
return filepath.Abs(configPath)
}
return "", err
}