@@ -3,6 +3,8 @@ package config
33
44import (
55 "errors"
6+ "fmt"
7+ "regexp"
68 "strings"
79 "time"
810
@@ -15,6 +17,8 @@ import (
1517 "github.com/openmeterio/openmeter/pkg/models"
1618)
1719
20+ type ReservedEventTypePattern = string
21+
1822// Configuration holds any kind of Configuration that comes from the outside world and
1923// is necessary for running the application.
2024type Configuration struct {
@@ -25,24 +29,25 @@ type Configuration struct {
2529
2630 Termination TerminationConfig
2731
28- Aggregation AggregationConfiguration
29- Entitlements EntitlementsConfiguration
30- Customer CustomerConfiguration
31- Dedupe DedupeConfiguration
32- Events EventsConfiguration
33- Ingest IngestConfiguration
34- Meters []* meter.Meter
35- Namespace NamespaceConfiguration
36- Portal PortalConfiguration
37- Postgres PostgresConfig
38- Sink SinkConfiguration
39- BalanceWorker BalanceWorkerConfiguration
40- Notification NotificationConfiguration
41- ProductCatalog ProductCatalogConfiguration
42- ProgressManager ProgressManagerConfiguration
43- Billing BillingConfiguration
44- Apps AppsConfiguration
45- Svix SvixConfig
32+ Aggregation AggregationConfiguration
33+ Entitlements EntitlementsConfiguration
34+ Customer CustomerConfiguration
35+ Dedupe DedupeConfiguration
36+ Events EventsConfiguration
37+ Ingest IngestConfiguration
38+ Meters []* meter.Meter
39+ ReservedEventTypes []ReservedEventTypePattern
40+ Namespace NamespaceConfiguration
41+ Portal PortalConfiguration
42+ Postgres PostgresConfig
43+ Sink SinkConfiguration
44+ BalanceWorker BalanceWorkerConfiguration
45+ Notification NotificationConfiguration
46+ ProductCatalog ProductCatalogConfiguration
47+ ProgressManager ProgressManagerConfiguration
48+ Billing BillingConfiguration
49+ Apps AppsConfiguration
50+ Svix SvixConfig
4651}
4752
4853// Validate validates the configuration.
@@ -107,6 +112,12 @@ func (c Configuration) Validate() error {
107112 }
108113 }
109114
115+ for _ , pattern := range c .ReservedEventTypes {
116+ if _ , err := regexp .Compile (pattern ); err != nil {
117+ errs = append (errs , fmt .Errorf ("reserved event type pattern %q: invalid regular expression" , pattern ))
118+ }
119+ }
120+
110121 if err := c .BalanceWorker .Validate (); err != nil {
111122 errs = append (errs , errorsx .WithPrefix (err , "balance worker" ))
112123 }
0 commit comments