Skip to content

Commit

Permalink
Revert legacy support for jetstream:// scheme
Browse files Browse the repository at this point in the history
Existing deployments using this scheme will effectively ignore the
embedded server options.

Signed-off-by: Byron Ruth <byron@nats.io>
  • Loading branch information
bruth authored and brandond committed May 5, 2023
1 parent a726c17 commit 27e1494
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 11 additions & 1 deletion pkg/drivers/nats/nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ type JSValue struct {
// New return an implementation of server.Backend using NATS + JetStream.
// See the `examples/nats.md` file for examples of connection strings.
func New(ctx context.Context, connection string, tlsInfo tls.Config) (server.Backend, error) {
return newBackend(ctx, connection, tlsInfo, false)
}

// NewLegacy return an implementation of server.Backend using NATS + JetStream
// with legacy jetstream:// behavior, ignoring the embedded server.
func NewLegacy(ctx context.Context, connection string, tlsInfo tls.Config) (server.Backend, error) {
return newBackend(ctx, connection, tlsInfo, true)
}

func newBackend(ctx context.Context, connection string, tlsInfo tls.Config, legacy bool) (server.Backend, error) {
config, err := parseConnection(connection, tlsInfo)
if err != nil {
return nil, err
Expand All @@ -123,7 +133,7 @@ func New(ctx context.Context, connection string, tlsInfo tls.Config) (server.Bac
nopts := append(config.clientOptions, nats.Name("kine using bucket: "+config.bucket))

// Run an embedded server if available and not disabled.
if natsserver.Embedded && !config.noEmbed {
if !legacy && natsserver.Embedded && !config.noEmbed {
logrus.Infof("using an embedded NATS server")

ns, err := natsserver.New(&natsserver.Config{
Expand Down
4 changes: 3 additions & 1 deletion pkg/endpoint/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ func getKineStorageBackend(ctx context.Context, driver, dsn string, cfg Config)
backend, err = pgsql.New(ctx, dsn, cfg.BackendTLSConfig, cfg.ConnectionPoolConfig, cfg.MetricsRegisterer)
case MySQLBackend:
backend, err = mysql.New(ctx, dsn, cfg.BackendTLSConfig, cfg.ConnectionPoolConfig, cfg.MetricsRegisterer)
case NATSBackend, JetStreamBackend:
case JetStreamBackend:
backend, err = nats.NewLegacy(ctx, dsn, cfg.BackendTLSConfig)
case NATSBackend:
backend, err = nats.New(ctx, dsn, cfg.BackendTLSConfig)
default:
return false, nil, fmt.Errorf("storage backend is not defined")
Expand Down

0 comments on commit 27e1494

Please sign in to comment.