Routing service (#36)

This commit is contained in:
ben-toogood
2021-01-08 16:20:28 +00:00
committed by GitHub
parent 39e0f94152
commit f8eb3bfd9b
10 changed files with 836 additions and 0 deletions

41
routing/main.go Normal file
View File

@@ -0,0 +1,41 @@
package main
import (
"github.com/micro/services/routing/handler"
pb "github.com/micro/services/routing/proto"
"github.com/micro/micro/v3/service"
"github.com/micro/micro/v3/service/config"
"github.com/micro/micro/v3/service/logger"
"googlemaps.github.io/maps"
)
func main() {
// Create service
srv := service.New(
service.Name("routing"),
service.Version("latest"),
)
// Setup google maps
c, err := config.Get("google.apikey")
if err != nil {
logger.Fatalf("Error loading config: %v", err)
}
apiKey := c.String("")
if len(apiKey) == 0 {
logger.Fatalf("Missing required config: google.apikey")
}
m, err := maps.NewClient(maps.WithAPIKey(apiKey))
if err != nil {
logger.Fatalf("Error configuring google maps client: %v", err)
}
// Register handler
pb.RegisterRoutingHandler(srv.Server(), &handler.Routing{m})
// Run service
if err := srv.Run(); err != nil {
logger.Fatal(err)
}
}