Skip to content

Commit

Permalink
update to use whosonfirst/go-whosonfirst-iterate 1.2.0; replace ?inde…
Browse files Browse the repository at this point in the history
…xer= parameter with ?iterator=
  • Loading branch information
thisisaaronland committed Jun 29, 2021
1 parent 71bfa6f commit 222ad85
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 18 deletions.
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ require (
github.com/whosonfirst/go-cache v0.5.0
github.com/whosonfirst/go-cache-blob v0.2.0
github.com/whosonfirst/go-ioutil v1.0.0
github.com/whosonfirst/go-reader v0.5.0 // indirect
github.com/whosonfirst/go-whosonfirst-iterate v1.1.2
github.com/whosonfirst/go-whosonfirst-iterate v1.2.0
github.com/whosonfirst/go-whosonfirst-uri v1.0.1
gocloud.dev v0.23.0
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,8 @@ github.com/whosonfirst/go-whosonfirst-index-git v0.0.4 h1:7+Y1FXiuVZZADntBEisdiF
github.com/whosonfirst/go-whosonfirst-index-git v0.0.4/go.mod h1:EFYsyfBP+b55asqaLRGbeGLGufs9ZXj4hhq9QpZXiLw=
github.com/whosonfirst/go-whosonfirst-iterate v1.1.2 h1:+XOeYOpCixtB2Zddicjbr9DSuOBDSaA2JdZY7V3QDao=
github.com/whosonfirst/go-whosonfirst-iterate v1.1.2/go.mod h1:MOA6QCBONVG98p8kA8HaoBEAmv83jW4SNTfNhHpP9+o=
github.com/whosonfirst/go-whosonfirst-iterate v1.2.0 h1:+wouZy6JPIrmLBZdFDqI1UJWthbpwGc1JRdnLbW6hIc=
github.com/whosonfirst/go-whosonfirst-iterate v1.2.0/go.mod h1:MOA6QCBONVG98p8kA8HaoBEAmv83jW4SNTfNhHpP9+o=
github.com/whosonfirst/go-whosonfirst-log v0.1.0 h1:mWYI5hn16uyeLxBmPsLSvYV4rQKK/cxGVhM+bC2ZoGc=
github.com/whosonfirst/go-whosonfirst-log v0.1.0/go.mod h1:pmgBbxZSnjGVy2nsUJBBMcFagxwIKLlmRsW7ClkXmac=
github.com/whosonfirst/go-whosonfirst-placetypes v0.1.0/go.mod h1:Jdmug2QQLbrmg+UcYGz8k575GnrOEg63vZVS46e5fMs=
Expand Down
26 changes: 13 additions & 13 deletions repo/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"encoding/json"
"errors"
"fmt"
"github.com/whosonfirst/go-cache"
"github.com/whosonfirst/go-ioutil"
"github.com/whosonfirst/go-whosonfirst-findingaid"
Expand Down Expand Up @@ -43,28 +44,31 @@ func NewIndexer(ctx context.Context, uri string) (findingaid.Indexer, error) {
q := u.Query()

cache_uri := q.Get("cache")
iterator_uri := q.Get("indexer")
iterator_uri := q.Get("iterator")

if cache_uri == "" {
return nil, errors.New("Missing cache URI")
return nil, errors.New("Missing ?cache= parameter.")
}

_, err = url.Parse(cache_uri)
c, err := cache.NewCache(ctx, cache_uri)

if err != nil {
return nil, err
}

_, err = url.Parse(iterator_uri)

if err != nil {
return nil, err
if iterator_uri == "" {
return nil, errors.New("Missing ?iterator= parameter.")
}

c, err := cache.NewCache(ctx, cache_uri)
// We defer creating the iterator until the 'IndexURIs' method is
// invoked because the iterator callback has a reference to this
// (findingaid indexer) instance which hasn't been created at this
// point.

_, err = url.Parse(iterator_uri)

if err != nil {
return nil, err
return nil, fmt.Errorf("Invalid ?iterator= parameter, %w", err)
}

fa := &Indexer{
Expand All @@ -78,10 +82,6 @@ func NewIndexer(ctx context.Context, uri string) (findingaid.Indexer, error) {
// Index will index records defined by 'sources...' in the finding aid, using the whosonfirst/go-whosonfirst-iterate package.
func (fa *Indexer) IndexURIs(ctx context.Context, sources ...string) error {

if fa.iterator_uri == "" {
return errors.New("Finding aid was not created with an indexer URI.")
}

cb := func(ctx context.Context, fh io.ReadSeeker, args ...interface{}) error {

select {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,9 @@ github.com/whosonfirst/go-cache-blob
# github.com/whosonfirst/go-ioutil v1.0.0
## explicit
github.com/whosonfirst/go-ioutil
# github.com/whosonfirst/go-reader v0.5.0
## explicit
# github.com/whosonfirst/go-whosonfirst-crawl v0.2.1
github.com/whosonfirst/go-whosonfirst-crawl
# github.com/whosonfirst/go-whosonfirst-iterate v1.1.2
# github.com/whosonfirst/go-whosonfirst-iterate v1.2.0
## explicit
github.com/whosonfirst/go-whosonfirst-iterate/emitter
github.com/whosonfirst/go-whosonfirst-iterate/filters
Expand Down

0 comments on commit 222ad85

Please sign in to comment.