-
Notifications
You must be signed in to change notification settings - Fork 407
/
env_config.go
62 lines (51 loc) · 1.34 KB
/
env_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
package testing
import (
"time"
"github.com/kyma-project/kyma/components/event-publisher-proxy/pkg/env"
)
const (
defaultPort = 8080
)
func NewEnvConfig(emsCEURL, authURL string, opts ...EnvConfigOption) *env.EventMeshConfig {
envConfig := &env.EventMeshConfig{
Port: defaultPort,
EventMeshPublishURL: emsCEURL,
TokenEndpoint: authURL,
RequestTimeout: time.Minute,
}
for _, opt := range opts {
opt(envConfig)
}
return envConfig
}
type EnvConfigOption func(e *env.EventMeshConfig)
func WithPort(port int) EnvConfigOption {
return func(e *env.EventMeshConfig) {
e.Port = port
}
}
func WithMaxIdleConns(maxIdleConns int) EnvConfigOption {
return func(e *env.EventMeshConfig) {
e.MaxIdleConns = maxIdleConns
}
}
func WithMaxIdleConnsPerHost(maxIdleConnsPerHost int) EnvConfigOption {
return func(e *env.EventMeshConfig) {
e.MaxIdleConnsPerHost = maxIdleConnsPerHost
}
}
func WithRequestTimeout(requestTimeout time.Duration) EnvConfigOption {
return func(e *env.EventMeshConfig) {
e.RequestTimeout = requestTimeout
}
}
func WithNamespace(namespace string) EnvConfigOption {
return func(e *env.EventMeshConfig) {
e.EventMeshNamespace = namespace
}
}
func WithEventTypePrefix(eventTypePrefix string) EnvConfigOption {
return func(e *env.EventMeshConfig) {
e.EventTypePrefix = eventTypePrefix
}
}