feat 服务发现模块

This commit is contained in:
2026-01-18 00:08:57 +08:00
parent 5b6a3a6b42
commit c293f9688a
4 changed files with 16 additions and 14 deletions

View File

@@ -9,16 +9,15 @@ log:
maxAge: 7 maxAge: 7
client: client:
count: 100 count: 10
usn: [ 1,10000000 ] usn: [ 1,10000000 ]
http: http:
# address: "https://www.hlsq.asia/api" address: "https://www.hlsq.asia/api"
# port: 0 port: 0
address: "http://127.0.0.1" # address: "http://127.0.0.1"
port: 8503 # port: 8503
websocket: websocket:
# address: "ws://47.108.184.184/ws/" address: "wss://www.hlsq.asia/ws/"
# address: "wss://www.hlsq.asia/ws/" port: 0
# port: 0 # address: "ws://127.0.0.1"
address: "ws://127.0.0.1" # port: 8501
port: 8501

3
go.mod
View File

@@ -3,7 +3,7 @@ module git.hlsq.asia/mmorpg/service-robot
go 1.24.0 go 1.24.0
require ( require (
git.hlsq.asia/mmorpg/service-common v0.0.0-20260116155014-3de703eb83c5 git.hlsq.asia/mmorpg/service-common v0.0.0-20260117160658-22d48542a852
github.com/gorilla/websocket v1.5.3 github.com/gorilla/websocket v1.5.3
github.com/judwhite/go-svc v1.2.1 github.com/judwhite/go-svc v1.2.1
google.golang.org/protobuf v1.36.10 google.golang.org/protobuf v1.36.10
@@ -76,6 +76,7 @@ require (
go.etcd.io/etcd/client/pkg/v3 v3.6.1 // indirect go.etcd.io/etcd/client/pkg/v3 v3.6.1 // indirect
go.etcd.io/etcd/client/v3 v3.6.1 // indirect go.etcd.io/etcd/client/v3 v3.6.1 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.64.0 // indirect
go.opentelemetry.io/otel v1.39.0 // indirect go.opentelemetry.io/otel v1.39.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.39.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.39.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.39.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.39.0 // indirect

6
go.sum
View File

@@ -1,7 +1,7 @@
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
git.hlsq.asia/mmorpg/service-common v0.0.0-20260116155014-3de703eb83c5 h1:b7pTgEyYUKpHtAAt4ea/3EYfX0Y0lYwhjrgf3kTyn0w= git.hlsq.asia/mmorpg/service-common v0.0.0-20260117160658-22d48542a852 h1:ehZ54MgGL3CO7KKDPxybFabIXxiQud1TGMcKjrSTcnw=
git.hlsq.asia/mmorpg/service-common v0.0.0-20260116155014-3de703eb83c5/go.mod h1:Dazg+4woCv9Jk7jgT2qUSGWhZOXx/0WYfJO+FCUDyhw= git.hlsq.asia/mmorpg/service-common v0.0.0-20260117160658-22d48542a852/go.mod h1:Dazg+4woCv9Jk7jgT2qUSGWhZOXx/0WYfJO+FCUDyhw=
github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0= github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
@@ -174,6 +174,8 @@ go.etcd.io/etcd/client/v3 v3.6.1 h1:KelkcizJGsskUXlsxjVrSmINvMMga0VWwFF0tSPGEP0=
go.etcd.io/etcd/client/v3 v3.6.1/go.mod h1:fCbPUdjWNLfx1A6ATo9syUmFVxqHH9bCnPLBZmnLmMY= go.etcd.io/etcd/client/v3 v3.6.1/go.mod h1:fCbPUdjWNLfx1A6ATo9syUmFVxqHH9bCnPLBZmnLmMY=
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.64.0 h1:RN3ifU8y4prNWeEnQp2kRRHz8UwonAEYZl8tUzHEXAk=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.64.0/go.mod h1:habDz3tEWiFANTo6oUE99EmaFUrCNYAAg3wiVmusm70=
go.opentelemetry.io/otel v1.39.0 h1:8yPrr/S0ND9QEfTfdP9V+SiwT4E0G7Y5MO7p85nis48= go.opentelemetry.io/otel v1.39.0 h1:8yPrr/S0ND9QEfTfdP9V+SiwT4E0G7Y5MO7p85nis48=
go.opentelemetry.io/otel v1.39.0/go.mod h1:kLlFTywNWrFyEdH0oj2xK0bFYZtHRYUdv1NklR/tgc8= go.opentelemetry.io/otel v1.39.0/go.mod h1:kLlFTywNWrFyEdH0oj2xK0bFYZtHRYUdv1NklR/tgc8=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.39.0 h1:f0cb2XPmrqn4XMy9PNliTgRKJgS5WcL/u0/WRYGz4t0= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.39.0 h1:f0cb2XPmrqn4XMy9PNliTgRKJgS5WcL/u0/WRYGz4t0=

View File

@@ -41,7 +41,7 @@ func NewClient(httpAddr, websocketAddr string) *Client {
func (c *Client) Start() { func (c *Client) Start() {
go func() { go func() {
data := fmt.Sprintf(`{"phone": "%v", "code": "1234"}`, utils.SnowflakeInstance().Generate().String()) data := fmt.Sprintf(`{"phone": "%v", "code": "1234"}`, utils.SnowflakeInstance().Generate().String())
resp, err := http.Post(c.httpAddr+"/gw/login", "application/json", bytes.NewBufferString(data)) resp, err := http.Post(c.httpAddr+"/gw/open/login", "application/json", bytes.NewBufferString(data))
if err != nil { if err != nil {
log.Errorf("POST request failed: %v\n", err) log.Errorf("POST request failed: %v\n", err)
return return