Paperclip/pkg/internal/grpc/server.go

30 lines
500 B
Go
Raw Normal View History

2024-05-17 07:59:51 +00:00
package grpc
import (
2024-06-16 15:24:54 +00:00
"git.solsynth.dev/hydrogen/paperclip/pkg/proto"
2024-05-17 07:59:51 +00:00
"net"
"github.com/spf13/viper"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
)
type Server struct {
proto.UnimplementedAttachmentsServer
}
func StartGrpc() error {
listen, err := net.Listen("tcp", viper.GetString("grpc_bind"))
if err != nil {
return err
}
server := grpc.NewServer()
proto.RegisterAttachmentsServer(server, &Server{})
reflection.Register(server)
return server.Serve(listen)
}