rename locations to places (#38)

* rename locations to places

* update failing things

Co-authored-by: Janos Dobronszki <dobronszki@gmail.com>
This commit is contained in:
Asim Aslam
2021-01-13 13:08:19 +00:00
committed by GitHub
parent a8e56e5e9e
commit ef2f313e33
15 changed files with 662 additions and 882 deletions

14
go.sum
View File

@@ -80,6 +80,7 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5P
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/cloudflare/cloudflare-go v0.10.2/go.mod h1:qhVI5MKwBGhdNU89ZRz2plgYutcJ5PCekLxXn56w6SY=
github.com/cloudflare/cloudflare-go v0.10.9/go.mod h1:5TrsWH+3f4NV6WjtS5QFp+DifH81rph40gU374Sh0dQ=
github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I=
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
@@ -136,6 +137,7 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekf
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
@@ -220,8 +222,10 @@ github.com/improbable-eng/grpc-web v0.13.0 h1:7XqtaBWaOCH0cVGKHyvhtcuo6fgW32Y10y
github.com/improbable-eng/grpc-web v0.13.0/go.mod h1:6hRR09jOEG81ADP5wCQju1z71g6OL4eEvELdran/3cs=
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf h1:WfD7VjIE6z8dIvMsI4/s+1qr5EL+zoIGev1BQj1eoJ8=
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf/go.mod h1:hyb9oH7vZsitZCiBt0ZvifOrB+qc8PS5IiilCIb87rg=
github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0=
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8=
github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA=
github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW9/pnVKPazfWOgNfH2aPem8YQ7ilXGvJE=
@@ -231,9 +235,13 @@ github.com/jackc/pgconn v1.5.0/go.mod h1:QeD3lBfpTFe8WUnPZWN5KY/mB8FGMIYRdd8P8Jr
github.com/jackc/pgconn v1.5.1-0.20200601181101-fa742c524853/go.mod h1:QeD3lBfpTFe8WUnPZWN5KY/mB8FGMIYRdd8P8Jr0fAI=
github.com/jackc/pgconn v1.8.0 h1:FmjZ0rOyXTr1wfWs45i4a9vjnjWUAGpMuQLD9OSs+lw=
github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o=
github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE=
github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8=
github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2 h1:JVX6jT/XfzNqIjye4717ITLaNwV9mWbJx0dLCpcRzdA=
github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgproto3 v1.1.0 h1:FYYE4yRw+AgI8wXIinMlNjBbp/UitDJwfj5LqqewP1A=
github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78=
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA=
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg=
@@ -243,6 +251,7 @@ github.com/jackc/pgproto3/v2 v2.0.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwX
github.com/jackc/pgproto3/v2 v2.0.6 h1:b1105ZGEMFe7aCvrT1Cca3VoVb4ZFMaFJLJcg/3zD+8=
github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
github.com/jackc/pgservicefile v0.0.0-20200307190119-3430c5407db8/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg=
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg=
github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc=
@@ -266,7 +275,9 @@ github.com/jackc/puddle v1.1.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dv
github.com/jackc/puddle v1.1.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.1 h1:g39TucaRWyV3dwDO++eEc6qf8TVIQ/Da48WmqjZ3i7E=
github.com/jinzhu/now v1.1.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
@@ -299,6 +310,7 @@ github.com/labbsr0x/goh v1.0.1/go.mod h1:8K2UhVoaWXcCU7Lxoa2omWnC8gyW8px7/lmO61c
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU=
github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/linode/linodego v0.10.0/go.mod h1:cziNP7pbvE3mXIPneHj0oRY8L1WtGEIKlZ8LANE4eXA=
github.com/liquidweb/liquidweb-go v1.6.0/go.mod h1:UDcVnAMDkZxpw4Y7NOHkqoeiGacVLEIG/i5J9cyixzQ=
@@ -404,8 +416,10 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
github.com/sacloud/libsacloud v1.26.1/go.mod h1:79ZwATmHLIFZIMd7sxA3LwzVy/B77uj3LDoToVTxDoQ=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/serenize/snaker v0.0.0-20171204205717-a683aaf2d516/go.mod h1:Yow6lPLSAXx2ifx470yD/nUe22Dv5vBvxK/UK9UUTVs=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
github.com/shopspring/decimal v0.0.0-20200227202807-02e2044944cc h1:jUIKcSPO9MoMJBbEoyE/RJoE8vz7Mb8AjvifMMwSyvY=
github.com/shopspring/decimal v0.0.0-20200227202807-02e2044944cc/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=

View File

@@ -1 +0,0 @@
service locations

View File

@@ -1,643 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.23.0
// protoc v3.13.0
// source: proto/locations.proto
package locations
import (
proto "github.com/golang/protobuf/proto"
timestamp "github.com/golang/protobuf/ptypes/timestamp"
wrappers "github.com/golang/protobuf/ptypes/wrappers"
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)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type Location struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
Timestamp *timestamp.Timestamp `protobuf:"bytes,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
Latitude *wrappers.DoubleValue `protobuf:"bytes,3,opt,name=latitude,proto3" json:"latitude,omitempty"`
Longitude *wrappers.DoubleValue `protobuf:"bytes,4,opt,name=longitude,proto3" json:"longitude,omitempty"`
}
func (x *Location) Reset() {
*x = Location{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_locations_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Location) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Location) ProtoMessage() {}
func (x *Location) ProtoReflect() protoreflect.Message {
mi := &file_proto_locations_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 Location.ProtoReflect.Descriptor instead.
func (*Location) Descriptor() ([]byte, []int) {
return file_proto_locations_proto_rawDescGZIP(), []int{0}
}
func (x *Location) GetUserId() string {
if x != nil {
return x.UserId
}
return ""
}
func (x *Location) GetTimestamp() *timestamp.Timestamp {
if x != nil {
return x.Timestamp
}
return nil
}
func (x *Location) GetLatitude() *wrappers.DoubleValue {
if x != nil {
return x.Latitude
}
return nil
}
func (x *Location) GetLongitude() *wrappers.DoubleValue {
if x != nil {
return x.Longitude
}
return nil
}
type SaveRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Locations []*Location `protobuf:"bytes,1,rep,name=locations,proto3" json:"locations,omitempty"`
}
func (x *SaveRequest) Reset() {
*x = SaveRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_locations_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SaveRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SaveRequest) ProtoMessage() {}
func (x *SaveRequest) ProtoReflect() protoreflect.Message {
mi := &file_proto_locations_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 SaveRequest.ProtoReflect.Descriptor instead.
func (*SaveRequest) Descriptor() ([]byte, []int) {
return file_proto_locations_proto_rawDescGZIP(), []int{1}
}
func (x *SaveRequest) GetLocations() []*Location {
if x != nil {
return x.Locations
}
return nil
}
type SaveResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *SaveResponse) Reset() {
*x = SaveResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_locations_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SaveResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SaveResponse) ProtoMessage() {}
func (x *SaveResponse) ProtoReflect() protoreflect.Message {
mi := &file_proto_locations_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 SaveResponse.ProtoReflect.Descriptor instead.
func (*SaveResponse) Descriptor() ([]byte, []int) {
return file_proto_locations_proto_rawDescGZIP(), []int{2}
}
type LastRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
UserIds []string `protobuf:"bytes,1,rep,name=user_ids,json=userIds,proto3" json:"user_ids,omitempty"`
}
func (x *LastRequest) Reset() {
*x = LastRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_locations_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *LastRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*LastRequest) ProtoMessage() {}
func (x *LastRequest) ProtoReflect() protoreflect.Message {
mi := &file_proto_locations_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 LastRequest.ProtoReflect.Descriptor instead.
func (*LastRequest) Descriptor() ([]byte, []int) {
return file_proto_locations_proto_rawDescGZIP(), []int{3}
}
func (x *LastRequest) GetUserIds() []string {
if x != nil {
return x.UserIds
}
return nil
}
type ListResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Locations []*Location `protobuf:"bytes,1,rep,name=locations,proto3" json:"locations,omitempty"`
}
func (x *ListResponse) Reset() {
*x = ListResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_locations_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ListResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListResponse) ProtoMessage() {}
func (x *ListResponse) ProtoReflect() protoreflect.Message {
mi := &file_proto_locations_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 ListResponse.ProtoReflect.Descriptor instead.
func (*ListResponse) Descriptor() ([]byte, []int) {
return file_proto_locations_proto_rawDescGZIP(), []int{4}
}
func (x *ListResponse) GetLocations() []*Location {
if x != nil {
return x.Locations
}
return nil
}
type NearRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Latitude *wrappers.DoubleValue `protobuf:"bytes,1,opt,name=latitude,proto3" json:"latitude,omitempty"`
Longitude *wrappers.DoubleValue `protobuf:"bytes,2,opt,name=longitude,proto3" json:"longitude,omitempty"`
// radius to search within, units km
Radius *wrappers.DoubleValue `protobuf:"bytes,3,opt,name=radius,proto3" json:"radius,omitempty"`
}
func (x *NearRequest) Reset() {
*x = NearRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_locations_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *NearRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*NearRequest) ProtoMessage() {}
func (x *NearRequest) ProtoReflect() protoreflect.Message {
mi := &file_proto_locations_proto_msgTypes[5]
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 NearRequest.ProtoReflect.Descriptor instead.
func (*NearRequest) Descriptor() ([]byte, []int) {
return file_proto_locations_proto_rawDescGZIP(), []int{5}
}
func (x *NearRequest) GetLatitude() *wrappers.DoubleValue {
if x != nil {
return x.Latitude
}
return nil
}
func (x *NearRequest) GetLongitude() *wrappers.DoubleValue {
if x != nil {
return x.Longitude
}
return nil
}
func (x *NearRequest) GetRadius() *wrappers.DoubleValue {
if x != nil {
return x.Radius
}
return nil
}
type ReadRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
UserIds []string `protobuf:"bytes,1,rep,name=user_ids,json=userIds,proto3" json:"user_ids,omitempty"`
After *timestamp.Timestamp `protobuf:"bytes,2,opt,name=after,proto3" json:"after,omitempty"`
Before *timestamp.Timestamp `protobuf:"bytes,3,opt,name=before,proto3" json:"before,omitempty"`
}
func (x *ReadRequest) Reset() {
*x = ReadRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_locations_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ReadRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ReadRequest) ProtoMessage() {}
func (x *ReadRequest) ProtoReflect() protoreflect.Message {
mi := &file_proto_locations_proto_msgTypes[6]
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 ReadRequest.ProtoReflect.Descriptor instead.
func (*ReadRequest) Descriptor() ([]byte, []int) {
return file_proto_locations_proto_rawDescGZIP(), []int{6}
}
func (x *ReadRequest) GetUserIds() []string {
if x != nil {
return x.UserIds
}
return nil
}
func (x *ReadRequest) GetAfter() *timestamp.Timestamp {
if x != nil {
return x.After
}
return nil
}
func (x *ReadRequest) GetBefore() *timestamp.Timestamp {
if x != nil {
return x.Before
}
return nil
}
var File_proto_locations_proto protoreflect.FileDescriptor
var file_proto_locations_proto_rawDesc = []byte{
0x0a, 0x15, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x73, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x22, 0xd3, 0x01, 0x0a, 0x08, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d,
0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67,
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54,
0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74,
0x61, 0x6d, 0x70, 0x12, 0x38, 0x0a, 0x08, 0x6c, 0x61, 0x74, 0x69, 0x74, 0x75, 0x64, 0x65, 0x18,
0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61,
0x6c, 0x75, 0x65, 0x52, 0x08, 0x6c, 0x61, 0x74, 0x69, 0x74, 0x75, 0x64, 0x65, 0x12, 0x3a, 0x0a,
0x09, 0x6c, 0x6f, 0x6e, 0x67, 0x69, 0x74, 0x75, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
0x75, 0x66, 0x2e, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x09,
0x6c, 0x6f, 0x6e, 0x67, 0x69, 0x74, 0x75, 0x64, 0x65, 0x22, 0x40, 0x0a, 0x0b, 0x53, 0x61, 0x76,
0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x31, 0x0a, 0x09, 0x6c, 0x6f, 0x63, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x6c, 0x6f,
0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x52, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x0e, 0x0a, 0x0c, 0x53,
0x61, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x28, 0x0a, 0x0b, 0x4c,
0x61, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x75, 0x73,
0x65, 0x72, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x75, 0x73,
0x65, 0x72, 0x49, 0x64, 0x73, 0x22, 0x41, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x31, 0x0a, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x6c, 0x6f, 0x63, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x6c,
0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0xb9, 0x01, 0x0a, 0x0b, 0x4e, 0x65, 0x61,
0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x38, 0x0a, 0x08, 0x6c, 0x61, 0x74, 0x69,
0x74, 0x75, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f,
0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x6f, 0x75,
0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x08, 0x6c, 0x61, 0x74, 0x69, 0x74, 0x75,
0x64, 0x65, 0x12, 0x3a, 0x0a, 0x09, 0x6c, 0x6f, 0x6e, 0x67, 0x69, 0x74, 0x75, 0x64, 0x65, 0x18,
0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61,
0x6c, 0x75, 0x65, 0x52, 0x09, 0x6c, 0x6f, 0x6e, 0x67, 0x69, 0x74, 0x75, 0x64, 0x65, 0x12, 0x34,
0x0a, 0x06, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c,
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
0x2e, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x06, 0x72, 0x61,
0x64, 0x69, 0x75, 0x73, 0x22, 0x8e, 0x01, 0x0a, 0x0b, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x73,
0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x73, 0x12,
0x30, 0x0a, 0x05, 0x61, 0x66, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a,
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x05, 0x61, 0x66, 0x74, 0x65,
0x72, 0x12, 0x32, 0x0a, 0x06, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28,
0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x06, 0x62,
0x65, 0x66, 0x6f, 0x72, 0x65, 0x32, 0xf7, 0x01, 0x0a, 0x09, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x73, 0x12, 0x39, 0x0a, 0x04, 0x53, 0x61, 0x76, 0x65, 0x12, 0x16, 0x2e, 0x6c, 0x6f,
0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x61, 0x76, 0x65, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e,
0x53, 0x61, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x39,
0x0a, 0x04, 0x4c, 0x61, 0x73, 0x74, 0x12, 0x16, 0x2e, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x73, 0x2e, 0x4c, 0x61, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17,
0x2e, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x39, 0x0a, 0x04, 0x4e, 0x65, 0x61,
0x72, 0x12, 0x16, 0x2e, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4e, 0x65,
0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x6c, 0x6f, 0x63, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x22, 0x00, 0x12, 0x39, 0x0a, 0x04, 0x52, 0x65, 0x61, 0x64, 0x12, 0x16, 0x2e, 0x6c,
0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73,
0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42,
0x35, 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x69,
0x63, 0x72, 0x6f, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x6c, 0x6f, 0x63,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x6c, 0x6f, 0x63,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_proto_locations_proto_rawDescOnce sync.Once
file_proto_locations_proto_rawDescData = file_proto_locations_proto_rawDesc
)
func file_proto_locations_proto_rawDescGZIP() []byte {
file_proto_locations_proto_rawDescOnce.Do(func() {
file_proto_locations_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_locations_proto_rawDescData)
})
return file_proto_locations_proto_rawDescData
}
var file_proto_locations_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_proto_locations_proto_goTypes = []interface{}{
(*Location)(nil), // 0: locations.Location
(*SaveRequest)(nil), // 1: locations.SaveRequest
(*SaveResponse)(nil), // 2: locations.SaveResponse
(*LastRequest)(nil), // 3: locations.LastRequest
(*ListResponse)(nil), // 4: locations.ListResponse
(*NearRequest)(nil), // 5: locations.NearRequest
(*ReadRequest)(nil), // 6: locations.ReadRequest
(*timestamp.Timestamp)(nil), // 7: google.protobuf.Timestamp
(*wrappers.DoubleValue)(nil), // 8: google.protobuf.DoubleValue
}
var file_proto_locations_proto_depIdxs = []int32{
7, // 0: locations.Location.timestamp:type_name -> google.protobuf.Timestamp
8, // 1: locations.Location.latitude:type_name -> google.protobuf.DoubleValue
8, // 2: locations.Location.longitude:type_name -> google.protobuf.DoubleValue
0, // 3: locations.SaveRequest.locations:type_name -> locations.Location
0, // 4: locations.ListResponse.locations:type_name -> locations.Location
8, // 5: locations.NearRequest.latitude:type_name -> google.protobuf.DoubleValue
8, // 6: locations.NearRequest.longitude:type_name -> google.protobuf.DoubleValue
8, // 7: locations.NearRequest.radius:type_name -> google.protobuf.DoubleValue
7, // 8: locations.ReadRequest.after:type_name -> google.protobuf.Timestamp
7, // 9: locations.ReadRequest.before:type_name -> google.protobuf.Timestamp
1, // 10: locations.Locations.Save:input_type -> locations.SaveRequest
3, // 11: locations.Locations.Last:input_type -> locations.LastRequest
5, // 12: locations.Locations.Near:input_type -> locations.NearRequest
6, // 13: locations.Locations.Read:input_type -> locations.ReadRequest
2, // 14: locations.Locations.Save:output_type -> locations.SaveResponse
4, // 15: locations.Locations.Last:output_type -> locations.ListResponse
4, // 16: locations.Locations.Near:output_type -> locations.ListResponse
4, // 17: locations.Locations.Read:output_type -> locations.ListResponse
14, // [14:18] is the sub-list for method output_type
10, // [10:14] is the sub-list for method input_type
10, // [10:10] is the sub-list for extension type_name
10, // [10:10] is the sub-list for extension extendee
0, // [0:10] is the sub-list for field type_name
}
func init() { file_proto_locations_proto_init() }
func file_proto_locations_proto_init() {
if File_proto_locations_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_proto_locations_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Location); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_locations_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SaveRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_locations_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SaveResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_locations_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*LastRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_locations_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_locations_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*NearRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_locations_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ReadRequest); 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_locations_proto_rawDesc,
NumEnums: 0,
NumMessages: 7,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_proto_locations_proto_goTypes,
DependencyIndexes: file_proto_locations_proto_depIdxs,
MessageInfos: file_proto_locations_proto_msgTypes,
}.Build()
File_proto_locations_proto = out.File
file_proto_locations_proto_rawDesc = nil
file_proto_locations_proto_goTypes = nil
file_proto_locations_proto_depIdxs = nil
}

View File

@@ -7,12 +7,12 @@ init:
.PHONY: proto
proto:
protoc --proto_path=. --micro_out=. --go_out=:. proto/locations.proto
protoc --proto_path=. --micro_out=. --go_out=:. proto/places.proto
.PHONY: build
build:
go build -o locations *.go
go build -o places *.go
.PHONY: test
test:
go test -v ./... -cover
go test -v ./... -cover

View File

@@ -1,2 +1,3 @@
package main
//go:generate make proto

View File

@@ -13,52 +13,52 @@ import (
"github.com/micro/micro/v3/service/errors"
"github.com/micro/micro/v3/service/logger"
"github.com/micro/services/locations/model"
pb "github.com/micro/services/locations/proto"
"github.com/micro/services/places/model"
pb "github.com/micro/services/places/proto"
)
var (
ErrMissingLocations = errors.BadRequest("MISSING_LOCATIONS", "One or more locations are required")
ErrMissingPlaces = errors.BadRequest("MISSING_LOCATIONS", "One or more places are required")
ErrMissingLatitude = errors.BadRequest("MISSING_LATITUDE", "Latitude is required")
ErrMissingLongitude = errors.BadRequest("MISSING_LONGITUDE", "Longitude is required")
ErrMissingUserID = errors.BadRequest("MISSING_USER_ID", "UserID is required")
ErrMissingUserIDs = errors.BadRequest("MISSING_USER_IDS", "One or more UserIDs are required")
ErrMissingID = errors.BadRequest("MISSING_ID", "Place ID is required")
ErrMissingIDs = errors.BadRequest("MISSING_IDS", "One or more Place IDs are required")
ErrMissingBefore = errors.BadRequest("MISSING_BEFORE", "Before timestamp is required")
ErrMissingAfter = errors.BadRequest("MISSING_AFTER", "After timestamp is required")
ErrMissingRadius = errors.BadRequest("MISSING_RADIUS", "Radius is required")
)
type Locations struct {
type Places struct {
sync.RWMutex
Geoindex *geo.PointsIndex
DB *gorm.DB
}
// Save a set of locations
func (l *Locations) Save(ctx context.Context, req *pb.SaveRequest, rsp *pb.SaveResponse) error {
// Save a set of places
func (l *Places) Save(ctx context.Context, req *pb.SaveRequest, rsp *pb.SaveResponse) error {
// validate the request
if len(req.Locations) == 0 {
return ErrMissingLocations
if len(req.Places) == 0 {
return ErrMissingPlaces
}
for _, l := range req.Locations {
for _, l := range req.Places {
if l.Latitude == nil {
return ErrMissingLatitude
}
if l.Longitude == nil {
return ErrMissingLongitude
}
if len(l.UserId) == 0 {
return ErrMissingUserID
if len(l.Id) == 0 {
return ErrMissingID
}
}
// construct the database objects
ls := make([]*model.Location, len(req.Locations))
for i, lc := range req.Locations {
ls := make([]*model.Location, len(req.Places))
for i, lc := range req.Places {
loc := &model.Location{
ID: uuid.New().String(),
UserID: lc.UserId,
PlaceID: lc.Id,
Latitude: lc.Latitude.Value,
Longitude: lc.Longitude.Value,
}
@@ -85,15 +85,15 @@ func (l *Locations) Save(ctx context.Context, req *pb.SaveRequest, rsp *pb.SaveR
return nil
}
// Last locations for a set of users
func (l *Locations) Last(ctx context.Context, req *pb.LastRequest, rsp *pb.ListResponse) error {
// Last places for a set of users
func (l *Places) Last(ctx context.Context, req *pb.LastRequest, rsp *pb.ListResponse) error {
// validate the request
if req.UserIds == nil {
return ErrMissingUserIDs
if req.Ids == nil {
return ErrMissingIDs
}
// query the database
q := l.DB.Raw("SELECT DISTINCT ON (user_id) user_id, timestamp, latitude, longitude FROM locations WHERE user_id IN (?) ORDER BY user_id, timestamp DESC", req.UserIds)
q := l.DB.Raw("SELECT DISTINCT ON (place_id) place_id, timestamp, latitude, longitude FROM places WHERE place_id IN (?) ORDER BY place_id, timestamp DESC", req.Ids)
var locs []*model.Location
if err := q.Find(&locs).Error; err != nil {
logger.Errorf("Error reading from the database: %v", err)
@@ -101,12 +101,12 @@ func (l *Locations) Last(ctx context.Context, req *pb.LastRequest, rsp *pb.ListR
}
// serialize the result
rsp.Locations = serializeLocations(locs)
rsp.Places = serializePlaces(locs)
return nil
}
// Near returns the locations near a point
func (l *Locations) Near(ctx context.Context, req *pb.NearRequest, rsp *pb.ListResponse) error {
// Near returns the places near a point
func (l *Places) Near(ctx context.Context, req *pb.NearRequest, rsp *pb.ListResponse) error {
// validate the request
if req.Latitude == nil {
return ErrMissingLatitude
@@ -131,15 +131,15 @@ func (l *Locations) Near(ctx context.Context, req *pb.NearRequest, rsp *pb.ListR
for i, r := range result {
locs[i] = r.(*model.Location)
}
rsp.Locations = serializeLocations(locs)
rsp.Places = serializePlaces(locs)
return nil
}
// Read locations for a group of users between two points in time
func (l *Locations) Read(ctx context.Context, req *pb.ReadRequest, rsp *pb.ListResponse) error {
// Read places for a group of users between two points in time
func (l *Places) Read(ctx context.Context, req *pb.ReadRequest, rsp *pb.ListResponse) error {
// validate the request
if len(req.UserIds) == 0 {
return ErrMissingUserIDs
if len(req.Ids) == 0 {
return ErrMissingIDs
}
if req.Before == nil {
return ErrMissingBefore
@@ -151,7 +151,7 @@ func (l *Locations) Read(ctx context.Context, req *pb.ReadRequest, rsp *pb.ListR
// construct the request
q := l.DB.Model(&model.Location{})
q = q.Order("timestamp ASC")
q = q.Where("user_id IN (?) AND timestamp > ? AND timestamp < ?", req.UserIds, req.After.AsTime(), req.Before.AsTime())
q = q.Where("place_id IN (?) AND timestamp > ? AND timestamp < ?", req.Ids, req.After.AsTime(), req.Before.AsTime())
var locs []*model.Location
if err := q.Find(&locs).Error; err != nil {
logger.Errorf("Error reading from the database: %v", err)
@@ -159,15 +159,15 @@ func (l *Locations) Read(ctx context.Context, req *pb.ReadRequest, rsp *pb.ListR
}
// serialize the result
rsp.Locations = serializeLocations(locs)
rsp.Places = serializePlaces(locs)
return nil
}
func serializeLocations(locs []*model.Location) []*pb.Location {
func serializePlaces(locs []*model.Location) []*pb.Location {
rsp := make([]*pb.Location, len(locs))
for i, l := range locs {
rsp[i] = &pb.Location{
UserId: l.UserID,
Id: l.PlaceID,
Latitude: &wrapperspb.DoubleValue{Value: l.Latitude},
Longitude: &wrapperspb.DoubleValue{Value: l.Longitude},
Timestamp: timestamppb.New(l.Timestamp),

View File

@@ -14,14 +14,14 @@ import (
"gorm.io/driver/postgres"
"gorm.io/gorm"
"github.com/micro/services/locations/handler"
"github.com/micro/services/locations/model"
pb "github.com/micro/services/locations/proto"
"github.com/micro/services/places/handler"
"github.com/micro/services/places/model"
pb "github.com/micro/services/places/proto"
)
func testHandler(t *testing.T) pb.LocationsHandler {
func testHandler(t *testing.T) pb.PlacesHandler {
// connect to the database
db, err := gorm.Open(postgres.Open("postgresql://postgres@localhost:5432/locations?sslmode=disable"), &gorm.Config{})
db, err := gorm.Open(postgres.Open("postgresql://postgres@localhost:5432/places?sslmode=disable"), &gorm.Config{})
if err != nil {
t.Fatalf("Error connecting to database: %v", err)
}
@@ -32,67 +32,67 @@ func testHandler(t *testing.T) pb.LocationsHandler {
}
// clean any data from a previous run
if err := db.Exec("TRUNCATE TABLE locations CASCADE").Error; err != nil {
if err := db.Exec("TRUNCATE TABLE places CASCADE").Error; err != nil {
t.Fatalf("Error cleaning database: %v", err)
}
return &handler.Locations{DB: db, Geoindex: geo.NewPointsIndex(geo.Km(0.1))}
return &handler.Places{DB: db, Geoindex: geo.NewPointsIndex(geo.Km(0.1))}
}
func TestSave(t *testing.T) {
tt := []struct {
Name string
Locations []*pb.Location
Error error
Name string
Places []*pb.Location
Error error
}{
{
Name: "NoLocations",
Error: handler.ErrMissingLocations,
Name: "NoPlaces",
Error: handler.ErrMissingPlaces,
},
{
Name: "NoLatitude",
Locations: []*pb.Location{
Places: []*pb.Location{
{
Longitude: &wrapperspb.DoubleValue{Value: -0.1246},
UserId: uuid.New().String(),
Id: uuid.New().String(),
},
},
Error: handler.ErrMissingLatitude,
},
{
Name: "NoLongitude",
Locations: []*pb.Location{
Places: []*pb.Location{
{
Latitude: &wrapperspb.DoubleValue{Value: -0.1246},
UserId: uuid.New().String(),
Id: uuid.New().String(),
},
},
Error: handler.ErrMissingLongitude,
},
{
Name: "OneLocation",
Locations: []*pb.Location{
Places: []*pb.Location{
{
Latitude: &wrapperspb.DoubleValue{Value: 51.5007},
Longitude: &wrapperspb.DoubleValue{Value: 0.1246},
Timestamp: timestamppb.New(time.Now()),
UserId: uuid.New().String(),
Id: uuid.New().String(),
},
},
},
{
Name: "ManyLocations",
Locations: []*pb.Location{
Name: "ManyPlaces",
Places: []*pb.Location{
{
Latitude: &wrapperspb.DoubleValue{Value: 51.5007},
Longitude: &wrapperspb.DoubleValue{Value: 0.1246},
Timestamp: timestamppb.New(time.Now()),
UserId: uuid.New().String(),
Id: uuid.New().String(),
},
{
Latitude: &wrapperspb.DoubleValue{Value: 51.003},
Longitude: &wrapperspb.DoubleValue{Value: -0.1246},
UserId: uuid.New().String(),
Id: uuid.New().String(),
},
},
},
@@ -103,7 +103,7 @@ func TestSave(t *testing.T) {
for _, tc := range tt {
t.Run(tc.Name, func(t *testing.T) {
err := h.Save(context.Background(), &pb.SaveRequest{
Locations: tc.Locations,
Places: tc.Places,
}, &pb.SaveResponse{})
assert.Equal(t, tc.Error, err)
})
@@ -113,18 +113,18 @@ func TestSave(t *testing.T) {
func TestLast(t *testing.T) {
h := testHandler(t)
t.Run("MissingUserIDs", func(t *testing.T) {
t.Run("MissingIDs", func(t *testing.T) {
err := h.Last(context.Background(), &pb.LastRequest{}, &pb.ListResponse{})
assert.Equal(t, handler.ErrMissingUserIDs, err)
assert.Equal(t, handler.ErrMissingIDs, err)
})
t.Run("NoMatches", func(t *testing.T) {
var rsp pb.ListResponse
err := h.Last(context.Background(), &pb.LastRequest{
UserIds: []string{uuid.New().String()},
Ids: []string{uuid.New().String()},
}, &rsp)
assert.NoError(t, err)
assert.Empty(t, rsp.Locations)
assert.Empty(t, rsp.Places)
})
// generate some example data to work with
@@ -132,65 +132,65 @@ func TestLast(t *testing.T) {
Latitude: &wrapperspb.DoubleValue{Value: 51.5007},
Longitude: &wrapperspb.DoubleValue{Value: 0.1246},
Timestamp: timestamppb.New(time.Now()),
UserId: "a",
Id: "a",
}
loc2 := &pb.Location{
Latitude: &wrapperspb.DoubleValue{Value: 51.6007},
Longitude: &wrapperspb.DoubleValue{Value: 0.1546},
Timestamp: timestamppb.New(time.Now()),
UserId: "b",
Id: "b",
}
loc3 := &pb.Location{
Latitude: &wrapperspb.DoubleValue{Value: 52.6007},
Longitude: &wrapperspb.DoubleValue{Value: 0.2546},
Timestamp: timestamppb.New(time.Now()),
UserId: loc2.UserId,
Id: loc2.Id,
}
err := h.Save(context.TODO(), &pb.SaveRequest{
Locations: []*pb.Location{loc1, loc2, loc3},
Places: []*pb.Location{loc1, loc2, loc3},
}, &pb.SaveResponse{})
assert.NoError(t, err)
t.Run("OneUser", func(t *testing.T) {
var rsp pb.ListResponse
err := h.Last(context.Background(), &pb.LastRequest{
UserIds: []string{loc2.UserId},
Ids: []string{loc2.Id},
}, &rsp)
assert.NoError(t, err)
if len(rsp.Locations) != 1 {
if len(rsp.Places) != 1 {
t.Fatalf("One location should be returned")
}
assert.Equal(t, loc3.UserId, rsp.Locations[0].UserId)
assert.Equal(t, loc3.Latitude.Value, rsp.Locations[0].Latitude.Value)
assert.Equal(t, loc3.Longitude.Value, rsp.Locations[0].Longitude.Value)
assert.Equal(t, loc3.Timestamp.AsTime(), rsp.Locations[0].Timestamp.AsTime())
assert.Equal(t, loc3.Id, rsp.Places[0].Id)
assert.Equal(t, loc3.Latitude.Value, rsp.Places[0].Latitude.Value)
assert.Equal(t, loc3.Longitude.Value, rsp.Places[0].Longitude.Value)
assert.Equal(t, loc3.Timestamp.AsTime(), rsp.Places[0].Timestamp.AsTime())
})
t.Run("ManyUser", func(t *testing.T) {
var rsp pb.ListResponse
err := h.Last(context.Background(), &pb.LastRequest{
UserIds: []string{loc1.UserId, loc2.UserId},
Ids: []string{loc1.Id, loc2.Id},
}, &rsp)
assert.NoError(t, err)
if len(rsp.Locations) != 2 {
t.Fatalf("Two locations should be returned")
if len(rsp.Places) != 2 {
t.Fatalf("Two places should be returned")
}
// sort using user_id so we can hardcode the index
sort.Slice(rsp.Locations, func(i, j int) bool {
return rsp.Locations[i].UserId > rsp.Locations[j].UserId
sort.Slice(rsp.Places, func(i, j int) bool {
return rsp.Places[i].Id > rsp.Places[j].Id
})
assert.Equal(t, loc1.UserId, rsp.Locations[1].UserId)
assert.Equal(t, loc1.Latitude.Value, rsp.Locations[1].Latitude.Value)
assert.Equal(t, loc1.Longitude.Value, rsp.Locations[1].Longitude.Value)
assert.Equal(t, loc1.Timestamp.AsTime(), rsp.Locations[1].Timestamp.AsTime())
assert.Equal(t, loc1.Id, rsp.Places[1].Id)
assert.Equal(t, loc1.Latitude.Value, rsp.Places[1].Latitude.Value)
assert.Equal(t, loc1.Longitude.Value, rsp.Places[1].Longitude.Value)
assert.Equal(t, loc1.Timestamp.AsTime(), rsp.Places[1].Timestamp.AsTime())
assert.Equal(t, loc3.UserId, rsp.Locations[0].UserId)
assert.Equal(t, loc3.Latitude.Value, rsp.Locations[0].Latitude.Value)
assert.Equal(t, loc3.Longitude.Value, rsp.Locations[0].Longitude.Value)
assert.Equal(t, loc3.Timestamp.AsTime(), rsp.Locations[0].Timestamp.AsTime())
assert.Equal(t, loc3.Id, rsp.Places[0].Id)
assert.Equal(t, loc3.Latitude.Value, rsp.Places[0].Latitude.Value)
assert.Equal(t, loc3.Longitude.Value, rsp.Places[0].Longitude.Value)
assert.Equal(t, loc3.Timestamp.AsTime(), rsp.Places[0].Timestamp.AsTime())
})
}
@@ -207,7 +207,7 @@ func TestNear(t *testing.T) {
tt := []struct {
Name string
Locations []*pb.Location
Places []*pb.Location
Results []*pb.Location
QueryLatitude *wrapperspb.DoubleValue
QueryLongitude *wrapperspb.DoubleValue
@@ -233,7 +233,7 @@ func TestNear(t *testing.T) {
Error: handler.ErrMissingRadius,
},
{
Name: "NoLocations",
Name: "NoPlaces",
QueryLatitude: lat,
QueryLongitude: lng,
QueryRadius: rad,
@@ -243,23 +243,23 @@ func TestNear(t *testing.T) {
QueryLatitude: lat,
QueryLongitude: lng,
QueryRadius: rad,
Locations: []*pb.Location{
Places: []*pb.Location{
&pb.Location{
Latitude: inBoundsLat,
Longitude: inBoundsLng,
UserId: "in",
Id: "in",
},
&pb.Location{
Latitude: outOfBoundsLat,
Longitude: outOfBoundsLng,
UserId: "out",
Id: "out",
},
},
Results: []*pb.Location{
&pb.Location{
Latitude: inBoundsLat,
Longitude: inBoundsLng,
UserId: "in",
Id: "in",
},
},
},
@@ -268,51 +268,51 @@ func TestNear(t *testing.T) {
QueryLatitude: lat,
QueryLongitude: lng,
QueryRadius: &wrapperspb.DoubleValue{Value: 0.01},
Locations: []*pb.Location{
Places: []*pb.Location{
&pb.Location{
Latitude: inBoundsLat,
Longitude: inBoundsLng,
UserId: "in",
Id: "in",
},
&pb.Location{
Latitude: outOfBoundsLat,
Longitude: outOfBoundsLng,
UserId: "out",
Id: "out",
},
},
},
{
Name: "TwoLocationsForUser",
Name: "TwoPlacesForUser",
QueryLatitude: lat,
QueryLongitude: lng,
QueryRadius: rad,
Locations: []*pb.Location{
Places: []*pb.Location{
&pb.Location{
Latitude: inBoundsLat,
Longitude: inBoundsLng,
UserId: "in",
Id: "in",
},
&pb.Location{
Latitude: outOfBoundsLat,
Longitude: outOfBoundsLng,
UserId: "out",
Id: "out",
},
&pb.Location{
Latitude: inBoundsLat,
Longitude: inBoundsLng,
UserId: "out",
Id: "out",
},
},
Results: []*pb.Location{
&pb.Location{
Latitude: inBoundsLat,
Longitude: inBoundsLng,
UserId: "in",
Id: "in",
},
&pb.Location{
Latitude: inBoundsLat,
Longitude: inBoundsLng,
UserId: "out",
Id: "out",
},
},
},
@@ -321,28 +321,28 @@ func TestNear(t *testing.T) {
QueryLatitude: lat,
QueryLongitude: lng,
QueryRadius: &wrapperspb.DoubleValue{Value: 20},
Locations: []*pb.Location{
Places: []*pb.Location{
&pb.Location{
Latitude: inBoundsLat,
Longitude: inBoundsLng,
UserId: "in",
Id: "in",
},
&pb.Location{
Latitude: outOfBoundsLat,
Longitude: outOfBoundsLng,
UserId: "out",
Id: "out",
},
},
Results: []*pb.Location{
&pb.Location{
Latitude: inBoundsLat,
Longitude: inBoundsLng,
UserId: "in",
Id: "in",
},
&pb.Location{
Latitude: outOfBoundsLat,
Longitude: outOfBoundsLng,
UserId: "out",
Id: "out",
},
},
},
@@ -352,13 +352,13 @@ func TestNear(t *testing.T) {
t.Run(tc.Name, func(t *testing.T) {
h := testHandler(t)
// create the locations
if len(tc.Locations) > 0 {
err := h.Save(context.TODO(), &pb.SaveRequest{Locations: tc.Locations}, &pb.SaveResponse{})
// create the places
if len(tc.Places) > 0 {
err := h.Save(context.TODO(), &pb.SaveRequest{Places: tc.Places}, &pb.SaveResponse{})
assert.NoError(t, err)
}
// find near locations
// find near places
var rsp pb.ListResponse
err := h.Near(context.TODO(), &pb.NearRequest{
Latitude: tc.QueryLatitude,
@@ -368,20 +368,20 @@ func TestNear(t *testing.T) {
assert.Equal(t, tc.Error, err)
// check the count of the results matches
if len(tc.Results) != len(rsp.Locations) {
t.Errorf("Incorrect number of results returned. Expected %v, got %v", len(tc.Results), len(rsp.Locations))
if len(tc.Results) != len(rsp.Places) {
t.Errorf("Incorrect number of results returned. Expected %v, got %v", len(tc.Results), len(rsp.Places))
}
// validate the results match
sort.Slice(rsp.Locations, func(i, j int) bool {
return rsp.Locations[i].UserId > rsp.Locations[j].UserId
sort.Slice(rsp.Places, func(i, j int) bool {
return rsp.Places[i].Id > rsp.Places[j].Id
})
sort.Slice(tc.Results, func(i, j int) bool {
return tc.Results[i].UserId > tc.Results[j].UserId
return tc.Results[i].Id > tc.Results[j].Id
})
for i, r := range tc.Results {
l := rsp.Locations[i]
assert.Equal(t, r.UserId, l.UserId)
l := rsp.Places[i]
assert.Equal(t, r.Id, l.Id)
assert.Equal(t, r.Latitude.Value, l.Latitude.Value)
assert.Equal(t, r.Longitude.Value, l.Longitude.Value)
}
@@ -394,26 +394,26 @@ func TestRead(t *testing.T) {
baseTime := time.Now().Add(time.Hour * -24)
t.Run("MissingUserIDs", func(t *testing.T) {
t.Run("MissingIDs", func(t *testing.T) {
err := h.Read(context.Background(), &pb.ReadRequest{
After: timestamppb.New(baseTime),
Before: timestamppb.New(baseTime),
}, &pb.ListResponse{})
assert.Equal(t, handler.ErrMissingUserIDs, err)
assert.Equal(t, handler.ErrMissingIDs, err)
})
t.Run("MissingAfter", func(t *testing.T) {
err := h.Read(context.Background(), &pb.ReadRequest{
UserIds: []string{uuid.New().String()},
Before: timestamppb.New(baseTime),
Ids: []string{uuid.New().String()},
Before: timestamppb.New(baseTime),
}, &pb.ListResponse{})
assert.Equal(t, handler.ErrMissingAfter, err)
})
t.Run("MissingBefore", func(t *testing.T) {
err := h.Read(context.Background(), &pb.ReadRequest{
UserIds: []string{uuid.New().String()},
After: timestamppb.New(baseTime),
Ids: []string{uuid.New().String()},
After: timestamppb.New(baseTime),
}, &pb.ListResponse{})
assert.Equal(t, handler.ErrMissingBefore, err)
})
@@ -423,97 +423,97 @@ func TestRead(t *testing.T) {
Latitude: &wrapperspb.DoubleValue{Value: 51.5007},
Longitude: &wrapperspb.DoubleValue{Value: 0.1246},
Timestamp: timestamppb.New(baseTime.Add(time.Minute * 10)),
UserId: "a",
Id: "a",
}
loc2 := &pb.Location{
Latitude: &wrapperspb.DoubleValue{Value: 51.6007},
Longitude: &wrapperspb.DoubleValue{Value: 0.1546},
Timestamp: timestamppb.New(baseTime.Add(time.Minute * 20)),
UserId: "b",
Id: "b",
}
loc3 := &pb.Location{
Latitude: &wrapperspb.DoubleValue{Value: 52.6007},
Longitude: &wrapperspb.DoubleValue{Value: 0.2546},
Timestamp: timestamppb.New(baseTime.Add(time.Minute * 40)),
UserId: loc2.UserId,
Id: loc2.Id,
}
err := h.Save(context.TODO(), &pb.SaveRequest{
Locations: []*pb.Location{loc1, loc2, loc3},
Places: []*pb.Location{loc1, loc2, loc3},
}, &pb.SaveResponse{})
assert.NoError(t, err)
t.Run("NoMatches", func(t *testing.T) {
var rsp pb.ListResponse
err := h.Read(context.Background(), &pb.ReadRequest{
UserIds: []string{uuid.New().String()},
After: timestamppb.New(baseTime),
Before: timestamppb.New(baseTime.Add(time.Hour)),
Ids: []string{uuid.New().String()},
After: timestamppb.New(baseTime),
Before: timestamppb.New(baseTime.Add(time.Hour)),
}, &rsp)
assert.NoError(t, err)
assert.Empty(t, rsp.Locations)
assert.Empty(t, rsp.Places)
})
t.Run("OneUserID", func(t *testing.T) {
t.Run("OnePlaceID", func(t *testing.T) {
var rsp pb.ListResponse
err := h.Read(context.Background(), &pb.ReadRequest{
UserIds: []string{loc2.UserId},
After: timestamppb.New(baseTime),
Before: timestamppb.New(baseTime.Add(time.Hour)),
Ids: []string{loc2.Id},
After: timestamppb.New(baseTime),
Before: timestamppb.New(baseTime.Add(time.Hour)),
}, &rsp)
assert.NoError(t, err)
if len(rsp.Locations) != 2 {
t.Fatalf("Two locations should be returned")
if len(rsp.Places) != 2 {
t.Fatalf("Two places should be returned")
}
assert.Equal(t, loc2.UserId, rsp.Locations[0].UserId)
assert.Equal(t, loc2.Latitude.Value, rsp.Locations[0].Latitude.Value)
assert.Equal(t, loc2.Longitude.Value, rsp.Locations[0].Longitude.Value)
assert.Equal(t, loc2.Timestamp.AsTime(), rsp.Locations[0].Timestamp.AsTime())
assert.Equal(t, loc2.Id, rsp.Places[0].Id)
assert.Equal(t, loc2.Latitude.Value, rsp.Places[0].Latitude.Value)
assert.Equal(t, loc2.Longitude.Value, rsp.Places[0].Longitude.Value)
assert.Equal(t, loc2.Timestamp.AsTime(), rsp.Places[0].Timestamp.AsTime())
assert.Equal(t, loc3.UserId, rsp.Locations[1].UserId)
assert.Equal(t, loc3.Latitude.Value, rsp.Locations[1].Latitude.Value)
assert.Equal(t, loc3.Longitude.Value, rsp.Locations[1].Longitude.Value)
assert.Equal(t, loc3.Timestamp.AsTime(), rsp.Locations[1].Timestamp.AsTime())
assert.Equal(t, loc3.Id, rsp.Places[1].Id)
assert.Equal(t, loc3.Latitude.Value, rsp.Places[1].Latitude.Value)
assert.Equal(t, loc3.Longitude.Value, rsp.Places[1].Longitude.Value)
assert.Equal(t, loc3.Timestamp.AsTime(), rsp.Places[1].Timestamp.AsTime())
})
t.Run("OneUserIDReducedTime", func(t *testing.T) {
t.Run("OnePlaceIDReducedTime", func(t *testing.T) {
var rsp pb.ListResponse
err := h.Read(context.Background(), &pb.ReadRequest{
UserIds: []string{loc2.UserId},
After: timestamppb.New(baseTime),
Before: timestamppb.New(baseTime.Add(time.Minute * 30)),
Ids: []string{loc2.Id},
After: timestamppb.New(baseTime),
Before: timestamppb.New(baseTime.Add(time.Minute * 30)),
}, &rsp)
assert.NoError(t, err)
if len(rsp.Locations) != 1 {
if len(rsp.Places) != 1 {
t.Fatalf("One location should be returned")
}
assert.Equal(t, loc2.UserId, rsp.Locations[0].UserId)
assert.Equal(t, loc2.Latitude.Value, rsp.Locations[0].Latitude.Value)
assert.Equal(t, loc2.Longitude.Value, rsp.Locations[0].Longitude.Value)
assert.Equal(t, loc2.Timestamp.AsTime(), rsp.Locations[0].Timestamp.AsTime())
assert.Equal(t, loc2.Id, rsp.Places[0].Id)
assert.Equal(t, loc2.Latitude.Value, rsp.Places[0].Latitude.Value)
assert.Equal(t, loc2.Longitude.Value, rsp.Places[0].Longitude.Value)
assert.Equal(t, loc2.Timestamp.AsTime(), rsp.Places[0].Timestamp.AsTime())
})
t.Run("TwoUserIDs", func(t *testing.T) {
t.Run("TwoPlaceIDs", func(t *testing.T) {
var rsp pb.ListResponse
err := h.Read(context.Background(), &pb.ReadRequest{
UserIds: []string{loc1.UserId, loc2.UserId},
After: timestamppb.New(baseTime),
Before: timestamppb.New(baseTime.Add(time.Minute * 30)),
Ids: []string{loc1.Id, loc2.Id},
After: timestamppb.New(baseTime),
Before: timestamppb.New(baseTime.Add(time.Minute * 30)),
}, &rsp)
assert.NoError(t, err)
if len(rsp.Locations) != 2 {
t.Fatalf("Two locations should be returned")
if len(rsp.Places) != 2 {
t.Fatalf("Two places should be returned")
}
assert.Equal(t, loc1.UserId, rsp.Locations[0].UserId)
assert.Equal(t, loc1.Latitude.Value, rsp.Locations[0].Latitude.Value)
assert.Equal(t, loc1.Longitude.Value, rsp.Locations[0].Longitude.Value)
assert.Equal(t, loc1.Timestamp.AsTime(), rsp.Locations[0].Timestamp.AsTime())
assert.Equal(t, loc1.Id, rsp.Places[0].Id)
assert.Equal(t, loc1.Latitude.Value, rsp.Places[0].Latitude.Value)
assert.Equal(t, loc1.Longitude.Value, rsp.Places[0].Longitude.Value)
assert.Equal(t, loc1.Timestamp.AsTime(), rsp.Places[0].Timestamp.AsTime())
assert.Equal(t, loc2.UserId, rsp.Locations[1].UserId)
assert.Equal(t, loc2.Latitude.Value, rsp.Locations[1].Latitude.Value)
assert.Equal(t, loc2.Longitude.Value, rsp.Locations[1].Longitude.Value)
assert.Equal(t, loc2.Timestamp.AsTime(), rsp.Locations[1].Timestamp.AsTime())
assert.Equal(t, loc2.Id, rsp.Places[1].Id)
assert.Equal(t, loc2.Latitude.Value, rsp.Places[1].Latitude.Value)
assert.Equal(t, loc2.Longitude.Value, rsp.Places[1].Longitude.Value)
assert.Equal(t, loc2.Timestamp.AsTime(), rsp.Places[1].Timestamp.AsTime())
})
}

View File

@@ -5,26 +5,26 @@ import (
"gorm.io/driver/postgres"
"gorm.io/gorm"
"github.com/micro/services/locations/handler"
"github.com/micro/services/locations/model"
pb "github.com/micro/services/locations/proto"
"github.com/micro/services/places/handler"
"github.com/micro/services/places/model"
pb "github.com/micro/services/places/proto"
"github.com/micro/micro/v3/service"
"github.com/micro/micro/v3/service/config"
"github.com/micro/micro/v3/service/logger"
)
var dbAddress = "postgresql://postgres@localhost:5432/locations?sslmode=disable"
var dbAddress = "postgresql://postgres@localhost:5432/places?sslmode=disable"
func main() {
// Create service
srv := service.New(
service.Name("locations"),
service.Name("places"),
service.Version("latest"),
)
// Connect to the database
cfg, err := config.Get("locations.database")
cfg, err := config.Get("places.database")
if err != nil {
logger.Fatalf("Error loading config: %v", err)
}
@@ -40,7 +40,7 @@ func main() {
}
// Register handler
pb.RegisterLocationsHandler(srv.Server(), &handler.Locations{
pb.RegisterPlacesHandler(srv.Server(), &handler.Places{
DB: db, Geoindex: geo.NewPointsIndex(geo.Km(0.1)),
})

1
places/micro.mu Normal file
View File

@@ -0,0 +1 @@
service places

View File

@@ -6,15 +6,15 @@ import (
type Location struct {
ID string
UserID string `gorm:"index"`
PlaceID string `gorm:"index"`
Latitude float64
Longitude float64
Timestamp time.Time
}
// use the user id for the geoindex so only one result is returned per user
// use the place id for the geoindex so only one result is returned per place
func (l *Location) Id() string {
return l.UserID
return l.PlaceID
}
func (l *Location) Lat() float64 {

407
places/proto/places.pb.go Normal file
View File

@@ -0,0 +1,407 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: proto/places.proto
package places
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
timestamp "github.com/golang/protobuf/ptypes/timestamp"
wrappers "github.com/golang/protobuf/ptypes/wrappers"
math "math"
)
// 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
type Location struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
Metadata map[string]string `protobuf:"bytes,3,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
Timestamp *timestamp.Timestamp `protobuf:"bytes,4,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
Latitude *wrappers.DoubleValue `protobuf:"bytes,5,opt,name=latitude,proto3" json:"latitude,omitempty"`
Longitude *wrappers.DoubleValue `protobuf:"bytes,6,opt,name=longitude,proto3" json:"longitude,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Location) Reset() { *m = Location{} }
func (m *Location) String() string { return proto.CompactTextString(m) }
func (*Location) ProtoMessage() {}
func (*Location) Descriptor() ([]byte, []int) {
return fileDescriptor_3b635ff9d2e2d652, []int{0}
}
func (m *Location) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Location.Unmarshal(m, b)
}
func (m *Location) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Location.Marshal(b, m, deterministic)
}
func (m *Location) XXX_Merge(src proto.Message) {
xxx_messageInfo_Location.Merge(m, src)
}
func (m *Location) XXX_Size() int {
return xxx_messageInfo_Location.Size(m)
}
func (m *Location) XXX_DiscardUnknown() {
xxx_messageInfo_Location.DiscardUnknown(m)
}
var xxx_messageInfo_Location proto.InternalMessageInfo
func (m *Location) GetId() string {
if m != nil {
return m.Id
}
return ""
}
func (m *Location) GetName() string {
if m != nil {
return m.Name
}
return ""
}
func (m *Location) GetMetadata() map[string]string {
if m != nil {
return m.Metadata
}
return nil
}
func (m *Location) GetTimestamp() *timestamp.Timestamp {
if m != nil {
return m.Timestamp
}
return nil
}
func (m *Location) GetLatitude() *wrappers.DoubleValue {
if m != nil {
return m.Latitude
}
return nil
}
func (m *Location) GetLongitude() *wrappers.DoubleValue {
if m != nil {
return m.Longitude
}
return nil
}
type SaveRequest struct {
Places []*Location `protobuf:"bytes,1,rep,name=places,proto3" json:"places,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *SaveRequest) Reset() { *m = SaveRequest{} }
func (m *SaveRequest) String() string { return proto.CompactTextString(m) }
func (*SaveRequest) ProtoMessage() {}
func (*SaveRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_3b635ff9d2e2d652, []int{1}
}
func (m *SaveRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SaveRequest.Unmarshal(m, b)
}
func (m *SaveRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_SaveRequest.Marshal(b, m, deterministic)
}
func (m *SaveRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_SaveRequest.Merge(m, src)
}
func (m *SaveRequest) XXX_Size() int {
return xxx_messageInfo_SaveRequest.Size(m)
}
func (m *SaveRequest) XXX_DiscardUnknown() {
xxx_messageInfo_SaveRequest.DiscardUnknown(m)
}
var xxx_messageInfo_SaveRequest proto.InternalMessageInfo
func (m *SaveRequest) GetPlaces() []*Location {
if m != nil {
return m.Places
}
return nil
}
type SaveResponse struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *SaveResponse) Reset() { *m = SaveResponse{} }
func (m *SaveResponse) String() string { return proto.CompactTextString(m) }
func (*SaveResponse) ProtoMessage() {}
func (*SaveResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_3b635ff9d2e2d652, []int{2}
}
func (m *SaveResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SaveResponse.Unmarshal(m, b)
}
func (m *SaveResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_SaveResponse.Marshal(b, m, deterministic)
}
func (m *SaveResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_SaveResponse.Merge(m, src)
}
func (m *SaveResponse) XXX_Size() int {
return xxx_messageInfo_SaveResponse.Size(m)
}
func (m *SaveResponse) XXX_DiscardUnknown() {
xxx_messageInfo_SaveResponse.DiscardUnknown(m)
}
var xxx_messageInfo_SaveResponse proto.InternalMessageInfo
type LastRequest struct {
Ids []string `protobuf:"bytes,1,rep,name=ids,proto3" json:"ids,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *LastRequest) Reset() { *m = LastRequest{} }
func (m *LastRequest) String() string { return proto.CompactTextString(m) }
func (*LastRequest) ProtoMessage() {}
func (*LastRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_3b635ff9d2e2d652, []int{3}
}
func (m *LastRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_LastRequest.Unmarshal(m, b)
}
func (m *LastRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_LastRequest.Marshal(b, m, deterministic)
}
func (m *LastRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_LastRequest.Merge(m, src)
}
func (m *LastRequest) XXX_Size() int {
return xxx_messageInfo_LastRequest.Size(m)
}
func (m *LastRequest) XXX_DiscardUnknown() {
xxx_messageInfo_LastRequest.DiscardUnknown(m)
}
var xxx_messageInfo_LastRequest proto.InternalMessageInfo
func (m *LastRequest) GetIds() []string {
if m != nil {
return m.Ids
}
return nil
}
type ListResponse struct {
Places []*Location `protobuf:"bytes,1,rep,name=places,proto3" json:"places,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ListResponse) Reset() { *m = ListResponse{} }
func (m *ListResponse) String() string { return proto.CompactTextString(m) }
func (*ListResponse) ProtoMessage() {}
func (*ListResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_3b635ff9d2e2d652, []int{4}
}
func (m *ListResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ListResponse.Unmarshal(m, b)
}
func (m *ListResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ListResponse.Marshal(b, m, deterministic)
}
func (m *ListResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_ListResponse.Merge(m, src)
}
func (m *ListResponse) XXX_Size() int {
return xxx_messageInfo_ListResponse.Size(m)
}
func (m *ListResponse) XXX_DiscardUnknown() {
xxx_messageInfo_ListResponse.DiscardUnknown(m)
}
var xxx_messageInfo_ListResponse proto.InternalMessageInfo
func (m *ListResponse) GetPlaces() []*Location {
if m != nil {
return m.Places
}
return nil
}
type NearRequest struct {
Latitude *wrappers.DoubleValue `protobuf:"bytes,1,opt,name=latitude,proto3" json:"latitude,omitempty"`
Longitude *wrappers.DoubleValue `protobuf:"bytes,2,opt,name=longitude,proto3" json:"longitude,omitempty"`
// radius to search within, units km
Radius *wrappers.DoubleValue `protobuf:"bytes,3,opt,name=radius,proto3" json:"radius,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *NearRequest) Reset() { *m = NearRequest{} }
func (m *NearRequest) String() string { return proto.CompactTextString(m) }
func (*NearRequest) ProtoMessage() {}
func (*NearRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_3b635ff9d2e2d652, []int{5}
}
func (m *NearRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_NearRequest.Unmarshal(m, b)
}
func (m *NearRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_NearRequest.Marshal(b, m, deterministic)
}
func (m *NearRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_NearRequest.Merge(m, src)
}
func (m *NearRequest) XXX_Size() int {
return xxx_messageInfo_NearRequest.Size(m)
}
func (m *NearRequest) XXX_DiscardUnknown() {
xxx_messageInfo_NearRequest.DiscardUnknown(m)
}
var xxx_messageInfo_NearRequest proto.InternalMessageInfo
func (m *NearRequest) GetLatitude() *wrappers.DoubleValue {
if m != nil {
return m.Latitude
}
return nil
}
func (m *NearRequest) GetLongitude() *wrappers.DoubleValue {
if m != nil {
return m.Longitude
}
return nil
}
func (m *NearRequest) GetRadius() *wrappers.DoubleValue {
if m != nil {
return m.Radius
}
return nil
}
type ReadRequest struct {
Ids []string `protobuf:"bytes,1,rep,name=ids,proto3" json:"ids,omitempty"`
After *timestamp.Timestamp `protobuf:"bytes,2,opt,name=after,proto3" json:"after,omitempty"`
Before *timestamp.Timestamp `protobuf:"bytes,3,opt,name=before,proto3" json:"before,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ReadRequest) Reset() { *m = ReadRequest{} }
func (m *ReadRequest) String() string { return proto.CompactTextString(m) }
func (*ReadRequest) ProtoMessage() {}
func (*ReadRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_3b635ff9d2e2d652, []int{6}
}
func (m *ReadRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ReadRequest.Unmarshal(m, b)
}
func (m *ReadRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ReadRequest.Marshal(b, m, deterministic)
}
func (m *ReadRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_ReadRequest.Merge(m, src)
}
func (m *ReadRequest) XXX_Size() int {
return xxx_messageInfo_ReadRequest.Size(m)
}
func (m *ReadRequest) XXX_DiscardUnknown() {
xxx_messageInfo_ReadRequest.DiscardUnknown(m)
}
var xxx_messageInfo_ReadRequest proto.InternalMessageInfo
func (m *ReadRequest) GetIds() []string {
if m != nil {
return m.Ids
}
return nil
}
func (m *ReadRequest) GetAfter() *timestamp.Timestamp {
if m != nil {
return m.After
}
return nil
}
func (m *ReadRequest) GetBefore() *timestamp.Timestamp {
if m != nil {
return m.Before
}
return nil
}
func init() {
proto.RegisterType((*Location)(nil), "places.Location")
proto.RegisterMapType((map[string]string)(nil), "places.Location.MetadataEntry")
proto.RegisterType((*SaveRequest)(nil), "places.SaveRequest")
proto.RegisterType((*SaveResponse)(nil), "places.SaveResponse")
proto.RegisterType((*LastRequest)(nil), "places.LastRequest")
proto.RegisterType((*ListResponse)(nil), "places.ListResponse")
proto.RegisterType((*NearRequest)(nil), "places.NearRequest")
proto.RegisterType((*ReadRequest)(nil), "places.ReadRequest")
}
func init() { proto.RegisterFile("proto/places.proto", fileDescriptor_3b635ff9d2e2d652) }
var fileDescriptor_3b635ff9d2e2d652 = []byte{
// 460 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0xcd, 0x6e, 0xd3, 0x40,
0x14, 0x85, 0x19, 0x3b, 0xb1, 0x92, 0xeb, 0x52, 0x45, 0x97, 0x2e, 0x2c, 0x0b, 0xb5, 0x91, 0x57,
0x59, 0x39, 0x28, 0x45, 0x22, 0x0a, 0x5b, 0xd8, 0x05, 0x84, 0x0c, 0x62, 0x3f, 0xa9, 0x6f, 0x22,
0x0b, 0xc7, 0x63, 0xec, 0x71, 0x51, 0x1f, 0x80, 0x87, 0xe2, 0x49, 0xd8, 0xf0, 0x30, 0x68, 0x7e,
0x1c, 0xbb, 0x45, 0x8d, 0x1a, 0x76, 0x33, 0xe3, 0xf3, 0x5d, 0x9f, 0x39, 0x67, 0x00, 0xcb, 0x4a,
0x48, 0x31, 0x2f, 0x73, 0x7e, 0x43, 0x75, 0xac, 0x37, 0xe8, 0x99, 0x5d, 0x78, 0xb5, 0x13, 0x62,
0x97, 0xd3, 0x5c, 0x9f, 0x6e, 0x9a, 0xed, 0x5c, 0x66, 0x7b, 0xaa, 0x25, 0xdf, 0x97, 0x46, 0x18,
0x5e, 0x3e, 0x14, 0xfc, 0xa8, 0x78, 0x59, 0x52, 0x65, 0x07, 0x45, 0xbf, 0x1d, 0x18, 0xad, 0xc5,
0x0d, 0x97, 0x99, 0x28, 0xf0, 0x1c, 0x9c, 0x2c, 0x0d, 0xd8, 0x94, 0xcd, 0xc6, 0x89, 0x93, 0xa5,
0x88, 0x30, 0x28, 0xf8, 0x9e, 0x02, 0x47, 0x9f, 0xe8, 0x35, 0xae, 0x60, 0xb4, 0x27, 0xc9, 0x53,
0x2e, 0x79, 0xe0, 0x4e, 0xdd, 0x99, 0xbf, 0xb8, 0x8c, 0xad, 0xb5, 0x76, 0x4e, 0xfc, 0xc1, 0x0a,
0xde, 0x17, 0xb2, 0xba, 0x4b, 0x0e, 0x7a, 0x5c, 0xc2, 0xf8, 0xe0, 0x2f, 0x18, 0x4c, 0xd9, 0xcc,
0x5f, 0x84, 0xb1, 0x31, 0x18, 0xb7, 0x06, 0xe3, 0x2f, 0xad, 0x22, 0xe9, 0xc4, 0xb8, 0x84, 0x51,
0xce, 0x65, 0x26, 0x9b, 0x94, 0x82, 0xa1, 0x06, 0x5f, 0xfe, 0x03, 0xbe, 0x13, 0xcd, 0x26, 0xa7,
0xaf, 0x3c, 0x6f, 0x28, 0x39, 0xa8, 0x71, 0x05, 0xe3, 0x5c, 0x14, 0x3b, 0x83, 0x7a, 0x4f, 0x40,
0x3b, 0x79, 0xf8, 0x16, 0x9e, 0xdf, 0xbb, 0x0a, 0x4e, 0xc0, 0xfd, 0x46, 0x77, 0x36, 0x21, 0xb5,
0xc4, 0x0b, 0x18, 0xde, 0x2a, 0xcc, 0x66, 0x64, 0x36, 0x2b, 0x67, 0xc9, 0xa2, 0x37, 0xe0, 0x7f,
0xe6, 0xb7, 0x94, 0xd0, 0xf7, 0x86, 0x6a, 0x89, 0x33, 0xb0, 0x9d, 0x05, 0x4c, 0xa7, 0x36, 0x79,
0x98, 0x5a, 0x62, 0xbf, 0x47, 0xe7, 0x70, 0x66, 0xc0, 0xba, 0x14, 0x45, 0x4d, 0xd1, 0x15, 0xf8,
0x6b, 0x5e, 0xcb, 0x76, 0xd0, 0x04, 0xdc, 0x2c, 0x35, 0x53, 0xc6, 0x89, 0x5a, 0x46, 0x4b, 0x38,
0x5b, 0x67, 0x4a, 0x60, 0x80, 0x13, 0x7e, 0xf5, 0x8b, 0x81, 0xff, 0x91, 0x78, 0xd5, 0xce, 0xee,
0xc7, 0xcc, 0xfe, 0x3f, 0x66, 0xe7, 0xa4, 0x98, 0xf1, 0x35, 0x78, 0x15, 0x4f, 0xb3, 0xa6, 0x0e,
0xdc, 0x27, 0x80, 0x56, 0x1b, 0xfd, 0x64, 0xe0, 0x27, 0xc4, 0xd3, 0x47, 0x73, 0xc1, 0x57, 0x30,
0xe4, 0x5b, 0x49, 0x95, 0xf5, 0x73, 0xec, 0xa9, 0x19, 0x21, 0x2e, 0xc0, 0xdb, 0xd0, 0x56, 0x54,
0x64, 0x9d, 0x1c, 0x43, 0xac, 0x72, 0xf1, 0x87, 0x81, 0xf7, 0x49, 0xc7, 0x89, 0xd7, 0x30, 0x50,
0xcd, 0xe1, 0x8b, 0x36, 0xf0, 0xde, 0x03, 0x08, 0x2f, 0xee, 0x1f, 0xda, 0x72, 0x9f, 0x29, 0x48,
0xd5, 0xdb, 0x41, 0xbd, 0xb2, 0x3b, 0xa8, 0x5f, 0xb0, 0x81, 0x54, 0x6f, 0x1d, 0xd4, 0x6b, 0xf1,
0x18, 0xa4, 0x02, 0xeb, 0xa0, 0x5e, 0x7c, 0x8f, 0x41, 0x1b, 0x4f, 0x5f, 0xfd, 0xfa, 0x6f, 0x00,
0x00, 0x00, 0xff, 0xff, 0x7a, 0x9f, 0xaf, 0x48, 0x86, 0x04, 0x00, 0x00,
}

View File

@@ -1,7 +1,7 @@
// Code generated by protoc-gen-micro. DO NOT EDIT.
// source: proto/locations.proto
// source: proto/places.proto
package locations
package places
import (
fmt "fmt"
@@ -35,39 +35,39 @@ var _ context.Context
var _ client.Option
var _ server.Option
// Api Endpoints for Locations service
// Api Endpoints for Places service
func NewLocationsEndpoints() []*api.Endpoint {
func NewPlacesEndpoints() []*api.Endpoint {
return []*api.Endpoint{}
}
// Client API for Locations service
// Client API for Places service
type LocationsService interface {
// Save a set of locations
type PlacesService interface {
// Save a set of places
Save(ctx context.Context, in *SaveRequest, opts ...client.CallOption) (*SaveResponse, error)
// Last locations for a set of users
// Last places for a set of users
Last(ctx context.Context, in *LastRequest, opts ...client.CallOption) (*ListResponse, error)
// Near returns the locations near a point at a given time
// Near returns the places near a point at a given time
Near(ctx context.Context, in *NearRequest, opts ...client.CallOption) (*ListResponse, error)
// Read locations for a group of users between two points in time
// Read places for a group of users between two points in time
Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ListResponse, error)
}
type locationsService struct {
type placesService struct {
c client.Client
name string
}
func NewLocationsService(name string, c client.Client) LocationsService {
return &locationsService{
func NewPlacesService(name string, c client.Client) PlacesService {
return &placesService{
c: c,
name: name,
}
}
func (c *locationsService) Save(ctx context.Context, in *SaveRequest, opts ...client.CallOption) (*SaveResponse, error) {
req := c.c.NewRequest(c.name, "Locations.Save", in)
func (c *placesService) Save(ctx context.Context, in *SaveRequest, opts ...client.CallOption) (*SaveResponse, error) {
req := c.c.NewRequest(c.name, "Places.Save", in)
out := new(SaveResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
@@ -76,8 +76,8 @@ func (c *locationsService) Save(ctx context.Context, in *SaveRequest, opts ...cl
return out, nil
}
func (c *locationsService) Last(ctx context.Context, in *LastRequest, opts ...client.CallOption) (*ListResponse, error) {
req := c.c.NewRequest(c.name, "Locations.Last", in)
func (c *placesService) Last(ctx context.Context, in *LastRequest, opts ...client.CallOption) (*ListResponse, error) {
req := c.c.NewRequest(c.name, "Places.Last", in)
out := new(ListResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
@@ -86,8 +86,8 @@ func (c *locationsService) Last(ctx context.Context, in *LastRequest, opts ...cl
return out, nil
}
func (c *locationsService) Near(ctx context.Context, in *NearRequest, opts ...client.CallOption) (*ListResponse, error) {
req := c.c.NewRequest(c.name, "Locations.Near", in)
func (c *placesService) Near(ctx context.Context, in *NearRequest, opts ...client.CallOption) (*ListResponse, error) {
req := c.c.NewRequest(c.name, "Places.Near", in)
out := new(ListResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
@@ -96,8 +96,8 @@ func (c *locationsService) Near(ctx context.Context, in *NearRequest, opts ...cl
return out, nil
}
func (c *locationsService) Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ListResponse, error) {
req := c.c.NewRequest(c.name, "Locations.Read", in)
func (c *placesService) Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ListResponse, error) {
req := c.c.NewRequest(c.name, "Places.Read", in)
out := new(ListResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
@@ -106,49 +106,49 @@ func (c *locationsService) Read(ctx context.Context, in *ReadRequest, opts ...cl
return out, nil
}
// Server API for Locations service
// Server API for Places service
type LocationsHandler interface {
// Save a set of locations
type PlacesHandler interface {
// Save a set of places
Save(context.Context, *SaveRequest, *SaveResponse) error
// Last locations for a set of users
// Last places for a set of users
Last(context.Context, *LastRequest, *ListResponse) error
// Near returns the locations near a point at a given time
// Near returns the places near a point at a given time
Near(context.Context, *NearRequest, *ListResponse) error
// Read locations for a group of users between two points in time
// Read places for a group of users between two points in time
Read(context.Context, *ReadRequest, *ListResponse) error
}
func RegisterLocationsHandler(s server.Server, hdlr LocationsHandler, opts ...server.HandlerOption) error {
type locations interface {
func RegisterPlacesHandler(s server.Server, hdlr PlacesHandler, opts ...server.HandlerOption) error {
type places interface {
Save(ctx context.Context, in *SaveRequest, out *SaveResponse) error
Last(ctx context.Context, in *LastRequest, out *ListResponse) error
Near(ctx context.Context, in *NearRequest, out *ListResponse) error
Read(ctx context.Context, in *ReadRequest, out *ListResponse) error
}
type Locations struct {
locations
type Places struct {
places
}
h := &locationsHandler{hdlr}
return s.Handle(s.NewHandler(&Locations{h}, opts...))
h := &placesHandler{hdlr}
return s.Handle(s.NewHandler(&Places{h}, opts...))
}
type locationsHandler struct {
LocationsHandler
type placesHandler struct {
PlacesHandler
}
func (h *locationsHandler) Save(ctx context.Context, in *SaveRequest, out *SaveResponse) error {
return h.LocationsHandler.Save(ctx, in, out)
func (h *placesHandler) Save(ctx context.Context, in *SaveRequest, out *SaveResponse) error {
return h.PlacesHandler.Save(ctx, in, out)
}
func (h *locationsHandler) Last(ctx context.Context, in *LastRequest, out *ListResponse) error {
return h.LocationsHandler.Last(ctx, in, out)
func (h *placesHandler) Last(ctx context.Context, in *LastRequest, out *ListResponse) error {
return h.PlacesHandler.Last(ctx, in, out)
}
func (h *locationsHandler) Near(ctx context.Context, in *NearRequest, out *ListResponse) error {
return h.LocationsHandler.Near(ctx, in, out)
func (h *placesHandler) Near(ctx context.Context, in *NearRequest, out *ListResponse) error {
return h.PlacesHandler.Near(ctx, in, out)
}
func (h *locationsHandler) Read(ctx context.Context, in *ReadRequest, out *ListResponse) error {
return h.LocationsHandler.Read(ctx, in, out)
func (h *placesHandler) Read(ctx context.Context, in *ReadRequest, out *ListResponse) error {
return h.PlacesHandler.Read(ctx, in, out)
}

View File

@@ -1,41 +1,42 @@
syntax = "proto3";
package locations;
option go_package = "github.com/micro/services/locations/proto;locations";
package places;
import "google/protobuf/timestamp.proto";
import "google/protobuf/wrappers.proto";
service Locations {
// Save a set of locations
service Places {
// Save a set of places
rpc Save(SaveRequest) returns (SaveResponse) {}
// Last locations for a set of users
// Last places for a set of users
rpc Last(LastRequest) returns (ListResponse) {}
// Near returns the locations near a point at a given time
// Near returns the places near a point at a given time
rpc Near(NearRequest) returns (ListResponse) {}
// Read locations for a group of users between two points in time
// Read places for a group of users between two points in time
rpc Read(ReadRequest) returns (ListResponse) {}
}
message Location {
string user_id = 1;
google.protobuf.Timestamp timestamp = 2;
google.protobuf.DoubleValue latitude = 3;
google.protobuf.DoubleValue longitude = 4;
string id = 1;
string name = 2;
map<string,string> metadata = 3;
google.protobuf.Timestamp timestamp = 4;
google.protobuf.DoubleValue latitude = 5;
google.protobuf.DoubleValue longitude = 6;
}
message SaveRequest {
repeated Location locations = 1;
repeated Location places = 1;
}
message SaveResponse {}
message LastRequest {
repeated string user_ids = 1;
repeated string ids = 1;
}
message ListResponse {
repeated Location locations = 1;
repeated Location places = 1;
}
message NearRequest {
@@ -46,7 +47,7 @@ message NearRequest {
}
message ReadRequest {
repeated string user_ids = 1;
repeated string ids = 1;
google.protobuf.Timestamp after = 2;
google.protobuf.Timestamp before = 3;
}
}