Skip to content

Conversation

@caspervonb
Copy link
Collaborator

@caspervonb caspervonb commented Sep 22, 2025

This adds a nats.server package which provides utilities for spawning nats server processes.

@caspervonb caspervonb force-pushed the add-nats-server-package branch 3 times, most recently from d2d090c to 9174ca1 Compare September 22, 2025 12:02
@caspervonb caspervonb requested a review from Copilot September 22, 2025 12:22
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new nats-server Python package that provides programmatic control of NATS server instances for development and testing purposes. The package wraps the NATS server binary to enable easy server lifecycle management from Python code.

  • Provides an asynchronous Server class for managing NATS server processes
  • Implements a run() function for starting servers with configurable options (port, JetStream, config files)
  • Includes comprehensive test coverage for various server configurations and edge cases

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
nats-server/src/nats/server/init.py Core implementation with Server class and run() function for managing NATS server processes
nats-server/tests/test_server.py Comprehensive test suite covering server startup, configuration, and error scenarios
nats-server/tests/conftest.py Pytest fixtures for ensuring NATS server availability and port management
nats-server/tests/configs/*.conf Test configuration files for various NATS server settings
nats-server/pyproject.toml Package configuration with dependencies and build settings
nats-server/README.md Package documentation with usage examples
.github/workflows/test.yml CI workflow updates to include testing for the new package

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@caspervonb caspervonb force-pushed the add-nats-server-package branch 2 times, most recently from 83d0f80 to 44fb982 Compare September 22, 2025 13:14
Copy link
Member

@Jarema Jarema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this is missing cleanup of JetStream resources?

@caspervonb
Copy link
Collaborator Author

I think that this is missing cleanup of JetStream resources?

Referring to store_dir? Since it's passed in, won't delete it.
Either you'll pass in a tempdir (what tests fixtures tend to do, or it's a real store dir which we won't touch). In the case of a tempdir just leaving it to the OS to reclaim.

@wallyqs
Copy link
Member

wallyqs commented Sep 23, 2025

can't this all be under tests folder?

@wallyqs
Copy link
Member

wallyqs commented Sep 23, 2025

also should try to add cluster setup to smoke test features on R3s, publishing while there are leader elections, etc...

@caspervonb
Copy link
Collaborator Author

caspervonb commented Sep 23, 2025

can't this all be under tests folder?

Intent is to make it a workspace, where nats.client, nats.jetstream etc are their own packages with namespace modules, so because they're packages, nats.server itself is a shared package.

Top level package (nats) eventually becomes a set of feature-gated optional dependencies with re-exports.

@caspervonb caspervonb requested a review from Jarema September 23, 2025 08:52
@Jarema
Copy link
Member

Jarema commented Sep 23, 2025

@caspervonb I would make some utility to easily create temp storage and cleanup method afterwards. After all, that will be used in every JetStream test. Whatever makes it convinient.

@wallyqs
Copy link
Member

wallyqs commented Sep 23, 2025

I think you need to clarify the intent that this is for testing, so would prefer if you move to be under a nats.test.server namespace or something similar

Copy link
Member

@wallyqs wallyqs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Rollback from using src/ folder
  • Use specific namespace for testing
  • Add clustering example

@caspervonb
Copy link
Collaborator Author

caspervonb commented Sep 23, 2025

@Jarema I would make some utility to easily create temp storage and cleanup method afterwards. After all, that will be used in every JetStream test. Whatever makes it convinient.

Because of pytest fixtures, feels redundant.
If you look at conftest.py in #734 you'll see how the tempdir teardown works in practice.

@wallyqs Rollback from using src/ folder

Why tho? without it source files are littered in the package directory next to everything else, need to explicitly list each thing to be packaged in wheels, source dists etc.

@wallyqs Use specific namespace for testing

How about we mark it explicitly as private = true for now.

Changing the namespace means a lot of merge conflicts in the current merge queue.

@wallyqs Add clustering example

No cluster support at the moment. But yes, we need to add that soon but not in the scope of this pull request imho.

project: ["nats-server"]
steps:
- name: Checkout repository
uses: actions/checkout@v2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current version is @v5; v2 used Node 12, and Node 16 is currently being deprecated by GH. I'm impressed this even works.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bumped them.

uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use @v6 for: actions/setup-go@v6; v2 was node12.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bumped them.

shell: bash

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python: @v6; v2 was node12.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bumped them.

@caspervonb caspervonb force-pushed the add-nats-server-package branch from 5871d4f to 8c151c0 Compare September 24, 2025 09:54
@caspervonb caspervonb requested a review from Copilot September 25, 2025 13:48
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@caspervonb caspervonb requested a review from Copilot September 25, 2025 13:49
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Flosckow
Copy link

@caspervonb, will there be support for the features from version 2.11 in this and related pulll requests?

@caspervonb
Copy link
Collaborator Author

@caspervonb, will there be support for the features from version 2.11 in this and related pulll requests?

@Flosckow yes, new jetstream package will have everything.

@caspervonb caspervonb force-pushed the add-nats-server-package branch from 036825e to ecb1a58 Compare October 3, 2025 10:18
@caspervonb caspervonb requested a review from philpennock October 3, 2025 10:23
@caspervonb caspervonb force-pushed the add-nats-server-package branch from 4d4529e to accfd1c Compare October 3, 2025 10:24
Signed-off-by: Casper Beyer <casper@synadia.com>
@caspervonb caspervonb force-pushed the add-nats-server-package branch from accfd1c to 20963ae Compare October 3, 2025 10:28
@caspervonb caspervonb merged commit 172f3f9 into main Oct 3, 2025
56 checks passed
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.

6 participants