feat 包命名规范

This commit is contained in:
2026-02-11 14:48:21 +08:00
parent 0ca8a0ccbb
commit 558677bc3a
30 changed files with 162 additions and 123 deletions

View File

@@ -1,24 +0,0 @@
package grpc_client
import (
"git.hlsq.asia/mmorpg/service-common/discover"
"git.hlsq.asia/mmorpg/service-common/discover/common"
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
)
func GatewayNewClient(sid ...int64) (grpc_pb.GatewayClient, error) {
c, err := discover.FindServer(common.KeyDiscoverGateway, sid...)
if err != nil {
return nil, err
}
return grpc_pb.NewGatewayClient(c), nil
}
func GatewayNewBroadcastClient() map[int64]grpc_pb.GatewayClient {
clientM := make(map[int64]grpc_pb.GatewayClient)
connM := discover.FindServerAll(common.KeyDiscoverGateway)
for sid, conn := range connM {
clientM[sid] = grpc_pb.NewGatewayClient(conn)
}
return clientM
}

View File

@@ -0,0 +1,24 @@
package grpcclient
import (
"git.hlsq.asia/mmorpg/service-common/discover"
"git.hlsq.asia/mmorpg/service-common/discover/common"
"git.hlsq.asia/mmorpg/service-common/proto/rs/rspb"
)
func GatewayNewClient(sid ...int64) (rspb.GatewayClient, error) {
c, err := discover.FindServer(common.KeyDiscoverGateway, sid...)
if err != nil {
return nil, err
}
return rspb.NewGatewayClient(c), nil
}
func GatewayNewBroadcastClient() map[int64]rspb.GatewayClient {
clientM := make(map[int64]rspb.GatewayClient)
connM := discover.FindServerAll(common.KeyDiscoverGateway)
for sid, conn := range connM {
clientM[sid] = rspb.NewGatewayClient(conn)
}
return clientM
}

View File

@@ -1,24 +1,24 @@
package grpc_client
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/grpc_pb"
"git.hlsq.asia/mmorpg/service-common/proto/rs/rspb"
)
func QgdzsNewClient(sid ...int64) (grpc_pb.QgdzsClient, error) {
func QgdzsNewClient(sid ...int64) (rspb.QgdzsClient, error) {
c, err := discover.FindServer(common.KeyDiscoverQgdzs, sid...)
if err != nil {
return nil, err
}
return grpc_pb.NewQgdzsClient(c), nil
return rspb.NewQgdzsClient(c), nil
}
func QgdzsNewClientLB() (grpc_pb.QgdzsClient, error) {
func QgdzsNewClientLB() (rspb.QgdzsClient, error) {
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameQgdzs)
if err != nil {
return nil, err
}
return grpc_pb.NewQgdzsClient(c), nil
return rspb.NewQgdzsClient(c), nil
}

View File

@@ -1,33 +1,33 @@
package grpc_client
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/grpc_pb"
"git.hlsq.asia/mmorpg/service-common/proto/rs/rspb"
)
func SceneNewClient(sid ...int64) (grpc_pb.SceneClient, error) {
func SceneNewClient(sid ...int64) (rspb.SceneClient, error) {
c, err := discover.FindServer(common.KeyDiscoverScene, sid...)
if err != nil {
return nil, err
}
return grpc_pb.NewSceneClient(c), nil
return rspb.NewSceneClient(c), nil
}
func SceneNewClientLB() (grpc_pb.SceneClient, error) {
func SceneNewClientLB() (rspb.SceneClient, error) {
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameScene)
if err != nil {
return nil, err
}
return grpc_pb.NewSceneClient(c), nil
return rspb.NewSceneClient(c), nil
}
func SceneNewBroadcastClient() map[int64]grpc_pb.SceneClient {
clientM := make(map[int64]grpc_pb.SceneClient)
func SceneNewBroadcastClient() map[int64]rspb.SceneClient {
clientM := make(map[int64]rspb.SceneClient)
connM := discover.FindServerAll(common.KeyDiscoverScene)
for sid, conn := range connM {
clientM[sid] = grpc_pb.NewSceneClient(conn)
clientM[sid] = rspb.NewSceneClient(conn)
}
return clientM
}

View File

@@ -1,24 +1,24 @@
package grpc_client
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/grpc_pb"
"git.hlsq.asia/mmorpg/service-common/proto/rs/rspb"
)
func UserNewClient(sid ...int64) (grpc_pb.UserClient, error) {
func UserNewClient(sid ...int64) (rspb.UserClient, error) {
c, err := discover.FindServer(common.KeyDiscoverUser, sid...)
if err != nil {
return nil, err
}
return grpc_pb.NewUserClient(c), nil
return rspb.NewUserClient(c), nil
}
func UserNewClientLB() (grpc_pb.UserClient, error) {
func UserNewClientLB() (rspb.UserClient, error) {
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameUser)
if err != nil {
return nil, err
}
return grpc_pb.NewUserClient(c), nil
return rspb.NewUserClient(c), nil
}

View File

@@ -1,4 +1,4 @@
package grpc_client
package grpcclient
import (
"context"

View File

@@ -1,4 +1,4 @@
package grpc_client
package grpcclient
import (
"context"

View File

@@ -1,4 +1,4 @@
package grpc_conn
package grpcconn
import (
"git.hlsq.asia/mmorpg/service-common/log"

View File

@@ -1,4 +1,4 @@
package grpc_conn
package grpcconn
import (
"fmt"

View File

@@ -1,7 +1,7 @@
package http_resp
package httpresp
import (
"git.hlsq.asia/mmorpg/service-common/proto/rs/rs_common"
"git.hlsq.asia/mmorpg/service-common/proto/rs/rscommon"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
@@ -41,7 +41,7 @@ func (c *Code) Error() string {
func (c *Code) Wrap() error {
st := status.New(codes.Unknown, c.Error())
st, _ = st.WithDetails(&rs_common.ErrorInfo{
st, _ = st.WithDetails(&rscommon.ErrorInfo{
Code: int32(c.Code()),
Msg: c.Error(),
})

View File

@@ -1,4 +1,4 @@
package http_resp
package httpresp
import (
"github.com/gin-gonic/gin"