Added some basic documentation

This commit is contained in:
Andrew Scott 2022-07-26 19:42:25 -04:00
parent ba7e27dfea
commit 87a9143248
Signed by: a
GPG key ID: 3EB62D0BBB8DB381
3 changed files with 8 additions and 0 deletions

View file

@ -10,6 +10,8 @@ import (
pb "codeberg.org/andcscott/OpenWeatherMap-gRPC-API/proto"
)
// Receives a gRPC request for the current forecast
// Returns a SendCurrent message containing the forecast in JSON
func (s *Server) Current(ctx context.Context, in *pb.RequestCurrent) (*pb.SendCurrent, error) {
log.Println("'Current' function called...")

View file

@ -11,6 +11,8 @@ import (
pb "codeberg.org/andcscott/OpenWeatherMap-gRPC-API/proto"
)
// Receives a gRPC request for an extended forecast
// Returns a SendExtended message with the forecast in JSON
func (s *Server) Extended(ctx context.Context, in *pb.RequestExtended) (*pb.SendExtended, error) {
log.Println("'Extended' function called...")

View file

@ -18,13 +18,16 @@ type Server struct {
func main() {
// Load .env file
err := godotenv.Load()
if err != nil {
log.Fatalln(err)
}
// Read PORT from .env
port, _ := strconv.Atoi(os.Getenv("PORT"))
// Start server
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
if err != nil {
log.Fatalf("Error starting server: %v\n", err)
@ -32,6 +35,7 @@ func main() {
log.Printf("Listening on port %d...\n", port)
}
// Initialize gRPC server
s := grpc.NewServer()
pb.RegisterWeatherServiceServer(s, &Server{})
if err = s.Serve(lis); err != nil {