SearchDynamicConfigService.java
5.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
package com.yoho.search.common;
import com.yoho.core.config.ConfigReader;
import com.yoho.search.aop.downgrade.PersionalRateLimit;
import com.yoho.search.aop.downgrade.PersionalRateLimitConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class SearchDynamicConfigService {
private static final Logger logger = LoggerFactory.getLogger(SearchDynamicConfigService.class);
@Autowired
private ConfigReader configReader;
/**
* 是否开启个性化
*/
public boolean openPersonalized() {
return configReader.getBoolean("search.degrade.open.personalized", true);
}
/**
* 搜索结果是否包含全球购
*/
public boolean containglobal() {
return configReader.getBoolean("search.degrade.open.containglobal", true);
}
/**
* 是否返回变价计划
*/
public boolean pricePlanOpen() {
return configReader.getBoolean("search.price.plan.open", true);
}
/**
* 频道降分是否打开
*/
public boolean isDeScorePhysicalChannelOpen() {
return configReader.getBoolean("search.degrade.descore.physicalchannel.open", true);
}
/**
* 频道降分权重
*/
public double getDeScorePhysicalChannelWeight() {
return configReader.getDouble("search.degrade.descore.physicalchannel.value", 0.6);
}
/**
* 是否打开搜索无结果或结果太少时的搜索提示功能
*/
public boolean isSearchSuggestionTipsOpen() {
return configReader.getBoolean("search.suggestion.tips.open", true);
}
/**
* 关于API查看动态参数值
*/
public String getDynamicParameterValue(String key) {
return configReader.getString(key, "DEFAULT");
}
/**
* 新品到着页的根据首次上架时间衰减函数规则值
*/
public String getNewArrivalPageDecayRuleValue() {
return configReader.getString("search.function.score.new_arrival_page_decay_rule", "4,1");
}
/**
* 非新品到着页的根据首次上架时间衰减函数规则值
*/
public String getOtherPageDecayRuleValue() {
return configReader.getString("search.function.score.other_page_decay_rule", "30,7");
}
/**
* 个性化限流配置
*/
public PersionalRateLimitConfig getPersionalRateLimitConfig(String rateLimitName, PersionalRateLimit persionalRateLimit) {
try {
String zkConfigKey = "search.persional.rateLimit" + rateLimitName.replaceAll("/", ".");
PersionalRateLimitConfig defalut = new PersionalRateLimitConfig(persionalRateLimit);
String zkConfigValue = configReader.getString(zkConfigKey, defalut.toZkValue());
return new PersionalRateLimitConfig(zkConfigValue);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return new PersionalRateLimitConfig(200, 10);
}
}
/**
* 个性化限流开关【双11打开】
*/
public boolean isPersionalRateLimitOpen() {
return configReader.getBoolean("search.persional.rateLimit.open", true);
}
/**
* 使用新的的召回策略
*/
public boolean searchPersionalNewStrategyOpen() {
return configReader.getBoolean("search.persional.newstrategy.open", true);
}
/**
* 促销页使用新的的召回策略
*/
public boolean searchPersionalNewStrategyPromotionOpen() {
return configReader.getBoolean("search.persional.newstrategy.promotion.open", true);
}
/**
* 新的的召回策略-第一页是否缓存
*/
public boolean searchPersionalNewStrategyFirstPageCacheOpen() {
return configReader.getBoolean("search.persional.newstrategy.first_page_cache.open", false);
}
/**
* 相关推荐否使用个性化-【双11关闭】
*/
public boolean isRecommendPersionalOpen() {
return configReader.getBoolean("search.persional.recommend.open", true);
}
/**
* 超时日志是否打开
*/
public boolean isControllerCostLogOpen() {
return configReader.getBoolean("search.controller.cost.log.open", true);
}
/**
* A策略是否打开
*/
public boolean isAStrategyOpen() {
return configReader.getBoolean("search.persional.abTest.a.strategy.open", true);
}
/**
* B策略是否打开
*/
public boolean isBStrategyOpen() {
return configReader.getBoolean("search.persional.abTest.b.strategy.open", true);
}
/**
* group_shop新实现
*/
public boolean groupShopNew() {
return configReader.getBoolean("search.shop.group.new", true);
}
/**
* aggProductListByBrand新实现
*/
public boolean aggBrandProductNew() {
return configReader.getBoolean("search.agg.brand.product.new", true);
}
/**
* aggProductListByBrand新实现
*/
public boolean productListReturnGoods() {
return configReader.getBoolean("search.productlist.return.goods", true);
}
}