🚚 Rename protobuf
This commit is contained in:
1
pkg/internal/auth/jwt.go
Normal file
1
pkg/internal/auth/jwt.go
Normal file
@ -0,0 +1 @@
|
||||
package auth
|
@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
type CommandRpcServer struct {
|
||||
proto.UnimplementedCommandControllerServer
|
||||
proto.UnimplementedCommandProviderServer
|
||||
}
|
||||
|
||||
func (c CommandRpcServer) AddCommand(ctx context.Context, info *proto.CommandInfo) (*proto.AddCommandResponse, error) {
|
||||
@ -66,7 +66,7 @@ func (c CommandRpcServer) SendCommand(ctx context.Context, argument *proto.Comma
|
||||
ctx, cancel := context.WithTimeout(ctx, time.Second*10)
|
||||
defer cancel()
|
||||
|
||||
out, err := proto.NewCommandControllerClient(conn).SendCommand(ctx, argument)
|
||||
out, err := proto.NewCommandProviderClient(conn).SendCommand(ctx, argument)
|
||||
if err != nil {
|
||||
return &proto.CommandReturn{
|
||||
IsDelivered: true,
|
||||
@ -99,7 +99,7 @@ func (c CommandRpcServer) SendStreamCommand(g grpc.BidiStreamingServer[proto.Com
|
||||
conn, err := handler.GetGrpcConn()
|
||||
|
||||
ctx, cancel := context.WithTimeout(g.Context(), time.Second*10)
|
||||
out, err := proto.NewCommandControllerClient(conn).SendCommand(ctx, pck)
|
||||
out, err := proto.NewCommandProviderClient(conn).SendCommand(ctx, pck)
|
||||
cancel()
|
||||
|
||||
if err != nil {
|
||||
|
@ -69,7 +69,7 @@ func BroadcastEvent(event string, data any) {
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
_, _ = proto.NewServiceDirectoryClient(conn).BroadcastEvent(ctx, &proto.EventInfo{
|
||||
_, _ = proto.NewDirectoryServiceClient(conn).BroadcastEvent(ctx, &proto.EventInfo{
|
||||
Event: event,
|
||||
Data: nex.EncodeMap(data),
|
||||
})
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
type ServiceRpcServer struct {
|
||||
proto.UnimplementedServiceDirectoryServer
|
||||
proto.UnimplementedDirectoryServiceServer
|
||||
}
|
||||
|
||||
func instantiationService(in *ServiceInstance) *proto.ServiceInfo {
|
||||
|
@ -15,8 +15,8 @@ import (
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
proto.UnimplementedDatabaseControllerServer
|
||||
proto.UnimplementedStreamControllerServer
|
||||
proto.UnimplementedDatabaseServiceServer
|
||||
proto.UnimplementedStreamServiceServer
|
||||
health.UnimplementedHealthServer
|
||||
|
||||
srv *grpc.Server
|
||||
@ -27,10 +27,10 @@ func NewServer() *Server {
|
||||
srv: grpc.NewServer(),
|
||||
}
|
||||
|
||||
proto.RegisterServiceDirectoryServer(server.srv, &directory2.ServiceRpcServer{})
|
||||
proto.RegisterCommandControllerServer(server.srv, &directory2.CommandRpcServer{})
|
||||
proto.RegisterDatabaseControllerServer(server.srv, server)
|
||||
proto.RegisterStreamControllerServer(server.srv, server)
|
||||
proto.RegisterDirectoryServiceServer(server.srv, &directory2.ServiceRpcServer{})
|
||||
proto.RegisterCommandProviderServer(server.srv, &directory2.CommandRpcServer{})
|
||||
proto.RegisterDatabaseServiceServer(server.srv, server)
|
||||
proto.RegisterStreamServiceServer(server.srv, server)
|
||||
health.RegisterHealthServer(server.srv, server)
|
||||
|
||||
reflection.Register(server.srv)
|
||||
|
@ -52,7 +52,7 @@ func invokeCommand(c *fiber.Ctx) error {
|
||||
ctx, cancel := context.WithTimeout(ctx, time.Second*10)
|
||||
defer cancel()
|
||||
|
||||
out, err := proto.NewCommandControllerClient(conn).SendCommand(ctx, &proto.CommandArgument{
|
||||
out, err := proto.NewCommandProviderClient(conn).SendCommand(ctx, &proto.CommandArgument{
|
||||
Command: command,
|
||||
Method: method,
|
||||
Payload: c.Body(),
|
||||
|
@ -60,7 +60,7 @@ func Listen(c *websocket.Conn) {
|
||||
continue
|
||||
}
|
||||
|
||||
sc := proto.NewStreamControllerClient(pc)
|
||||
sc := proto.NewStreamServiceClient(pc)
|
||||
_, err = sc.EmitStreamEvent(context.Background(), &proto.StreamEventRequest{
|
||||
Event: packet.Action,
|
||||
UserId: uint64(user.ID),
|
||||
|
19
pkg/internal/kv/etcd.go
Normal file
19
pkg/internal/kv/etcd.go
Normal file
@ -0,0 +1,19 @@
|
||||
package kv
|
||||
|
||||
import (
|
||||
clientv3 "go.etcd.io/etcd/client/v3"
|
||||
"time"
|
||||
)
|
||||
|
||||
var Kv *clientv3.Client
|
||||
|
||||
func ConnectEtcd(endpoints []string) error {
|
||||
conn, err := clientv3.New(clientv3.Config{
|
||||
Endpoints: endpoints,
|
||||
DialTimeout: 10 * time.Second,
|
||||
})
|
||||
if err == nil {
|
||||
Kv = conn
|
||||
}
|
||||
return err
|
||||
}
|
Reference in New Issue
Block a user