mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-11 10:54:28 +00:00
add the place service (#376)
This commit is contained in:
2
place/.gitignore
vendored
Normal file
2
place/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
place
|
||||
3
place/Dockerfile
Normal file
3
place/Dockerfile
Normal file
@@ -0,0 +1,3 @@
|
||||
FROM alpine
|
||||
ADD place /place
|
||||
ENTRYPOINT [ "/place" ]
|
||||
28
place/Makefile
Normal file
28
place/Makefile
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
GOPATH:=$(shell go env GOPATH)
|
||||
.PHONY: init
|
||||
init:
|
||||
go get -u github.com/golang/protobuf/proto
|
||||
go get -u github.com/golang/protobuf/protoc-gen-go
|
||||
go get github.com/micro/micro/v3/cmd/protoc-gen-micro
|
||||
go get github.com/micro/micro/v3/cmd/protoc-gen-openapi
|
||||
|
||||
.PHONY: api
|
||||
api:
|
||||
protoc --openapi_out=. --proto_path=. proto/place.proto
|
||||
|
||||
.PHONY: proto
|
||||
proto:
|
||||
protoc --proto_path=. --micro_out=. --go_out=:. proto/place.proto
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
go build -o place *.go
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
go test -v ./... -cover
|
||||
|
||||
.PHONY: docker
|
||||
docker:
|
||||
docker build . -t place:latest
|
||||
6
place/README.md
Normal file
6
place/README.md
Normal file
@@ -0,0 +1,6 @@
|
||||
Search for places
|
||||
|
||||
# Place Service
|
||||
|
||||
Search for place information, including points of interest, categories and geographic locations.
|
||||
Search by geolocation or by text query.
|
||||
106
place/examples.json
Normal file
106
place/examples.json
Normal file
@@ -0,0 +1,106 @@
|
||||
{
|
||||
"nearby": [{
|
||||
"title": "Find places nearby",
|
||||
"description": "Find places and points of interest nearby",
|
||||
"run_check": false,
|
||||
"request": {
|
||||
"location": "51.5074577,-0.1297515",
|
||||
"keyword": "tesco",
|
||||
"type": "store"
|
||||
},
|
||||
"response": {
|
||||
"results": [
|
||||
{
|
||||
"name": "Tesco Express",
|
||||
"address": "",
|
||||
"location": "51.5089111,-0.1346174",
|
||||
"type": "",
|
||||
"icon_url": "https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/shopping-71.png",
|
||||
"rating": 3.700000047683716,
|
||||
"open_now": true,
|
||||
"opening_hours": [],
|
||||
"vicinity": "17-25 Regent St., London",
|
||||
"types": [
|
||||
"supermarket",
|
||||
"convenience_store",
|
||||
"grocery_or_supermarket",
|
||||
"food",
|
||||
"point_of_interest",
|
||||
"store",
|
||||
"establishment"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Tesco Express",
|
||||
"address": "",
|
||||
"location": "51.5111163,-0.1251733",
|
||||
"type": "",
|
||||
"icon_url": "https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/shopping-71.png",
|
||||
"rating": 3.9000000953674316,
|
||||
"open_now": true,
|
||||
"opening_hours": [],
|
||||
"vicinity": "22-25 Bedford St, London",
|
||||
"types": [
|
||||
"supermarket",
|
||||
"convenience_store",
|
||||
"grocery_or_supermarket",
|
||||
"food",
|
||||
"point_of_interest",
|
||||
"store",
|
||||
"establishment"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}],
|
||||
"Search": [{
|
||||
"title": "Search for places",
|
||||
"description": "Find places and points of interest",
|
||||
"run_check": false,
|
||||
"request": {
|
||||
"query": "food",
|
||||
"location": "51.5074577,-0.1297515"
|
||||
},
|
||||
"response": {
|
||||
"results": [
|
||||
{
|
||||
"name": "Covent Garden Food \u0026 Wine",
|
||||
"address": "20 Wellington St, London WC2E 7DD",
|
||||
"location": "51.5119823,-0.1200065",
|
||||
"type": "",
|
||||
"icon_url": "https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/shopping-71.png",
|
||||
"rating": 4,
|
||||
"open_now": true,
|
||||
"opening_hours": [],
|
||||
"vicinity": "",
|
||||
"types": [
|
||||
"convenience_store",
|
||||
"book_store",
|
||||
"food",
|
||||
"point_of_interest",
|
||||
"store",
|
||||
"establishment"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Co-op Food - Holborn - Kingsway",
|
||||
"address": "18 Kingsway, London WC2B 6LH",
|
||||
"location": "51.5140073,-0.1176054",
|
||||
"type": "",
|
||||
"icon_url": "https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/shopping-71.png",
|
||||
"rating": 4,
|
||||
"open_now": true,
|
||||
"opening_hours": [],
|
||||
"vicinity": "",
|
||||
"types": [
|
||||
"convenience_store",
|
||||
"food",
|
||||
"point_of_interest",
|
||||
"store",
|
||||
"establishment"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}]
|
||||
}
|
||||
2
place/generate.go
Normal file
2
place/generate.go
Normal file
@@ -0,0 +1,2 @@
|
||||
package main
|
||||
//go:generate make proto
|
||||
179
place/handler/google.go
Normal file
179
place/handler/google.go
Normal file
@@ -0,0 +1,179 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"strconv"
|
||||
|
||||
"googlemaps.github.io/maps"
|
||||
"github.com/micro/micro/v3/service/config"
|
||||
"github.com/micro/micro/v3/service/errors"
|
||||
"github.com/micro/micro/v3/service/logger"
|
||||
|
||||
pb "github.com/micro/services/place/proto"
|
||||
)
|
||||
|
||||
var (
|
||||
Key string
|
||||
Url = "https://maps.googleapis.com/maps/api/"
|
||||
Format = "json"
|
||||
)
|
||||
|
||||
type Google struct {
|
||||
Maps *maps.Client
|
||||
}
|
||||
|
||||
func NewGoogle() *Google {
|
||||
// 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)
|
||||
}
|
||||
|
||||
return &Google{
|
||||
Maps: m,
|
||||
}
|
||||
}
|
||||
|
||||
func (g *Google) Nearby(ctx context.Context, req *pb.NearbyRequest, rsp *pb.NearbyResponse) error {
|
||||
greq := &maps.NearbySearchRequest{}
|
||||
|
||||
if len(req.Location) > 0 {
|
||||
parts := strings.Split(req.Location, ",")
|
||||
if len(parts) > 2 {
|
||||
return errors.BadRequest("place.nearby", "invalid location")
|
||||
}
|
||||
lat, _ := strconv.ParseFloat(parts[0], 64)
|
||||
lng, _ := strconv.ParseFloat(parts[1], 64)
|
||||
|
||||
greq.Location = &maps.LatLng{
|
||||
Lat: lat,
|
||||
Lng: lng,
|
||||
}
|
||||
}
|
||||
|
||||
if req.Radius == 0 {
|
||||
req.Radius = uint32(1000)
|
||||
}
|
||||
|
||||
greq.Radius = uint(req.Radius)
|
||||
greq.Keyword = req.Keyword
|
||||
greq.Name = req.Name
|
||||
greq.OpenNow = req.OpenNow
|
||||
|
||||
// set the place type
|
||||
// https://developers.google.com/maps/documentation/places/web-service/supported_types
|
||||
if len(req.Type) > 0 {
|
||||
pt, err := maps.ParsePlaceType(req.Type)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
greq.Type = pt
|
||||
}
|
||||
|
||||
resp, err := g.Maps.NearbySearch(ctx, greq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, res := range resp.Results {
|
||||
var hours []string
|
||||
var openNow bool
|
||||
if res.OpeningHours != nil {
|
||||
hours = res.OpeningHours.WeekdayText
|
||||
if res.OpeningHours.OpenNow != nil {
|
||||
openNow = *res.OpeningHours.OpenNow
|
||||
}
|
||||
}
|
||||
|
||||
rsp.Results = append(rsp.Results, &pb.Result{
|
||||
Address: res.FormattedAddress,
|
||||
Location: res.Geometry.Location.String(),
|
||||
Name: res.Name,
|
||||
IconUrl: res.Icon,
|
||||
Rating: float64(res.Rating),
|
||||
OpenNow: openNow,
|
||||
OpeningHours: hours,
|
||||
Vicinity: res.Vicinity,
|
||||
Types: res.Types,
|
||||
})
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *Google) Search(ctx context.Context, req *pb.SearchRequest, rsp *pb.SearchResponse) error {
|
||||
if len(req.Query) == 0 {
|
||||
return errors.BadRequest("place.search", "missing query")
|
||||
}
|
||||
|
||||
greq := &maps.TextSearchRequest{}
|
||||
|
||||
if len(req.Location) > 0 {
|
||||
parts := strings.Split(req.Location, ",")
|
||||
if len(parts) > 2 {
|
||||
return errors.BadRequest("place.search", "invalid location")
|
||||
}
|
||||
lat, _ := strconv.ParseFloat(parts[0], 64)
|
||||
lng, _ := strconv.ParseFloat(parts[1], 64)
|
||||
|
||||
greq.Location = &maps.LatLng{
|
||||
Lat: lat,
|
||||
Lng: lng,
|
||||
}
|
||||
}
|
||||
|
||||
if req.Radius == 0 {
|
||||
req.Radius = uint32(1000)
|
||||
}
|
||||
|
||||
greq.Radius = uint(req.Radius)
|
||||
greq.OpenNow = req.OpenNow
|
||||
|
||||
// set the place type
|
||||
// https://developers.google.com/maps/documentation/places/web-service/supported_types
|
||||
if len(req.Type) > 0 {
|
||||
pt, err := maps.ParsePlaceType(req.Type)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
greq.Type = pt
|
||||
}
|
||||
|
||||
resp, err := g.Maps.TextSearch(ctx, greq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, res := range resp.Results {
|
||||
var hours []string
|
||||
var openNow bool
|
||||
if res.OpeningHours != nil {
|
||||
hours = res.OpeningHours.WeekdayText
|
||||
if res.OpeningHours.OpenNow != nil {
|
||||
openNow = *res.OpeningHours.OpenNow
|
||||
}
|
||||
}
|
||||
rsp.Results = append(rsp.Results, &pb.Result{
|
||||
Address: res.FormattedAddress,
|
||||
Location: res.Geometry.Location.String(),
|
||||
Name: res.Name,
|
||||
IconUrl: res.Icon,
|
||||
Rating: float64(res.Rating),
|
||||
OpenNow: openNow,
|
||||
OpeningHours: hours,
|
||||
Vicinity: res.Vicinity,
|
||||
Types: res.Types,
|
||||
})
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
10
place/handler/place.go
Normal file
10
place/handler/place.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package handler
|
||||
|
||||
type Place struct{
|
||||
*Google
|
||||
}
|
||||
|
||||
func New() *Place {
|
||||
g := NewGoogle()
|
||||
return &Place{g}
|
||||
}
|
||||
25
place/main.go
Normal file
25
place/main.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/micro/services/place/handler"
|
||||
pb "github.com/micro/services/place/proto"
|
||||
|
||||
"github.com/micro/micro/v3/service"
|
||||
"github.com/micro/micro/v3/service/logger"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Create service
|
||||
srv := service.New(
|
||||
service.Name("place"),
|
||||
service.Version("latest"),
|
||||
)
|
||||
|
||||
// Register handler
|
||||
pb.RegisterPlaceHandler(srv.Server(), handler.New())
|
||||
|
||||
// Run service
|
||||
if err := srv.Run(); err != nil {
|
||||
logger.Fatal(err)
|
||||
}
|
||||
}
|
||||
1
place/micro.mu
Normal file
1
place/micro.mu
Normal file
@@ -0,0 +1 @@
|
||||
service place
|
||||
602
place/proto/place.pb.go
Normal file
602
place/proto/place.pb.go
Normal file
@@ -0,0 +1,602 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.27.1
|
||||
// protoc v3.15.6
|
||||
// source: proto/place.proto
|
||||
|
||||
package place
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type Result struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// name of the place
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
// address of place
|
||||
Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"`
|
||||
// lat/lng of place
|
||||
Location string `protobuf:"bytes,3,opt,name=location,proto3" json:"location,omitempty"`
|
||||
// type of location
|
||||
Type string `protobuf:"bytes,4,opt,name=type,proto3" json:"type,omitempty"`
|
||||
// url of an icon
|
||||
IconUrl string `protobuf:"bytes,5,opt,name=icon_url,json=iconUrl,proto3" json:"icon_url,omitempty"`
|
||||
// rating from 1.0 to 5.0
|
||||
Rating float64 `protobuf:"fixed64,6,opt,name=rating,proto3" json:"rating,omitempty"`
|
||||
// open now
|
||||
OpenNow bool `protobuf:"varint,7,opt,name=open_now,json=openNow,proto3" json:"open_now,omitempty"`
|
||||
// opening hours
|
||||
OpeningHours []string `protobuf:"bytes,8,rep,name=opening_hours,json=openingHours,proto3" json:"opening_hours,omitempty"`
|
||||
// simplified address
|
||||
Vicinity string `protobuf:"bytes,9,opt,name=vicinity,proto3" json:"vicinity,omitempty"`
|
||||
// feature types
|
||||
Types []string `protobuf:"bytes,10,rep,name=types,proto3" json:"types,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Result) Reset() {
|
||||
*x = Result{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_place_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Result) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Result) ProtoMessage() {}
|
||||
|
||||
func (x *Result) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_place_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Result.ProtoReflect.Descriptor instead.
|
||||
func (*Result) Descriptor() ([]byte, []int) {
|
||||
return file_proto_place_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *Result) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Result) GetAddress() string {
|
||||
if x != nil {
|
||||
return x.Address
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Result) GetLocation() string {
|
||||
if x != nil {
|
||||
return x.Location
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Result) GetType() string {
|
||||
if x != nil {
|
||||
return x.Type
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Result) GetIconUrl() string {
|
||||
if x != nil {
|
||||
return x.IconUrl
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Result) GetRating() float64 {
|
||||
if x != nil {
|
||||
return x.Rating
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Result) GetOpenNow() bool {
|
||||
if x != nil {
|
||||
return x.OpenNow
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *Result) GetOpeningHours() []string {
|
||||
if x != nil {
|
||||
return x.OpeningHours
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Result) GetVicinity() string {
|
||||
if x != nil {
|
||||
return x.Vicinity
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Result) GetTypes() []string {
|
||||
if x != nil {
|
||||
return x.Types
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Search for places nearby, points of interest and geographic locations
|
||||
type NearbyRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// specify the location by lat,lng e.g -33.8670522,-151.1957362
|
||||
Location string `protobuf:"bytes,1,opt,name=location,proto3" json:"location,omitempty"`
|
||||
// radius in meters within which to search
|
||||
Radius uint32 `protobuf:"varint,2,opt,name=radius,proto3" json:"radius,omitempty"`
|
||||
// Keyword to include in the search
|
||||
Keyword string `protobuf:"bytes,3,opt,name=keyword,proto3" json:"keyword,omitempty"`
|
||||
// Name of the place to search for
|
||||
Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"`
|
||||
// Whether the place is open now
|
||||
OpenNow bool `protobuf:"varint,5,opt,name=open_now,json=openNow,proto3" json:"open_now,omitempty"`
|
||||
// Type of place. https://developers.google.com/maps/documentation/places/web-service/supported_types
|
||||
Type string `protobuf:"bytes,6,opt,name=type,proto3" json:"type,omitempty"`
|
||||
}
|
||||
|
||||
func (x *NearbyRequest) Reset() {
|
||||
*x = NearbyRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_place_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *NearbyRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*NearbyRequest) ProtoMessage() {}
|
||||
|
||||
func (x *NearbyRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_place_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use NearbyRequest.ProtoReflect.Descriptor instead.
|
||||
func (*NearbyRequest) Descriptor() ([]byte, []int) {
|
||||
return file_proto_place_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *NearbyRequest) GetLocation() string {
|
||||
if x != nil {
|
||||
return x.Location
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *NearbyRequest) GetRadius() uint32 {
|
||||
if x != nil {
|
||||
return x.Radius
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *NearbyRequest) GetKeyword() string {
|
||||
if x != nil {
|
||||
return x.Keyword
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *NearbyRequest) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *NearbyRequest) GetOpenNow() bool {
|
||||
if x != nil {
|
||||
return x.OpenNow
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *NearbyRequest) GetType() string {
|
||||
if x != nil {
|
||||
return x.Type
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type NearbyResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Results []*Result `protobuf:"bytes,1,rep,name=results,proto3" json:"results,omitempty"`
|
||||
}
|
||||
|
||||
func (x *NearbyResponse) Reset() {
|
||||
*x = NearbyResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_place_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *NearbyResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*NearbyResponse) ProtoMessage() {}
|
||||
|
||||
func (x *NearbyResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_place_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use NearbyResponse.ProtoReflect.Descriptor instead.
|
||||
func (*NearbyResponse) Descriptor() ([]byte, []int) {
|
||||
return file_proto_place_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *NearbyResponse) GetResults() []*Result {
|
||||
if x != nil {
|
||||
return x.Results
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type SearchRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// the text string on which to search, for example: "restaurant"
|
||||
Query string `protobuf:"bytes,1,opt,name=query,proto3" json:"query,omitempty"`
|
||||
// the location by lat,lng e.g -33.8670522,-151.1957362
|
||||
Location string `protobuf:"bytes,2,opt,name=location,proto3" json:"location,omitempty"`
|
||||
// radius in meters within which to search
|
||||
Radius uint32 `protobuf:"varint,3,opt,name=radius,proto3" json:"radius,omitempty"`
|
||||
// Whether the place is open now
|
||||
OpenNow bool `protobuf:"varint,4,opt,name=open_now,json=openNow,proto3" json:"open_now,omitempty"`
|
||||
// Type of place. https://developers.google.com/maps/documentation/places/web-service/supported_types
|
||||
Type string `protobuf:"bytes,5,opt,name=type,proto3" json:"type,omitempty"`
|
||||
}
|
||||
|
||||
func (x *SearchRequest) Reset() {
|
||||
*x = SearchRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_place_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *SearchRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SearchRequest) ProtoMessage() {}
|
||||
|
||||
func (x *SearchRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_place_proto_msgTypes[3]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SearchRequest.ProtoReflect.Descriptor instead.
|
||||
func (*SearchRequest) Descriptor() ([]byte, []int) {
|
||||
return file_proto_place_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *SearchRequest) GetQuery() string {
|
||||
if x != nil {
|
||||
return x.Query
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *SearchRequest) GetLocation() string {
|
||||
if x != nil {
|
||||
return x.Location
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *SearchRequest) GetRadius() uint32 {
|
||||
if x != nil {
|
||||
return x.Radius
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SearchRequest) GetOpenNow() bool {
|
||||
if x != nil {
|
||||
return x.OpenNow
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *SearchRequest) GetType() string {
|
||||
if x != nil {
|
||||
return x.Type
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type SearchResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Results []*Result `protobuf:"bytes,1,rep,name=results,proto3" json:"results,omitempty"`
|
||||
}
|
||||
|
||||
func (x *SearchResponse) Reset() {
|
||||
*x = SearchResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_place_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *SearchResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SearchResponse) ProtoMessage() {}
|
||||
|
||||
func (x *SearchResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_place_proto_msgTypes[4]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SearchResponse.ProtoReflect.Descriptor instead.
|
||||
func (*SearchResponse) Descriptor() ([]byte, []int) {
|
||||
return file_proto_place_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *SearchResponse) GetResults() []*Result {
|
||||
if x != nil {
|
||||
return x.Results
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_proto_place_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_proto_place_proto_rawDesc = []byte{
|
||||
0x0a, 0x11, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x2e, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x12, 0x05, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x22, 0x8b, 0x02, 0x0a, 0x06, 0x52,
|
||||
0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64,
|
||||
0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72,
|
||||
0x65, 0x73, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18,
|
||||
0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12,
|
||||
0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74,
|
||||
0x79, 0x70, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x69, 0x63, 0x6f, 0x6e, 0x5f, 0x75, 0x72, 0x6c, 0x18,
|
||||
0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x69, 0x63, 0x6f, 0x6e, 0x55, 0x72, 0x6c, 0x12, 0x16,
|
||||
0x0a, 0x06, 0x72, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x01, 0x52, 0x06,
|
||||
0x72, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x19, 0x0a, 0x08, 0x6f, 0x70, 0x65, 0x6e, 0x5f, 0x6e,
|
||||
0x6f, 0x77, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x6f, 0x70, 0x65, 0x6e, 0x4e, 0x6f,
|
||||
0x77, 0x12, 0x23, 0x0a, 0x0d, 0x6f, 0x70, 0x65, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x68, 0x6f, 0x75,
|
||||
0x72, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x6f, 0x70, 0x65, 0x6e, 0x69, 0x6e,
|
||||
0x67, 0x48, 0x6f, 0x75, 0x72, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x76, 0x69, 0x63, 0x69, 0x6e, 0x69,
|
||||
0x74, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x69, 0x63, 0x69, 0x6e, 0x69,
|
||||
0x74, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x79, 0x70, 0x65, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28,
|
||||
0x09, 0x52, 0x05, 0x74, 0x79, 0x70, 0x65, 0x73, 0x22, 0xa0, 0x01, 0x0a, 0x0d, 0x4e, 0x65, 0x61,
|
||||
0x72, 0x62, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x6c, 0x6f,
|
||||
0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6c, 0x6f,
|
||||
0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x12, 0x18,
|
||||
0x0a, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65,
|
||||
0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x19, 0x0a, 0x08,
|
||||
0x6f, 0x70, 0x65, 0x6e, 0x5f, 0x6e, 0x6f, 0x77, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07,
|
||||
0x6f, 0x70, 0x65, 0x6e, 0x4e, 0x6f, 0x77, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18,
|
||||
0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x39, 0x0a, 0x0e, 0x4e,
|
||||
0x65, 0x61, 0x72, 0x62, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a,
|
||||
0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d,
|
||||
0x2e, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x07, 0x72,
|
||||
0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x22, 0x88, 0x01, 0x0a, 0x0d, 0x53, 0x65, 0x61, 0x72, 0x63,
|
||||
0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72,
|
||||
0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, 0x1a,
|
||||
0x0a, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x61,
|
||||
0x64, 0x69, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x72, 0x61, 0x64, 0x69,
|
||||
0x75, 0x73, 0x12, 0x19, 0x0a, 0x08, 0x6f, 0x70, 0x65, 0x6e, 0x5f, 0x6e, 0x6f, 0x77, 0x18, 0x04,
|
||||
0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x6f, 0x70, 0x65, 0x6e, 0x4e, 0x6f, 0x77, 0x12, 0x12, 0x0a,
|
||||
0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70,
|
||||
0x65, 0x22, 0x39, 0x0a, 0x0e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f,
|
||||
0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x18, 0x01,
|
||||
0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x2e, 0x52, 0x65, 0x73,
|
||||
0x75, 0x6c, 0x74, 0x52, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x32, 0x79, 0x0a, 0x05,
|
||||
0x50, 0x6c, 0x61, 0x63, 0x65, 0x12, 0x37, 0x0a, 0x06, 0x4e, 0x65, 0x61, 0x72, 0x62, 0x79, 0x12,
|
||||
0x14, 0x2e, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x2e, 0x4e, 0x65, 0x61, 0x72, 0x62, 0x79, 0x52, 0x65,
|
||||
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x2e, 0x4e, 0x65,
|
||||
0x61, 0x72, 0x62, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x37,
|
||||
0x0a, 0x06, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x12, 0x14, 0x2e, 0x70, 0x6c, 0x61, 0x63, 0x65,
|
||||
0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15,
|
||||
0x2e, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73,
|
||||
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x0f, 0x5a, 0x0d, 0x2e, 0x2f, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x3b, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_proto_place_proto_rawDescOnce sync.Once
|
||||
file_proto_place_proto_rawDescData = file_proto_place_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_proto_place_proto_rawDescGZIP() []byte {
|
||||
file_proto_place_proto_rawDescOnce.Do(func() {
|
||||
file_proto_place_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_place_proto_rawDescData)
|
||||
})
|
||||
return file_proto_place_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_proto_place_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
|
||||
var file_proto_place_proto_goTypes = []interface{}{
|
||||
(*Result)(nil), // 0: place.Result
|
||||
(*NearbyRequest)(nil), // 1: place.NearbyRequest
|
||||
(*NearbyResponse)(nil), // 2: place.NearbyResponse
|
||||
(*SearchRequest)(nil), // 3: place.SearchRequest
|
||||
(*SearchResponse)(nil), // 4: place.SearchResponse
|
||||
}
|
||||
var file_proto_place_proto_depIdxs = []int32{
|
||||
0, // 0: place.NearbyResponse.results:type_name -> place.Result
|
||||
0, // 1: place.SearchResponse.results:type_name -> place.Result
|
||||
1, // 2: place.Place.Nearby:input_type -> place.NearbyRequest
|
||||
3, // 3: place.Place.Search:input_type -> place.SearchRequest
|
||||
2, // 4: place.Place.Nearby:output_type -> place.NearbyResponse
|
||||
4, // 5: place.Place.Search:output_type -> place.SearchResponse
|
||||
4, // [4:6] is the sub-list for method output_type
|
||||
2, // [2:4] is the sub-list for method input_type
|
||||
2, // [2:2] is the sub-list for extension type_name
|
||||
2, // [2:2] is the sub-list for extension extendee
|
||||
0, // [0:2] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_proto_place_proto_init() }
|
||||
func file_proto_place_proto_init() {
|
||||
if File_proto_place_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_proto_place_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Result); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_place_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*NearbyRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_place_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*NearbyResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_place_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*SearchRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_place_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*SearchResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_proto_place_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 5,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_proto_place_proto_goTypes,
|
||||
DependencyIndexes: file_proto_place_proto_depIdxs,
|
||||
MessageInfos: file_proto_place_proto_msgTypes,
|
||||
}.Build()
|
||||
File_proto_place_proto = out.File
|
||||
file_proto_place_proto_rawDesc = nil
|
||||
file_proto_place_proto_goTypes = nil
|
||||
file_proto_place_proto_depIdxs = nil
|
||||
}
|
||||
110
place/proto/place.pb.micro.go
Normal file
110
place/proto/place.pb.micro.go
Normal file
@@ -0,0 +1,110 @@
|
||||
// Code generated by protoc-gen-micro. DO NOT EDIT.
|
||||
// source: proto/place.proto
|
||||
|
||||
package place
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
math "math"
|
||||
)
|
||||
|
||||
import (
|
||||
context "context"
|
||||
api "github.com/micro/micro/v3/service/api"
|
||||
client "github.com/micro/micro/v3/service/client"
|
||||
server "github.com/micro/micro/v3/service/server"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ api.Endpoint
|
||||
var _ context.Context
|
||||
var _ client.Option
|
||||
var _ server.Option
|
||||
|
||||
// Api Endpoints for Place service
|
||||
|
||||
func NewPlaceEndpoints() []*api.Endpoint {
|
||||
return []*api.Endpoint{}
|
||||
}
|
||||
|
||||
// Client API for Place service
|
||||
|
||||
type PlaceService interface {
|
||||
Nearby(ctx context.Context, in *NearbyRequest, opts ...client.CallOption) (*NearbyResponse, error)
|
||||
Search(ctx context.Context, in *SearchRequest, opts ...client.CallOption) (*SearchResponse, error)
|
||||
}
|
||||
|
||||
type placeService struct {
|
||||
c client.Client
|
||||
name string
|
||||
}
|
||||
|
||||
func NewPlaceService(name string, c client.Client) PlaceService {
|
||||
return &placeService{
|
||||
c: c,
|
||||
name: name,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *placeService) Nearby(ctx context.Context, in *NearbyRequest, opts ...client.CallOption) (*NearbyResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "Place.Nearby", in)
|
||||
out := new(NearbyResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *placeService) Search(ctx context.Context, in *SearchRequest, opts ...client.CallOption) (*SearchResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "Place.Search", in)
|
||||
out := new(SearchResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for Place service
|
||||
|
||||
type PlaceHandler interface {
|
||||
Nearby(context.Context, *NearbyRequest, *NearbyResponse) error
|
||||
Search(context.Context, *SearchRequest, *SearchResponse) error
|
||||
}
|
||||
|
||||
func RegisterPlaceHandler(s server.Server, hdlr PlaceHandler, opts ...server.HandlerOption) error {
|
||||
type place interface {
|
||||
Nearby(ctx context.Context, in *NearbyRequest, out *NearbyResponse) error
|
||||
Search(ctx context.Context, in *SearchRequest, out *SearchResponse) error
|
||||
}
|
||||
type Place struct {
|
||||
place
|
||||
}
|
||||
h := &placeHandler{hdlr}
|
||||
return s.Handle(s.NewHandler(&Place{h}, opts...))
|
||||
}
|
||||
|
||||
type placeHandler struct {
|
||||
PlaceHandler
|
||||
}
|
||||
|
||||
func (h *placeHandler) Nearby(ctx context.Context, in *NearbyRequest, out *NearbyResponse) error {
|
||||
return h.PlaceHandler.Nearby(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *placeHandler) Search(ctx context.Context, in *SearchRequest, out *SearchResponse) error {
|
||||
return h.PlaceHandler.Search(ctx, in, out)
|
||||
}
|
||||
70
place/proto/place.proto
Normal file
70
place/proto/place.proto
Normal file
@@ -0,0 +1,70 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package place;
|
||||
|
||||
option go_package = "./proto;place";
|
||||
|
||||
service Place {
|
||||
rpc Nearby(NearbyRequest) returns (NearbyResponse) {}
|
||||
rpc Search(SearchRequest) returns (SearchResponse) {}
|
||||
}
|
||||
|
||||
message Result {
|
||||
// name of the place
|
||||
string name = 1;
|
||||
// address of place
|
||||
string address = 2;
|
||||
// lat/lng of place
|
||||
string location = 3;
|
||||
// type of location
|
||||
string type = 4;
|
||||
// url of an icon
|
||||
string icon_url = 5;
|
||||
// rating from 1.0 to 5.0
|
||||
double rating = 6;
|
||||
// open now
|
||||
bool open_now = 7;
|
||||
// opening hours
|
||||
repeated string opening_hours = 8;
|
||||
// simplified address
|
||||
string vicinity = 9;
|
||||
// feature types
|
||||
repeated string types = 10;
|
||||
}
|
||||
|
||||
// Search for places nearby, points of interest and geographic locations
|
||||
message NearbyRequest {
|
||||
// specify the location by lat,lng e.g -33.8670522,-151.1957362
|
||||
string location = 1;
|
||||
// radius in meters within which to search
|
||||
uint32 radius = 2;
|
||||
// Keyword to include in the search
|
||||
string keyword = 3;
|
||||
// Name of the place to search for
|
||||
string name = 4;
|
||||
// Whether the place is open now
|
||||
bool open_now = 5;
|
||||
// Type of place. https://developers.google.com/maps/documentation/places/web-service/supported_types
|
||||
string type = 6;
|
||||
}
|
||||
|
||||
message NearbyResponse {
|
||||
repeated Result results = 1;
|
||||
}
|
||||
|
||||
message SearchRequest {
|
||||
// the text string on which to search, for example: "restaurant"
|
||||
string query = 1;
|
||||
// the location by lat,lng e.g -33.8670522,-151.1957362
|
||||
string location = 2;
|
||||
// radius in meters within which to search
|
||||
uint32 radius = 3;
|
||||
// Whether the place is open now
|
||||
bool open_now = 4;
|
||||
// Type of place. https://developers.google.com/maps/documentation/places/web-service/supported_types
|
||||
string type = 5;
|
||||
}
|
||||
|
||||
message SearchResponse {
|
||||
repeated Result results = 1;
|
||||
}
|
||||
6
place/publicapi.json
Normal file
6
place/publicapi.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "place",
|
||||
"icon": "🗺️",
|
||||
"category": "utility",
|
||||
"display_name": "Places"
|
||||
}
|
||||
Reference in New Issue
Block a user