collado-mike commented on code in PR #459:
URL: https://github.com/apache/polaris/pull/459#discussion_r1852940725
##########
polaris-service/src/test/java/org/apache/polaris/service/config/DefaultConfigurationStoreTest.java:
##########
@@ -106,4 +111,77 @@ public void testGetRealmConfiguration() {
String keyTwoRealm3 =
defaultConfigurationStore.getConfiguration(realm3Ctx, "key2");
assertThat(keyTwoRealm3).isEqualTo(defaultKeyTwoValue);
}
+
+ @Test
+ public void testDynamicConfig() {
+ InMemoryPolarisMetaStoreManagerFactory metastoreFactory =
+ new InMemoryPolarisMetaStoreManagerFactory();
+ PolarisCallContext polarisCtx =
+ new PolarisCallContext(
+ metastoreFactory.getOrCreateSessionSupplier(() -> "realm1").get(),
+ new PolarisDefaultDiagServiceImpl());
+
+ String key = "k1";
+ Map<String, Object> staticConfig = Map.of(key, 10);
+
+ assertThat(
+ new DefaultConfigurationStore(staticConfig, Map.of(), k ->
Optional.empty())
+ .<Integer>getConfiguration(polarisCtx, key))
+ .as("The DynamicFeatureConfigResolver always returns Optional.empty()")
+ .isEqualTo(10);
+
+ assertThat(
+ new DefaultConfigurationStore(staticConfig, Map.of(), k ->
Optional.of(5))
+ .<Integer>getConfiguration(polarisCtx, key))
+ .as("The DynamicFeatureConfigResolver always returns 5")
+ .isEqualTo(5);
+ }
+
+ @ParameterizedTest
+ @MethodSource("getTestConfigs")
+ public void
testPrecedenceIsDynamicThenStaticPerRealmThenStaticGlobal(TestConfig
testConfig) {
Review Comment:
What about catalog-level? I'd assume the catalog-level properties take
precedence over everything, right?
##########
polaris-service/src/main/java/org/apache/polaris/service/config/DynamicFeatureConfigResolver.java:
##########
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.polaris.service.config;
+
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import io.dropwizard.jackson.Discoverable;
+import java.util.Optional;
+
+/**
+ * DynamicFeatureConfigResolvers dynamically resolve featureConfigurations.
This is useful for
+ * integration with feature flag systems which are intended for fetching
configs at runtime.
+ */
+@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY,
property = "type")
+public interface DynamicFeatureConfigResolver extends Discoverable {
Review Comment:
TBH, I feel that this type _should_ be unnecessary. Unfortunately, we just
added the `featureConfiguration` field as a map, rather than having the
`DefaultConfigurationStore` instantiated and populated by Jackson during
application startup. Now the configuration can't really change to add, e.g., a
`type` configuration key so that we could use different
`PolarisConfigurationStore` implementations. The `PolarisConfigurationStore`
interface was always intended to support dynamic implementations - which is why
the `PolarisCallContext` is part of the signature.
I'm just trying to figure out if there isn't a way to make the
implementation swappable, while still supporting the backward-compatible
configuration. I mean, there's no real harm in adding another interface, but it
just feels unnecessary and the consequence of poor decision making earlier on.
I hate the idea of that poor decision making having to follow us around forever.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]