yats.git

commit ab0656c81bbb21aad1528da9cbb39ea0e85879e2

Author: Paolo Lulli <paolo@lulli.net>

Split Grpc server across different files

 server/grpc/event-grpc-server.go | 26 ++++++++++++++++++++++++++
 server/grpc/metric-grpc-server.go | 27 +++++++++++++++++++++++++++
 server/grpc/position-grpc-server.go | 26 ++++++++++++++++++++++++++
 server/grpc/yats-grpc-server.go | 20 --------------------


diff --git a/server/grpc/event-grpc-server.go b/server/grpc/event-grpc-server.go
new file mode 100644
index 0000000000000000000000000000000000000000..42f3da9696e879ad7b66b27d9877343ab1e43831
--- /dev/null
+++ b/server/grpc/event-grpc-server.go
@@ -0,0 +1,26 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grpc
+
+import (
+	"context"
+	"fmt"
+	"yats-server/db"
+	"yats-server/proto"
+)
+
+func (s *server) CreateEvent(ctx context.Context, req *proto.CreateEventRequest) (*proto.CreateEventResponse, error) {
+	event := req.GetEvent()
+	clientCN := event.IdClient
+	fmt.Printf("%s / %s ", clientCN, event.Name)
+	db.SaveEvent(clientCN, event.Name)
+	return &proto.CreateEventResponse{Event: event}, nil
+}




diff --git a/server/grpc/metric-grpc-server.go b/server/grpc/metric-grpc-server.go
new file mode 100644
index 0000000000000000000000000000000000000000..c21665d675ef7f07a93f5478a2891d3f812581a5
--- /dev/null
+++ b/server/grpc/metric-grpc-server.go
@@ -0,0 +1,27 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grpc
+
+import (
+	"context"
+	"fmt"
+	"yats-server/db"
+	"yats-server/proto"
+)
+
+func (s *server) CreateMetric(ctx context.Context, req *proto.CreateMetricRequest) (*proto.CreateMetricResponse, error) {
+	metric := req.GetMetric()
+	clientCN := metric.IdClient
+	fmt.Printf("%s / %s / %s", clientCN, metric.Name, metric.Value)
+	db.SaveMetric(clientCN, metric.Name, metric.Value)
+
+	return &proto.CreateMetricResponse{Metric: metric}, nil
+}




diff --git a/server/grpc/position-grpc-server.go b/server/grpc/position-grpc-server.go
new file mode 100644
index 0000000000000000000000000000000000000000..494a2d8eaa81ff3f6f0246dbd7378ac034048f5a
--- /dev/null
+++ b/server/grpc/position-grpc-server.go
@@ -0,0 +1,26 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grpc
+
+import (
+	"context"
+	"fmt"
+	"yats-server/db"
+	"yats-server/proto"
+)
+
+func (s *server) CreatePosition(ctx context.Context, req *proto.CreatePositionRequest) (*proto.CreatePositionResponse, error) {
+	position := req.GetPosition()
+	clientCN := position.IdClient
+	fmt.Printf("%s / %s ", clientCN, position.Name)
+	db.SavePosition(clientCN, position.Lat, position.Lon, position.Name)
+	return &proto.CreatePositionResponse{Position: position}, nil
+}




diff --git a/server/grpc/yats-grpc-server.go b/server/grpc/yats-grpc-server.go
index 50bdc61e78435a334439c921afea1a79459cac9b..8fed1bc63e58befd3e48034fc5172e03ebed62e2 100644
--- a/server/grpc/yats-grpc-server.go
+++ b/server/grpc/yats-grpc-server.go
@@ -11,34 +11,14 @@
 package grpc
 
 import (
-	"context"
-	"fmt"
 	"google.golang.org/grpc"
 	"log"
 	"net"
-	"yats-server/db"
 	"yats-server/proto"
 )
 
 type server struct {
 	proto.UnimplementedYatsGrpcServiceServer
-}
-
-func (s *server) CreateMetric(ctx context.Context, req *proto.CreateMetricRequest) (*proto.CreateMetricResponse, error) {
-	metric := req.GetMetric()
-	clientCN := metric.IdClient
-	fmt.Printf("%s / %s / %s", clientCN, metric.Name, metric.Value)
-	db.SaveMetric(clientCN, metric.Name, metric.Value)
-
-	return &proto.CreateMetricResponse{Metric: metric}, nil
-}
-
-func (s *server) CreatePosition(ctx context.Context, req *proto.CreatePositionRequest) (*proto.CreatePositionResponse, error) {
-	position := req.GetPosition()
-	clientCN := position.IdClient
-	fmt.Printf("%s / %s ", clientCN, position.Name)
-	db.SavePosition(clientCN, position.Lat, position.Lon, position.Name)
-	return &proto.CreatePositionResponse{Position: position}, nil
 }
 
 func RunYatsGrpcServer(address string) {