tianxiaoliang commented on a change in pull request #953: URL: https://github.com/apache/servicecomb-service-center/pull/953#discussion_r620789363
########## File path: datasource/mongo/fast_register_config.go ########## @@ -0,0 +1,44 @@ +/* + * 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 request 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 request 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 mongo + +import ( + "sync" + + "github.com/apache/servicecomb-service-center/server/config" +) + +const defaultQueueSize = 500000 + +var ( + configOnce sync.Once + fastRegConfig FastRegConfig +) + +type FastRegConfig struct { + enable bool + queueSize int +} + +func FastRegConfiguration() *FastRegConfig { + configOnce.Do(func() { + fastRegConfig.enable = config.GetBool("registry.mongo.fastRegister.enable", false) + fastRegConfig.queueSize = config.GetInt("registry.mongo.fastRegister.queueSize", defaultQueueSize) Review comment: 我不建议用2个参数,而是用quesize为0或大于0来控制,大于0说明需要启用功能,小于等于0关闭。不要让用户学习2个参数 ########## File path: datasource/mongo/fast_register_config.go ########## @@ -0,0 +1,44 @@ +/* + * 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 request 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 request 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 mongo + +import ( + "sync" + + "github.com/apache/servicecomb-service-center/server/config" +) + +const defaultQueueSize = 500000 + +var ( + configOnce sync.Once + fastRegConfig FastRegConfig +) + +type FastRegConfig struct { + enable bool + queueSize int +} + +func FastRegConfiguration() *FastRegConfig { + configOnce.Do(func() { + fastRegConfig.enable = config.GetBool("registry.mongo.fastRegister.enable", false) + fastRegConfig.queueSize = config.GetInt("registry.mongo.fastRegister.queueSize", defaultQueueSize) Review comment: 另外,这引出了另外一个问题,当queue满了的时候,应该走正常注册流程,而不是拒绝,这样才能持续服务,但是要充分测试下这个场景的表现 -- 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. For queries about this service, please contact Infrastructure at: [email protected]
