Skip to content

feat(events/natsjs): add NatsOptions to pass nats.Option values - #3

Merged
kobergj merged 2 commits into
kobergj:NatsjskvWatcherfrom
2403905:natsjs-nats-options
Oct 30, 2026
Merged

kobergj merged 2 commits into
kobergj:NatsjskvWatcherfrom
2403905:natsjs-nats-options

Conversation

@2403905

@2403905 2403905 commented Oct 23, 2026

Copy link
Copy Markdown

Description

The events/natsjs plugin builds its own nats.Options from a fixed set of fields. It cannot set JWT credentials. Thus it cannot connect to a NATS server that runs in operator (JWT) mode.

This PR adds the option natsjs.NatsOptions(...nats.Option). The plugin applies these values after all other options, so they take precedence. Use it with nats.UserCredentials or nats.UserCredentialBytes for JWT authentication.

reva (OCSRE-1629) uses this option to give .creds credentials to the event streams.

Changes

  • v4/events/natsjs: add NatsOptions. connectToNatsJetStream applies the values and returns an error when an option fails.
  • v4/events/natsjs: add jwt_test.go. The test starts a NATS server in operator mode and checks these cases:
    • no credentials
    • a valid creds file
    • valid creds bytes
    • creds of an unknown account
    • an option that fails
  • v4/events/natsjs, v4/store/nats-js-kv: bump nats.go to v1.54.0 and go to 1.26.10.

Tests

  • GOWORK=off go test ./... in v4/events/natsjs: TestNatsOptionsUserCredentials passes.
  • GOWORK=off go test ./... in v4/store/nats-js-kv: passes.
  • TestSingleEvent sometimes fails during the TempDir cleanup. The same flaky behavior occurs on the base commit. This PR does not cause it.

Follow-up

After the merge, reva must add a replace for github.com/go-micro/plugins/v4/events/natsjs to this fork. reva must also move the nats-js-kv replace to the new commit.

🤖 Generated with Claude Code

2403905 and others added 2 commits October 23, 2026 13:50
The plugin builds its own nats.Options from a fixed set of fields.
It cannot set JWT credentials, so it cannot connect to a NATS server
that runs in operator (JWT) mode.

The new option NatsOptions adds nats.Option values to the connection.
The plugin applies them last, so they take precedence. Use it with
nats.UserCredentials or nats.UserCredentialBytes for JWT credentials.

Bump nats.go to v1.54.0 and go to 1.26.10.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kobergj
kobergj merged commit 811a2de into kobergj:NatsjskvWatcher Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants