You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2020/10/29 04:57:27 UTC

[GitHub] [dubbo-go-samples] AlexStocks commented on a change in pull request #7: consul service discovery sample

AlexStocks commented on a change in pull request #7:
URL: https://github.com/apache/dubbo-go-samples/pull/7#discussion_r513968248



##########
File path: registry/servicediscovery/consul/go-client/app/client.go
##########
@@ -0,0 +1,96 @@
+/*
+ * 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 main
+
+import (
+	"context"
+	"fmt"
+	"os"
+	"os/signal"
+	"syscall"
+	"time"
+)
+
+import (
+	hessian "github.com/apache/dubbo-go-hessian2"

Review comment:
       split this import block and move it to the 2rd import block.

##########
File path: registry/servicediscovery/consul/go-client/app/client.go
##########
@@ -0,0 +1,96 @@
+/*
+ * 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 main
+
+import (
+	"context"
+	"fmt"
+	"os"
+	"os/signal"
+	"syscall"
+	"time"
+)
+
+import (
+	hessian "github.com/apache/dubbo-go-hessian2"
+
+	"github.com/apache/dubbo-go/common/logger"
+	_ "github.com/apache/dubbo-go/common/proxy/proxy_factory"
+	"github.com/apache/dubbo-go/config"
+	_ "github.com/apache/dubbo-go/protocol/dubbo"
+	_ "github.com/apache/dubbo-go/registry/protocol"
+
+	_ "github.com/apache/dubbo-go/filter/filter_impl"
+
+	_ "github.com/apache/dubbo-go/cluster/cluster_impl"
+	_ "github.com/apache/dubbo-go/cluster/loadbalance"
+
+	_ "github.com/apache/dubbo-go/metadata/mapping/dynamic"
+	_ "github.com/apache/dubbo-go/metadata/report/consul"
+	_ "github.com/apache/dubbo-go/metadata/service/remote"
+	_ "github.com/apache/dubbo-go/registry/consul"
+	_ "github.com/apache/dubbo-go/registry/servicediscovery"
+)
+
+var (
+	survivalTimeout int = 10e9
+)
+
+// they are necessary:
+// 		export CONF_CONSUMER_FILE_PATH="xxx"
+// 		export APP_LOG_CONF_FILE="xxx"
+func main() {
+	hessian.RegisterPOJO(&User{})
+	config.Load()
+	time.Sleep(3e9)
+
+	fmt.Printf("\033[32;40m" + "\n\n\nstart to test dubbo" + "\033[0m\n")

Review comment:
       pls using gxlog.CInfo from "github.com/dubbogo/gost/log" instead. as https://github.com/apache/dubbo-go-samples/blob/master/helloworld/dubbo/go-client/app/client.go#L56

##########
File path: registry/servicediscovery/consul/go-client/app/client.go
##########
@@ -0,0 +1,96 @@
+/*
+ * 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 main
+
+import (
+	"context"
+	"fmt"
+	"os"
+	"os/signal"
+	"syscall"
+	"time"
+)
+
+import (
+	hessian "github.com/apache/dubbo-go-hessian2"
+
+	"github.com/apache/dubbo-go/common/logger"
+	_ "github.com/apache/dubbo-go/common/proxy/proxy_factory"
+	"github.com/apache/dubbo-go/config"
+	_ "github.com/apache/dubbo-go/protocol/dubbo"
+	_ "github.com/apache/dubbo-go/registry/protocol"
+
+	_ "github.com/apache/dubbo-go/filter/filter_impl"
+
+	_ "github.com/apache/dubbo-go/cluster/cluster_impl"
+	_ "github.com/apache/dubbo-go/cluster/loadbalance"
+
+	_ "github.com/apache/dubbo-go/metadata/mapping/dynamic"
+	_ "github.com/apache/dubbo-go/metadata/report/consul"
+	_ "github.com/apache/dubbo-go/metadata/service/remote"
+	_ "github.com/apache/dubbo-go/registry/consul"
+	_ "github.com/apache/dubbo-go/registry/servicediscovery"
+)
+
+var (
+	survivalTimeout int = 10e9
+)
+
+// they are necessary:
+// 		export CONF_CONSUMER_FILE_PATH="xxx"
+// 		export APP_LOG_CONF_FILE="xxx"
+func main() {
+	hessian.RegisterPOJO(&User{})
+	config.Load()
+	time.Sleep(3e9)
+
+	fmt.Printf("\033[32;40m" + "\n\n\nstart to test dubbo" + "\033[0m\n")
+	user := &User{}
+	for i := 0; i < 5; i++ {
+		err := userProvider.GetUser(context.TODO(), []interface{}{"A001"}, user)
+		if err != nil {
+			panic(err)
+		}
+		fmt.Printf("\033[32;40m"+"response result: %v\n"+"\033[0m\n", user)

Review comment:
       pls using gxlog.CInfo from "github.com/dubbogo/gost/log" instead. as https://github.com/apache/dubbo-go-samples/blob/master/helloworld/dubbo/go-client/app/client.go#L56

##########
File path: registry/servicediscovery/consul/go-server/app/user.go
##########
@@ -0,0 +1,60 @@
+/*
+ * 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 main
+
+import (
+	"context"
+	"fmt"
+	"time"
+)
+
+import (
+	hessian "github.com/apache/dubbo-go-hessian2"
+	"github.com/apache/dubbo-go/config"
+)
+
+func init() {
+	config.SetProviderService(new(UserProvider))
+	// ------for hessian2------
+	hessian.RegisterPOJO(&User{})
+}
+
+type User struct {
+	Id   string
+	Name string
+	Age  int32
+	Time time.Time
+}
+
+type UserProvider struct {
+}
+
+func (u *UserProvider) GetUser(ctx context.Context, req []interface{}) (*User, error) {
+	fmt.Printf("\033[32;40m"+"req:%#v"+"\033[0m\n", req)

Review comment:
       pls using gxlog.CInfo from "github.com/dubbogo/gost/log" instead. as https://github.com/apache/dubbo-go-samples/blob/master/helloworld/dubbo/go-client/app/client.go#L56

##########
File path: registry/servicediscovery/consul/go-server/app/user.go
##########
@@ -0,0 +1,60 @@
+/*
+ * 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 main
+
+import (
+	"context"
+	"fmt"
+	"time"
+)
+
+import (
+	hessian "github.com/apache/dubbo-go-hessian2"
+	"github.com/apache/dubbo-go/config"
+)
+
+func init() {
+	config.SetProviderService(new(UserProvider))
+	// ------for hessian2------
+	hessian.RegisterPOJO(&User{})
+}
+
+type User struct {
+	Id   string
+	Name string
+	Age  int32
+	Time time.Time
+}
+
+type UserProvider struct {
+}
+
+func (u *UserProvider) GetUser(ctx context.Context, req []interface{}) (*User, error) {
+	fmt.Printf("\033[32;40m"+"req:%#v"+"\033[0m\n", req)
+	rsp := User{"A001", "Alex Stocks", 18, time.Now()}
+	fmt.Printf("\033[32;40m"+"rsp:%#v"+"\033[0m\n", rsp)

Review comment:
       pls using gxlog.CInfo from "github.com/dubbogo/gost/log" instead. as https://github.com/apache/dubbo-go-samples/blob/master/helloworld/dubbo/go-client/app/client.go#L56




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org