Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inferfacify TblPropsToggleRegistry for internal extension #211

Merged
merged 1 commit into from
Sep 24, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -1,31 +1,8 @@
package com.linkedin.openhouse.tables.config;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import javax.annotation.PostConstruct;
import org.springframework.stereotype.Component;

/** A central registry for all table properties that are managed through Feature Toggle */
@Component
public class TblPropsToggleRegistry {
public interface TblPropsToggleRegistry {

public static final String ENABLE_TBLTYPE = "enable_tabletype";

// TODO: Using these vocabularies as MySQL validation
private final Map<String, String> featureKeys = new HashMap<>();

@PostConstruct
public void initializeKeys() {
// placeholders: demo purpose
featureKeys.put("openhouse.tableType", ENABLE_TBLTYPE);
}

public Optional<String> obtainFeatureByKey(String key) {
return Optional.ofNullable(featureKeys.get(key));
}

public boolean isFeatureRegistered(String featureId) {
return featureKeys.containsValue(featureId);
}
Optional<String> obtainFeatureByKey(String key);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.linkedin.openhouse.tables.config;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import javax.annotation.PostConstruct;
import org.springframework.stereotype.Component;

/** A central registry for all table properties that are managed through Feature Toggle */
@Component
public class TblPropsToggleRegistryBaseImpl implements TblPropsToggleRegistry {

public static final String ENABLE_TBLTYPE = "enable_tabletype";
// TODO: Using these vocabularies as MySQL validation
private final Map<String, String> featureKeys = new HashMap<>();

@PostConstruct
public void initializeKeys() {
// placeholders: demo purpose
featureKeys.put("openhouse.tableType", ENABLE_TBLTYPE);
}

public Optional<String> obtainFeatureByKey(String key) {
return Optional.ofNullable(featureKeys.get(key));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import static com.linkedin.openhouse.common.api.validator.ValidatorConstants.INITIAL_TABLE_VERSION;
import static com.linkedin.openhouse.common.schema.IcebergSchemaHelper.*;
import static com.linkedin.openhouse.tables.config.TablesMvcConstants.*;
import static com.linkedin.openhouse.tables.config.TblPropsToggleRegistry.*;
import static com.linkedin.openhouse.tables.e2e.h2.ToggleH2StatusesRepository.*;
import static com.linkedin.openhouse.tables.e2e.h2.ValidationUtilities.*;
import static com.linkedin.openhouse.tables.model.DatabaseModelConstants.*;
import static com.linkedin.openhouse.tables.model.ServiceAuditModelConstants.*;
Expand Down Expand Up @@ -36,6 +34,7 @@
import com.linkedin.openhouse.tables.api.spec.v0.response.GetTableResponseBody;
import com.linkedin.openhouse.tables.audit.model.TableAuditEvent;
import com.linkedin.openhouse.tables.common.TableType;
import com.linkedin.openhouse.tables.config.TblPropsToggleRegistryBaseImpl;
import com.linkedin.openhouse.tables.mock.properties.AuthorizationPropertiesInitializer;
import com.linkedin.openhouse.tables.model.ServiceAuditModelConstants;
import com.linkedin.openhouse.tables.model.TableAuditModelConstants;
Expand Down Expand Up @@ -318,7 +317,7 @@ public void testTblPropsThruFeatureToggle() throws Exception {
*/
inMemToggleStatusRepo.save(
TableToggleStatus.builder()
.featureId(ENABLE_TBLTYPE)
.featureId(TblPropsToggleRegistryBaseImpl.ENABLE_TBLTYPE)
.tableId(GET_TABLE_RESPONSE_BODY.getTableId())
.databaseId(GET_TABLE_RESPONSE_BODY.getDatabaseId())
.toggleStatusEnum(ToggleStatus.StatusEnum.ACTIVE)
Expand Down
Loading