tianxiaoliang commented on a change in pull request #789: URL: https://github.com/apache/servicecomb-service-center/pull/789#discussion_r547730463
########## File path: datasource/mongo/sd/watcher.go ########## @@ -0,0 +1,23 @@ +/* + * 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 + +type Watcher interface { + EventBus() <-chan *MongoListWatchResponse Review comment: 这个方法名肯定没有达意,eventbus是消息总线 ########## File path: datasource/mongo/sd/event_proxy.go ########## @@ -0,0 +1,69 @@ +/* + * 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" + "sync" + + "github.com/apache/servicecomb-service-center/pkg/log" + "github.com/apache/servicecomb-service-center/pkg/util" +) + +var ( + eventProxies = make(map[string]*MongoEventProxy) +) + +type MongoEventProxy struct { + evtHandleFuncs []MongoEventFunc Review comment: 没特别理由用sync.Map ########## File path: datasource/mongo/sd/watcher_inner.go ########## @@ -0,0 +1,87 @@ +/* + * 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 ( + "context" + "sync" + + "github.com/apache/servicecomb-service-center/pkg/gopool" + "github.com/apache/servicecomb-service-center/pkg/log" +) + +type innerWatcher struct { + Cfg ListWatchConfig + bus chan *MongoListWatchResponse Review comment: MongoListWatchResponse 并不是一个总线的名字,如果你期望要一个总线,就抽象一个struct,别拿变量表示总线 ---------------------------------------------------------------- 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]
