feat 包命名规范
This commit is contained in:
33
net/grpc/grpcclient/client_scene.go
Normal file
33
net/grpc/grpcclient/client_scene.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package grpcclient
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/mmorpg/service-common/discover"
|
||||
"git.hlsq.asia/mmorpg/service-common/discover/common"
|
||||
"git.hlsq.asia/mmorpg/service-common/net/grpc/resolver"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/rs/rspb"
|
||||
)
|
||||
|
||||
func SceneNewClient(sid ...int64) (rspb.SceneClient, error) {
|
||||
c, err := discover.FindServer(common.KeyDiscoverScene, sid...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rspb.NewSceneClient(c), nil
|
||||
}
|
||||
|
||||
func SceneNewClientLB() (rspb.SceneClient, error) {
|
||||
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameScene)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rspb.NewSceneClient(c), nil
|
||||
}
|
||||
|
||||
func SceneNewBroadcastClient() map[int64]rspb.SceneClient {
|
||||
clientM := make(map[int64]rspb.SceneClient)
|
||||
connM := discover.FindServerAll(common.KeyDiscoverScene)
|
||||
for sid, conn := range connM {
|
||||
clientM[sid] = rspb.NewSceneClient(conn)
|
||||
}
|
||||
return clientM
|
||||
}
|
||||
Reference in New Issue
Block a user