iter
This commit is contained in:
@@ -27,7 +27,7 @@ func NewMapsOf(ctx context.Context, town string) (*Maps, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var rps = 2
|
var rps = 2
|
||||||
var limit = 200
|
var mapsLimit = 200
|
||||||
var mapsLimiter = rate.NewLimiter(rate.Limit(rps), 1)
|
var mapsLimiter = rate.NewLimiter(rate.Limit(rps), 1)
|
||||||
|
|
||||||
type Location struct {
|
type Location struct {
|
||||||
@@ -60,7 +60,7 @@ func (m *Maps) Search(ctx context.Context, query string) ([]Location, error) {
|
|||||||
|
|
||||||
locations := []Location{}
|
locations := []Location{}
|
||||||
nextToken := ""
|
nextToken := ""
|
||||||
for {
|
for len(locations) < mapsLimit {
|
||||||
results, err := m._textSearch(ctx, query, nextToken)
|
results, err := m._textSearch(ctx, query, nextToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
Reference in New Issue
Block a user