diff --git a/router-tests/events/nats_events_test.go b/router-tests/events/nats_events_test.go index 3a42dc1467..f7ee66c9af 100644 --- a/router-tests/events/nats_events_test.go +++ b/router-tests/events/nats_events_test.go @@ -1213,7 +1213,7 @@ func TestNatsEvents(t *testing.T) { }, ModifyEventsConfiguration: func(cfg *config.EventsConfiguration) { for i := range cfg.Providers.Nats { - cfg.Providers.Nats[i].Consumers.Durable.DeleteOnShutdown = true + cfg.Providers.Nats[i].DeleteDurableConsumersOnShutdown = true } }, }) @@ -1270,7 +1270,7 @@ func TestNatsEvents(t *testing.T) { }, ModifyEventsConfiguration: func(cfg *config.EventsConfiguration) { for i := range cfg.Providers.Nats { - cfg.Providers.Nats[i].Consumers.Durable.DeleteOnShutdown = false + cfg.Providers.Nats[i].DeleteDurableConsumersOnShutdown = false } }, }) diff --git a/router/pkg/config/config.go b/router/pkg/config/config.go index ba52f28ba7..e40812f34a 100644 --- a/router/pkg/config/config.go +++ b/router/pkg/config/config.go @@ -616,19 +616,11 @@ type NatsAuthentication struct { NatsTokenBasedAuthentication `yaml:"token,inline"` } -type NatsDurableConsumersConfiguration struct { - DeleteOnShutdown bool `yaml:"delete_on_shutdown" envDefault:"false"` -} - -type NatsConsumersConfiguration struct { - Durable NatsDurableConsumersConfiguration `yaml:"durable,omitempty"` -} - type NatsEventSource struct { - ID string `yaml:"id,omitempty"` - URL string `yaml:"url,omitempty"` - Authentication *NatsAuthentication `yaml:"authentication,omitempty"` - Consumers NatsConsumersConfiguration `yaml:"consumers,omitempty"` + ID string `yaml:"id,omitempty"` + URL string `yaml:"url,omitempty"` + Authentication *NatsAuthentication `yaml:"authentication,omitempty"` + DeleteDurableConsumersOnShutdown bool `yaml:"experiment_delete_durable_consumers_on_shutdown"` } func (n NatsEventSource) GetID() string { diff --git a/router/pkg/config/config.schema.json b/router/pkg/config/config.schema.json index ac01bedeb7..6cef0fc2e2 100644 --- a/router/pkg/config/config.schema.json +++ b/router/pkg/config/config.schema.json @@ -20,7 +20,7 @@ "properties": { "token": { "type": "string", - "description": "The token used to authenticate with other component from Cosmo. Can be ommitted if the router is started with a static execution config." + "description": "The token used to authenticate with other component from Cosmo. Can be omitted if the router is started with a static execution config." }, "sign_key": { "type": "string", @@ -2581,24 +2581,10 @@ } ] }, - "consumers": { - "type": "object", - "description": "Configuration for JetStream consumers managed by this NATS provider.", - "additionalProperties": false, - "properties": { - "durable": { - "type": "object", - "description": "Configuration for durable JetStream consumers managed by this NATS provider.", - "additionalProperties": false, - "properties": { - "delete_on_shutdown": { - "type": "boolean", - "description": "When enabled, all durable JetStream consumers created by this provider are deleted when the router shuts down normally. Defaults to false.", - "default": false - } - } - } - } + "experiment_delete_durable_consumers_on_shutdown": { + "type": "boolean", + "description": "When enabled, all durable JetStream consumers created by this provider are deleted when the router shuts down normally. Defaults to false. NOTE: This option is experimental and may change in future versions.", + "default": false } } } diff --git a/router/pkg/config/testdata/config_full.json b/router/pkg/config/testdata/config_full.json index e9e85f1e97..98c86135c7 100644 --- a/router/pkg/config/testdata/config_full.json +++ b/router/pkg/config/testdata/config_full.json @@ -657,11 +657,7 @@ "ID": "default", "URL": "nats://localhost:4222", "Authentication": null, - "Consumers": { - "Durable": { - "DeleteOnShutdown": false - } - } + "DeleteDurableConsumersOnShutdown": false }, { "ID": "my-nats", @@ -673,11 +669,7 @@ }, "Token": null }, - "Consumers": { - "Durable": { - "DeleteOnShutdown": false - } - } + "DeleteDurableConsumersOnShutdown": false } ], "Kafka": [ diff --git a/router/pkg/pubsub/nats/provider_builder.go b/router/pkg/pubsub/nats/provider_builder.go index 17b1e4febb..8b590d7494 100644 --- a/router/pkg/pubsub/nats/provider_builder.go +++ b/router/pkg/pubsub/nats/provider_builder.go @@ -123,7 +123,7 @@ func buildProvider(ctx context.Context, provider config.NatsEventSource, logger return nil, fmt.Errorf("failed to build options for Nats provider with ID \"%s\": %w", provider.ID, err) } - adapter, err := NewAdapter(ctx, logger, provider.URL, options, hostName, routerListenAddr, provider.Consumers.Durable.DeleteOnShutdown, providerOpts) + adapter, err := NewAdapter(ctx, logger, provider.URL, options, hostName, routerListenAddr, provider.DeleteDurableConsumersOnShutdown, providerOpts) if err != nil { return nil, fmt.Errorf("failed to create adapter for Nats provider with ID \"%s\": %w", provider.ID, err) }