Repository: risingwavelabs/risingwave
File: src/license/src/feature.rs (Rust)

Code before:
    }

    /// Description of the feature.
    pub fn description(self) -> &'static str {
        self.get_documentation().unwrap_or_default()
    }

    /// Get a slice of all features.
    pub fn all() -> &'static [Feature] {
        Feature::VARIANTS
    }

    /// Get a slice of all features available as of 2.5 (before we introduce custom tier).
    pub(crate) fn all_as_of_2_5() -> &'static [Feature] {
        // `IcebergCompaction` was the last feature introduced.
        &Feature::all()[..=Feature::IcebergCompaction as usize]
    }
}

/// The error type for feature not available due to license.
#[derive(Debug, Error)]
pub enum FeatureNotAvailable {
    // TODO(license): refine error message to include tier name & better instructions
    #[error(
        "feature {feature:?} is not available based on your license\n\n\
        Hint: You may want to set a license key with `ALTER SYSTEM SET license_key = '...';` command. Please contact sales at sales@risingwave-labs.com for more information."
    )]
    NotAvailable { feature: Feature },

    #[error("feature {feature:?} is not available due to license error")]
    LicenseError {
        feature: Feature,
        source: LicenseError,
    },
}

impl Feature {
    /// Check whether the feature is available based on the given license manager.
    pub(crate) fn check_available_with(
        self,
        manager: &LicenseManager,
    ) -> Result<(), FeatureNotAvailable> {
        let check_res = match manager.license() {
            Ok(license) => {
                if license.tier.available_features().any(|x| x == self) {
                    Ok(())
                } else {
                    Err(FeatureNotAvailable::NotAvailable { feature: self })
                }
            }
            Err(error) => Err(FeatureNotAvailable::LicenseError {

Review comment (suggestion):
Actually I've generated a short link `https://go.risingwave.com/premium`. Shall we use it instead? The contact info is also at the bottom of the page.

Code after:
    }

    /// Description of the feature.
    pub fn description(self) -> &'static str {
        self.get_documentation().unwrap_or_default()
    }

    /// Get a slice of all features.
    pub fn all() -> &'static [Feature] {
        Feature::VARIANTS
    }

    /// Get a slice of all features available as of 2.5 (before we introduce custom tier).
    pub(crate) fn all_as_of_2_5() -> &'static [Feature] {
        // `IcebergCompaction` was the last feature introduced.
        &Feature::all()[..=Feature::IcebergCompaction as usize]
    }
}

/// The error type for feature not available due to license.
#[derive(Debug, Error)]
pub enum FeatureNotAvailable {
    // TODO(license): refine error message to include tier name & better instructions
    #[error(
        "feature {feature:?} is not available based on your license\n\n\
        Hint: You may want to set a license key with `ALTER SYSTEM SET license_key = '...';` command. For more information, visit https://go.risingwave.com/premium."
    )]
    NotAvailable { feature: Feature },

    #[error("feature {feature:?} is not available due to license error")]
    LicenseError {
        feature: Feature,
        source: LicenseError,
    },
}

impl Feature {
    /// Check whether the feature is available based on the given license manager.
    pub(crate) fn check_available_with(
        self,
        manager: &LicenseManager,
    ) -> Result<(), FeatureNotAvailable> {
        let check_res = match manager.license() {
            Ok(license) => {
                if license.tier.available_features().any(|x| x == self) {
                    Ok(())
                } else {
                    Err(FeatureNotAvailable::NotAvailable { feature: self })
                }
            }
            Err(error) => Err(FeatureNotAvailable::LicenseError {