All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nepxion.discovery.plugin.strategy.sentinel.apollo.loader.SentinelApolloRuleLoader Maven / Gradle / Ivy

The newest version!
package com.nepxion.discovery.plugin.strategy.sentinel.apollo.loader;

/**
 * 

Title: Nepxion Discovery

*

Description: Nepxion Discovery

*

Copyright: Copyright (c) 2017-2050

*

Company: Nepxion

* @author Weihua Wang * @author Haojun Ren * @version 1.0 */ import java.util.List; import com.alibaba.csp.sentinel.datasource.ReadableDataSource; import com.alibaba.csp.sentinel.datasource.apollo.ApolloDataSource; import com.alibaba.csp.sentinel.slots.block.authority.AuthorityRule; import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule; import com.alibaba.csp.sentinel.slots.block.flow.FlowRule; import com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowRule; import com.alibaba.csp.sentinel.slots.system.SystemRule; import com.nepxion.discovery.common.apollo.configuration.ApolloAutoConfiguration; import com.nepxion.discovery.common.apollo.constant.ApolloConstant; import com.nepxion.discovery.plugin.strategy.sentinel.constant.SentinelStrategyConstant; import com.nepxion.discovery.plugin.strategy.sentinel.loader.SentinelDataSourceRuleLoader; public class SentinelApolloRuleLoader extends SentinelDataSourceRuleLoader { private String namespace; @Override public void initialize() { namespace = ApolloAutoConfiguration.getNamespace(applicationContext.getEnvironment()); } @Override public ReadableDataSource> getFlowRuleDataSource() { return new ApolloDataSource<>(namespace, pluginAdapter.getGroup() + "-" + pluginAdapter.getServiceId() + "-" + SentinelStrategyConstant.SENTINEL_FLOW_KEY, null, sentinelFlowRuleParser); } @Override public ReadableDataSource> getDegradeRuleDataSource() { return new ApolloDataSource<>(namespace, pluginAdapter.getGroup() + "-" + pluginAdapter.getServiceId() + "-" + SentinelStrategyConstant.SENTINEL_DEGRADE_KEY, null, sentinelDegradeRuleParser); } @Override public ReadableDataSource> getAuthorityRuleDataSource() { return new ApolloDataSource<>(namespace, pluginAdapter.getGroup() + "-" + pluginAdapter.getServiceId() + "-" + SentinelStrategyConstant.SENTINEL_AUTHORITY_KEY, null, sentinelAuthorityRuleParser); } @Override public ReadableDataSource> getSystemRuleDataSource() { return new ApolloDataSource<>(namespace, pluginAdapter.getGroup() + "-" + pluginAdapter.getServiceId() + "-" + SentinelStrategyConstant.SENTINEL_SYSTEM_KEY, null, sentinelSystemRuleParser); } @Override public ReadableDataSource> getParamFlowRuleDataSource() { return new ApolloDataSource<>(namespace, pluginAdapter.getGroup() + "-" + pluginAdapter.getServiceId() + "-" + SentinelStrategyConstant.SENTINEL_PARAM_FLOW_KEY, null, sentinelParamFlowRuleParser); } @Override public String getConfigType() { return ApolloConstant.APOLLO_TYPE; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy