This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
/
application_config_provider.go
124 lines (108 loc) · 4.15 KB
/
application_config_provider.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package runtime
import (
"github.com/flyteorg/flyteadmin/pkg/common"
"github.com/flyteorg/flyteadmin/pkg/runtime/interfaces"
"github.com/flyteorg/flytestdlib/config"
"github.com/flyteorg/flytestdlib/contextutils"
"github.com/flyteorg/flytestdlib/database"
)
const flyteAdmin = "flyteadmin"
const scheduler = "scheduler"
const remoteData = "remoteData"
const notifications = "notifications"
const domains = "domains"
const externalEvents = "externalEvents"
const cloudEvents = "cloudEvents"
const metricPort = 10254
const KB = 1024
const MB = KB * KB
var flyteAdminConfig = config.MustRegisterSection(flyteAdmin, &interfaces.ApplicationConfig{
ProfilerPort: metricPort,
MetricsScope: "flyte:",
MetricKeys: []string{contextutils.ProjectKey.String(), contextutils.DomainKey.String(),
contextutils.WorkflowIDKey.String(), contextutils.TaskIDKey.String(), contextutils.PhaseKey.String(),
contextutils.TaskTypeKey.String(), common.RuntimeTypeKey.String(), common.RuntimeVersionKey.String(),
contextutils.AppNameKey.String()},
MetadataStoragePrefix: []string{"metadata", "admin"},
EventVersion: 2,
AsyncEventsBufferSize: 100,
MaxParallelism: 25,
K8SServiceAccount: "",
UseOffloadedWorkflowClosure: false,
})
var schedulerConfig = config.MustRegisterSection(scheduler, &interfaces.SchedulerConfig{
ProfilerPort: config.Port{Port: metricPort},
EventSchedulerConfig: interfaces.EventSchedulerConfig{
Scheme: common.Local,
FlyteSchedulerConfig: &interfaces.FlyteSchedulerConfig{},
},
WorkflowExecutorConfig: interfaces.WorkflowExecutorConfig{
Scheme: common.Local,
FlyteWorkflowExecutorConfig: &interfaces.FlyteWorkflowExecutorConfig{
AdminRateLimit: &interfaces.AdminRateLimit{
Tps: 100,
Burst: 10,
},
},
},
})
var remoteDataConfig = config.MustRegisterSection(remoteData, &interfaces.RemoteDataConfig{
Scheme: common.None,
MaxSizeInBytes: 2 * MB,
InlineEventDataPolicy: interfaces.InlineEventDataPolicyOffload,
SignedURL: interfaces.SignedURL{
Enabled: false,
},
})
var notificationsConfig = config.MustRegisterSection(notifications, &interfaces.NotificationsConfig{
Type: common.Local,
})
var domainsConfig = config.MustRegisterSection(domains, &interfaces.DomainsConfig{
{
ID: "development",
Name: "development",
},
{
ID: "staging",
Name: "staging",
},
{
ID: "production",
Name: "production",
},
})
var externalEventsConfig = config.MustRegisterSection(externalEvents, &interfaces.ExternalEventsConfig{
Type: common.Local,
})
var cloudEventsConfig = config.MustRegisterSection(cloudEvents, &interfaces.CloudEventsConfig{
Type: common.Local,
})
// Implementation of an interfaces.ApplicationConfiguration
type ApplicationConfigurationProvider struct{}
func (p *ApplicationConfigurationProvider) GetDbConfig() *database.DbConfig {
return database.GetConfig()
}
func (p *ApplicationConfigurationProvider) GetTopLevelConfig() *interfaces.ApplicationConfig {
return flyteAdminConfig.GetConfig().(*interfaces.ApplicationConfig)
}
func (p *ApplicationConfigurationProvider) GetSchedulerConfig() *interfaces.SchedulerConfig {
return schedulerConfig.GetConfig().(*interfaces.SchedulerConfig)
}
func (p *ApplicationConfigurationProvider) GetRemoteDataConfig() *interfaces.RemoteDataConfig {
return remoteDataConfig.GetConfig().(*interfaces.RemoteDataConfig)
}
func (p *ApplicationConfigurationProvider) GetNotificationsConfig() *interfaces.NotificationsConfig {
return notificationsConfig.GetConfig().(*interfaces.NotificationsConfig)
}
func (p *ApplicationConfigurationProvider) GetDomainsConfig() *interfaces.DomainsConfig {
return domainsConfig.GetConfig().(*interfaces.DomainsConfig)
}
func (p *ApplicationConfigurationProvider) GetExternalEventsConfig() *interfaces.ExternalEventsConfig {
return externalEventsConfig.GetConfig().(*interfaces.ExternalEventsConfig)
}
func (p *ApplicationConfigurationProvider) GetCloudEventsConfig() *interfaces.CloudEventsConfig {
return cloudEventsConfig.GetConfig().(*interfaces.CloudEventsConfig)
}
func NewApplicationConfigurationProvider() interfaces.ApplicationConfiguration {
return &ApplicationConfigurationProvider{}
}