zeromicro / go-zero

A cloud-native Go microservices framework with cli tool for productivity.
https://go-zero.dev
MIT License
29.21k stars 3.95k forks source link

Problem: empty etcd hosts #2376

Open 1511563371 opened 2 years ago

1511563371 commented 2 years ago

Describe the bug A clear and concise description of what the bug is.

proto file:

syntax = "proto3"; 

package rpcUser;
option go_package="./rpcUser";

message UserRequest {
 string UserID = 1;
 string UserName = 2;
}

message UserResponse {
 string UserID = 1;
 string UserName = 2;
}

service UserInfo {
    rpc UserInfoSearch (UserRequest) returns (UserResponse);
}
XXX.yaml文件

Name: user.rpc
ListenOn: 0.0.0.0:8081
Etcd:
  Hosts:
  - 127.0.0.1:2379
  Key: user.rpc

ShopOwnerRpc:
  Etcd:
    Hosts:
      - 127.0.0.1:2379
    Key: shopowner.rpc
build and run: 
go run .

result:
XXXXX:39 empty etcd hosts
exit status 1
kevwan commented 2 years ago

I'm not sure if it's your formatting issue. Check your yaml format first please.

dobet commented 1 year ago

i meet this problem too. and i do this: fmt.Println("has etcd ?", c.HasEtcd()) fmt.Println("etcd hosts:", c.Etcd.Hosts) fmt.Println("validator etcd", c.Etcd.Validate())

i get: has etcd ? true etcd hosts: [etcd:2379] validator etcd 2022/11/11 08:13:22 empty etcd hosts

dobet commented 1 year ago

the Validate code is : func (c EtcdConf) Validate() error { if len(c.Hosts) == 0 { return errEmptyEtcdHosts } else if len(c.Key) == 0 { return errEmptyEtcdKey } else { return nil } }

so, I print key and hosts fmt.Println("has etcd ?", c.HasEtcd()) fmt.Println("etcd hosts:", c.Etcd.Hosts) fmt.Println("etcd Key:", c.Etcd.Key) fmt.Println("validator etcd", c.Etcd.Validate())

i got has etcd ? true etcd hosts: [etcd:2379] etcd Key: order.rpc validator etcd 2022/11/11 08:16:27 empty etcd hosts

dobet commented 1 year ago

i found is my yaml xxxRpc config is nil, but the error is so simple

zaunist commented 1 year ago

I meet the same error..

zaunist commented 1 year ago

I meet the same error..

I wrote wrong config, after correction it's ok.

dahaipublic commented 1 year ago

empty etcd hosts Name: identify.rpc ListenOn: 0.0.0.0:9004

Etcd: Hosts:

Mysql: DataSource: root:123456@tcp(mysql:3306)/mall?charset=utf8mb4&parseTime=true&loc=Asia%2FShanghai

CacheRedis:

Salt: HWVOFkGgPTryzICwd7qnJaZR9KQ2i8xe

ymal里面如何配置

Issues-translate-bot commented 1 year ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


empty etcd hosts Name: identify.rpc ListenOn: 0.0.0.0:9004

Etcd: Hosts:

Mysql: DataSource: root:123456@tcp(mysql:3306)/mall?charset=utf8mb4&parseTime=true&loc=Asia%2FShanghai

CacheRedis:

Salt: HWVOFkGgPTryzICwd7qnJaZR9KQ2i8xe

ymal里面如何配置

CaoLei-JS commented 1 year ago

i found is my yaml xxxRpc config is nil, but the error is so simple

i found my yaml property name(xxxRpc) must be the same as in the config.go

chenxinlong commented 10 months ago

遇到同样的问题。 漏配置了 xxxRPC, 结果报错内容是 etcd 配置不存在。 这种问题很难怀疑到框架身上,排查了半天,抱着侥幸心理查到这里,结果真的是框架问题。

@kevwan

Issues-translate-bot commented 10 months ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Encountered the same problem. A was not configured, and the error message was that the etcd configuration does not exist.