nats-io / nats.rs

Rust client for NATS, the cloud native messaging system.
Apache License 2.0
980 stars 159 forks source link

Build failure with default_features = false #1242

Closed jaskij closed 2 months ago

jaskij commented 2 months ago

Observed behavior

When depending on async-nats = "0.34.0, if I set default-features = false, it fails to build with the following error:

error[E0560]: struct `jetstream::stream::Config` has no field named `compression`
    --> /home/jaskij/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-nats-0.34.0/src/jetstream/context.rs:1048:17
     |
1048 |                 compression: if config.compression {
     |                 ^^^^^^^^^^^ `jetstream::stream::Config` does not have this field
     |
     = note: available fields are: `max_bytes`, `max_messages`, `max_messages_per_subject`, `discard_new_per_subject`, `retention` ... and 12 others

For more information about this error, try `rustc --explain E0560`.
error: could not compile `async-nats` (lib) due to 1 previous error

Expected behavior

The crate builds and works as intended.

Server and client version

from my Cargo.toml

async-nats = { version = "0.34.0", default-features = false }

Host environment

up-to-date Arch Linux running on x86-64, building with current Rust stable

$ cargo --version
cargo 1.77.1 (e52e36006 2024-03-26)

Steps to reproduce

Make a Rust crate depending on async-nats 0.34.0 with default-features = false. It fails to build.

jaskij commented 2 months ago

Since your template doesn't have a field for comments: in your CI you should at least ensure every possible combination of feature flags builds, preferably test it to the extent possible. I have found cargo-hack extremely useful for this.

Jarema commented 2 months ago

Thanks for the report!

We can definately add this to Ci and of course fix the compilation.

However, I do not recommend running this crate with disabled default features, as those are related to working with older server versions.

Every new API or client feature is not enabled by default (like Service API).

jaskij commented 2 months ago

However, I do not recommend running this crate with disabled default features, as those are related to working with older server versions.

Having read the feature flag description (thanks for the quick update!), yeah, I will definitely enable server_2_10.