From 222ad85f7aade5e10435ed6144b4ebfaeb53f183 Mon Sep 17 00:00:00 2001 From: thisisaaronland Date: Tue, 29 Jun 2021 09:59:57 -0700 Subject: [PATCH] update to use whosonfirst/go-whosonfirst-iterate 1.2.0; replace ?indexer= parameter with ?iterator= --- go.mod | 3 +-- go.sum | 2 ++ repo/indexer.go | 26 +++++++++---------- .../go-whosonfirst-iterate/emitter/null.go | 24 +++++++++++++++++ vendor/modules.txt | 4 +-- 5 files changed, 41 insertions(+), 18 deletions(-) create mode 100644 vendor/github.com/whosonfirst/go-whosonfirst-iterate/emitter/null.go diff --git a/go.mod b/go.mod index d4f0fb0a..fea99b35 100644 --- a/go.mod +++ b/go.mod @@ -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 ) diff --git a/go.sum b/go.sum index 2a5a8ace..06c9035a 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/repo/indexer.go b/repo/indexer.go index 59493be8..4f774847 100644 --- a/repo/indexer.go +++ b/repo/indexer.go @@ -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" @@ -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{ @@ -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 { diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-iterate/emitter/null.go b/vendor/github.com/whosonfirst/go-whosonfirst-iterate/emitter/null.go new file mode 100644 index 00000000..36ab35ac --- /dev/null +++ b/vendor/github.com/whosonfirst/go-whosonfirst-iterate/emitter/null.go @@ -0,0 +1,24 @@ +package emitter + +import ( + "context" +) + +func init() { + ctx := context.Background() + RegisterEmitter(ctx, "null", NewNullEmitter) +} + +type NullEmitter struct { + Emitter +} + +func NewNullEmitter(ctx context.Context, uri string) (Emitter, error) { + + idx := &NullEmitter{} + return idx, nil +} + +func (idx *NullEmitter) WalkURI(ctx context.Context, index_cb EmitterCallbackFunc, uri string) error { + return nil +} diff --git a/vendor/modules.txt b/vendor/modules.txt index cc005933..98ebea5f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -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