tianxiaoliang commented on code in PR #1309:
URL: 
https://github.com/apache/servicecomb-service-center/pull/1309#discussion_r914797845


##########
istio/pkg/controllers/servicecenter/controller.go:
##########
@@ -0,0 +1,210 @@
+/*
+ * 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 servicecenter
+
+import (
+       "reflect"
+       "sync"
+       "time"
+
+       "github.com/apache/servicecomb-service-center/istio/pkg/event"
+       "github.com/apache/servicecomb-service-center/istio/pkg/utils"
+       "github.com/go-chassis/cari/discovery"
+
+       client 
"github.com/apache/servicecomb-service-center/istio/pkg/controllers/servicecenter/client"
+       "istio.io/pkg/log"
+)
+

Review Comment:
   comments to describe the responsibility 



##########
istio/pkg/controllers/servicecenter/controller.go:
##########
@@ -0,0 +1,210 @@
+/*
+ * 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 servicecenter
+
+import (
+       "reflect"
+       "sync"
+       "time"
+
+       "github.com/apache/servicecomb-service-center/istio/pkg/event"
+       "github.com/apache/servicecomb-service-center/istio/pkg/utils"
+       "github.com/go-chassis/cari/discovery"
+
+       client 
"github.com/apache/servicecomb-service-center/istio/pkg/controllers/servicecenter/client"
+       "istio.io/pkg/log"
+)
+
+type Controller struct {
+       // servicecomb service center go-chassis API client
+       client *client.Client
+       // Channel used to send and receive servicecomb service center change 
events from the service center controller
+       event chan []event.ChangeEvent

Review Comment:
   events



##########
istio/pkg/controllers/servicecenter/controller.go:
##########
@@ -0,0 +1,210 @@
+/*
+ * 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 servicecenter
+
+import (
+       "reflect"
+       "sync"
+       "time"
+
+       "github.com/apache/servicecomb-service-center/istio/pkg/event"
+       "github.com/apache/servicecomb-service-center/istio/pkg/utils"
+       "github.com/go-chassis/cari/discovery"
+
+       client 
"github.com/apache/servicecomb-service-center/istio/pkg/controllers/servicecenter/client"
+       "istio.io/pkg/log"
+)
+
+type Controller struct {
+       // servicecomb service center go-chassis API client
+       client *client.Client
+       // Channel used to send and receive servicecomb service center change 
events from the service center controller
+       event chan []event.ChangeEvent
+       // Lock for service cache
+       cacheMutex sync.Mutex
+       // Cache of retrieved servicecomb service center microservices, mapped 
to their service ids
+       serviceCache map[string]*event.MicroserviceEntry
+}
+
+func NewController(addr string, e chan []event.ChangeEvent) *Controller {
+       controller := &Controller{
+               client:       client.New(addr),
+               event:        e,
+               serviceCache: map[string]*event.MicroserviceEntry{},
+       }
+
+       return controller
+}
+
+// Run until a stop signal is received
+func (c *Controller) Run(stop <-chan struct{}) {

Review Comment:
   if you just want to control this goroutine, please use context, and wait for 
cancel signal,  not a channel



##########
istio/pkg/controllers/servicecenter/controller.go:
##########
@@ -0,0 +1,210 @@
+/*
+ * 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 servicecenter
+
+import (
+       "reflect"
+       "sync"
+       "time"
+
+       "github.com/apache/servicecomb-service-center/istio/pkg/event"
+       "github.com/apache/servicecomb-service-center/istio/pkg/utils"
+       "github.com/go-chassis/cari/discovery"
+
+       client 
"github.com/apache/servicecomb-service-center/istio/pkg/controllers/servicecenter/client"
+       "istio.io/pkg/log"
+)
+
+type Controller struct {
+       // servicecomb service center go-chassis API client
+       client *client.Client
+       // Channel used to send and receive servicecomb service center change 
events from the service center controller
+       event chan []event.ChangeEvent
+       // Lock for service cache
+       cacheMutex sync.Mutex
+       // Cache of retrieved servicecomb service center microservices, mapped 
to their service ids
+       serviceCache map[string]*event.MicroserviceEntry

Review Comment:
   how about use sync.Map



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to