Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion src/main/java/io/stargate/sgv2/jsonapi/JsonApiStartUp.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,23 @@
import io.stargate.sgv2.jsonapi.api.request.tenant.TenantFactory;
import io.stargate.sgv2.jsonapi.config.BillingConfig;
import io.stargate.sgv2.jsonapi.config.DebugModeConfig;
import io.stargate.sgv2.jsonapi.config.DeploymentMarkerConfig;
import io.stargate.sgv2.jsonapi.config.OperationsConfig;
import io.stargate.sgv2.jsonapi.config.feature.ApiFeature;
import io.stargate.sgv2.jsonapi.config.feature.ApiFeatures;
import io.stargate.sgv2.jsonapi.config.feature.FeaturesConfig;
import jakarta.enterprise.event.Observes;
import jakarta.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class JsonApiStartUp {

private static final Logger LOGGER = LoggerFactory.getLogger(JsonApiStartUp.class);

private final OperationsConfig operationsConfig;
private final DeploymentMarkerConfig deploymentMarkerConfig;
private final FeaturesConfig featuresConfig;

/**
* {@link DebugModeConfig} and {@link BillingConfig} are injected here purely to anchor them as
Expand All @@ -26,11 +36,30 @@ public class JsonApiStartUp {
*/
@Inject
public JsonApiStartUp(
DebugModeConfig config, OperationsConfig operationsConfig, BillingConfig billingConfig) {
DebugModeConfig config,
OperationsConfig operationsConfig,
BillingConfig billingConfig,
DeploymentMarkerConfig deploymentMarkerConfig,
FeaturesConfig featuresConfig) {
this.operationsConfig = operationsConfig;
this.deploymentMarkerConfig = deploymentMarkerConfig;
this.featuresConfig = featuresConfig;
}

void onStart(@Observes StartupEvent ev) {
TenantFactory.initialize(operationsConfig.databaseConfig().type());

// Observation point for deployment drills, see DeploymentMarkerConfig.
// Disabled by default, in which case nothing is logged here.
if (deploymentMarkerConfig.enabled()) {
LOGGER.info("Deployment config enabled - marker={}", deploymentMarkerConfig.value());
}

// Startup-resolved feature flag state (configuration only — request headers cannot apply
// here). Logged unconditionally so the effective state is observable from the pod log.
ApiFeatures apiFeatures = ApiFeatures.fromConfigAndRequest(featuresConfig, null);
LOGGER.info(
"ApiFeature DEPLOYMENT_MARKER enabled={}",
apiFeatures.isFeatureEnabled(ApiFeature.DEPLOYMENT_MARKER));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.stargate.sgv2.jsonapi.config;

import io.smallrye.config.ConfigMapping;
import io.smallrye.config.WithDefault;
import java.util.Optional;

@ConfigMapping(prefix = "stargate.jsonapi.deployment.env")
public interface DeploymentMarkerConfig {

@WithDefault("false")
boolean enabled();

Optional<String> deployCloud();

Optional<String> deploy_region();

@WithDefault("0")
int value();
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ public enum ApiFeature {
*
* <p>Disabled by default.
*/
BILLING_EVENTS_LOGGING("billing-events-logging", false);
BILLING_EVENTS_LOGGING("billing-events-logging", false),

DEPLOYMENT_MARKER("deployment-marker", false);

/**
* Prefix for HTTP headers used to override feature flags for specific requests: prepended before
Expand Down
Loading