tianxiaoliang commented on a change in pull request #789:
URL: 
https://github.com/apache/servicecomb-service-center/pull/789#discussion_r547724805



##########
File path: datasource/mongo/sd/common.go
##########
@@ -0,0 +1,36 @@
+/*
+* 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 sd
+
+import (
+       "time"
+)
+
+const (
+       // force re-list
+       DefaultForceListInterval = 10
+
+       minWaitInterval = 1 * time.Second
+       eventBlockSize  = 1000
+       eventBusSize    = 1000
+
+       INSERT  = "insert"
+       UPDATE  = "update"

Review comment:
       驼峰才是go风格的常量命

##########
File path: datasource/mongo/sd/config.go
##########
@@ -0,0 +1,73 @@
+/*
+ * 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 sd
+
+import (
+       "fmt"
+       "time"
+)
+
+const (
+       DefaultTimeout       = 30 * time.Second
+       DefaultCacheInitSize = 100
+)
+
+type Config struct {

Review comment:
       统一风格叫Options

##########
File path: datasource/mongo/sd/config.go
##########
@@ -0,0 +1,73 @@
+/*
+ * 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 sd
+
+import (
+       "fmt"
+       "time"
+)
+
+const (
+       DefaultTimeout       = 30 * time.Second
+       DefaultCacheInitSize = 100
+)
+
+type Config struct {
+       // Key is the table to unique specify resource type
+       Key      string
+       InitSize int
+       Timeout  time.Duration
+       Period   time.Duration
+       OnEvent  MongoEventFunc
+}
+
+func (cfg *Config) String() string {
+       return fmt.Sprintf("{key: %s, timeout: %s, period: %s}",
+               cfg.Key, cfg.Timeout, cfg.Period)
+}
+
+func (cfg *Config) WithTable(key string) *Config {
+       cfg.Key = key
+       return cfg
+}
+
+func (cfg *Config) WithEventFunc(f MongoEventFunc) *Config {
+       cfg.OnEvent = f
+       return cfg
+}
+
+func (cfg *Config) AppendEventFunc(f MongoEventFunc) *Config {
+       if prev := cfg.OnEvent; prev != nil {
+               next := f
+               f = func(evt MongoEvent) {
+                       prev(evt)
+                       next(evt)
+               }
+       }
+       cfg.OnEvent = f
+       return cfg
+}
+
+func Configure() *Config {

Review comment:
       这方法名叫DefaultOptions

##########
File path: datasource/mongo/sd/config.go
##########
@@ -0,0 +1,73 @@
+/*
+ * 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 sd
+
+import (
+       "fmt"
+       "time"
+)
+
+const (
+       DefaultTimeout       = 30 * time.Second
+       DefaultCacheInitSize = 100
+)
+
+type Config struct {
+       // Key is the table to unique specify resource type
+       Key      string
+       InitSize int
+       Timeout  time.Duration
+       Period   time.Duration
+       OnEvent  MongoEventFunc
+}
+
+func (cfg *Config) String() string {
+       return fmt.Sprintf("{key: %s, timeout: %s, period: %s}",
+               cfg.Key, cfg.Timeout, cfg.Period)
+}
+
+func (cfg *Config) WithTable(key string) *Config {
+       cfg.Key = key

Review comment:
       而且不要提供java bean风格的方法




----------------------------------------------------------------
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]


Reply via email to