From 95670df6cc5f17ab7679d962763ed933be027c6e Mon Sep 17 00:00:00 2001 From: Aaron Straup Cope Date: Thu, 21 Nov 2024 13:33:45 -0800 Subject: [PATCH] update docs (#15) Co-authored-by: sfomuseumbot --- README.md | 31 ++-- cmd/grpc-client/main.go | 8 +- cmd/grpc-server/main.go | 13 +- cmd/http-server/main.go | 10 +- cmd/pip/main.go | 6 +- cmd/update-hierarchies/main.go | 6 +- go.mod | 20 ++- go.sum | 32 ++-- .../aaronland/go-json-query/.gitignore | 4 +- .../aaronland/go-uid-proxy/proxy.go | 20 ++- .../sfomuseum/go-timings/counter.go | 10 +- .../github.com/sfomuseum/go-timings/since.go | 6 +- vendor/github.com/tidwall/gjson/README.md | 22 +-- vendor/github.com/tidwall/gjson/gjson.go | 160 ++++++++++++++---- .../go-whosonfirst-iterate/v2/emitter/cwd.go | 131 ++++++++++++++ vendor/modules.txt | 24 +-- 16 files changed, 376 insertions(+), 127 deletions(-) create mode 100644 vendor/github.com/whosonfirst/go-whosonfirst-iterate/v2/emitter/cwd.go diff --git a/README.md b/README.md index 6f82f46a..af313554 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,7 @@ import ( "context" "encoding/json" "fmt" + _ "github.com/whosonfirst/go-whosonfirst-spatial-sqlite" "github.com/whosonfirst/go-whosonfirst-spatial/database" "github.com/whosonfirst/go-whosonfirst-spatial/filter" @@ -130,7 +131,7 @@ _To be written_ $> ./bin/pip -h -alternate-geometry value One or more alternate geometry labels (wof:alt_label) values to filter results by. - -cessation-date string + -cessation string A valid EDTF date string. -custom-placetypes string A JSON-encoded string containing custom placetypes defined using the syntax described in the whosonfirst/go-whosonfirst-placetypes repository. @@ -138,7 +139,7 @@ $> ./bin/pip -h Enable wof:placetype values that are not explicitly defined in the whosonfirst/go-whosonfirst-placetypes repository. -geometries string Valid options are: all, alt, default. (default "all") - -inception-date string + -inception string A valid EDTF date string. -is-ceased value One or more existential flags (-1, 0, 1) to filter results by. @@ -152,18 +153,26 @@ $> ./bin/pip -h One or more existential flags (-1, 0, 1) to filter results by. -is-wof Input data is WOF-flavoured GeoJSON. (Pass a value of '0' or 'false' if you need to index non-WOF documents. (default true) + -iterator-uri value + Zero or more URIs denoting data sources to use for indexing the spatial database at startup. URIs take the form of {ITERATOR_URI} + "#" + {PIPE-SEPARATED LIST OF ITERATOR SOURCES}. Where {ITERATOR_URI} is expected to be a registered whosonfirst/go-whosonfirst-iterate/v2 iterator (emitter) URI and {ITERATOR SOURCES} are valid input paths for that iterator. Supported whosonfirst/go-whosonfirst-iterate/v2 iterator schemes are: cwd://, directory://, featurecollection://, file://, filelist://, geojsonl://, null://, repo://. -latitude float A valid latitude. -longitude float A valid longitude. + -mode string + Valid options are: cli (default "cli") -placetype value One or more place types to filter results by. -properties-reader-uri string - A valid whosonfirst/go-reader.Reader URI. Available options are: [file:// fs:// null://] + A valid whosonfirst/go-reader.Reader URI. Available options are: [fs:// null:// repo:// sqlite:// stdin://]. If the value is {spatial-database-uri} then the value of the '-spatial-database-uri' implements the reader.Reader interface and will be used. -property value One or more Who's On First properties to append to each result. + -server-uri string + A valid aaronland/go-http-server URI. (default "http://localhost:8080") + -sort-uri value + Zero or more whosonfirst/go-whosonfirst-spr/sort URIs. -spatial-database-uri string - A valid whosonfirst/go-whosonfirst-spatial/data.SpatialDatabase URI. options are: [sqlite://] + A valid whosonfirst/go-whosonfirst-spatial/data.SpatialDatabase URI. options are: [rtree:// sqlite://] (default "rtree://") -verbose Be chatty. ``` @@ -252,7 +261,7 @@ $> ./bin/pip \ But when filtered using the `-is-current 1` flag there is only a single result: ``` -> ./bin/pip \ +$> ./bin/pip \ -spatial-database-uri 'sqlite://?dsn=/usr/local/data/sfom-arch.db' \ -latitude 37.616951 \ -longitude -122.383747 \ @@ -382,7 +391,7 @@ _Big thanks to @psanford 's [sqlitevfshttp](https://github.com/psanford/sqlite3v ### http-server ``` -> ./bin/http-server -h +$> ./bin/http-server -h -authenticator-uri string A valid sfomuseum/go-http-auth URI. (default "null://") -cors-allow-credentials @@ -401,10 +410,8 @@ _Big thanks to @psanford 's [sqlitevfshttp](https://github.com/psanford/sqlite3v Enable gzip-encoding for data-related and API handlers. -enable-www Enable the interactive /debug endpoint to query points and display results. - -is-wof - Input data is WOF-flavoured GeoJSON. (Pass a value of '0' or 'false' if you need to index non-WOF documents. (default true) - -iterator-uri string - A valid whosonfirst/go-whosonfirst-iterate/v2 URI. Supported schemes are: directory://, featurecollection://, file://, filelist://, geojsonl://, null://, repo://. (default "repo://") + -iterator-uri value + Zero or more URIs denoting data sources to use for indexing the spatial database at startup. URIs take the form of {ITERATOR_URI} + "#" + {PIPE-SEPARATED LIST OF ITERATOR SOURCES}. Where {ITERATOR_URI} is expected to be a registered whosonfirst/go-whosonfirst-iterate/v2 iterator (emitter) URI and {ITERATOR SOURCES} are valid input paths for that iterator. Supported whosonfirst/go-whosonfirst-iterate/v2 iterator schemes are: cwd://, directory://, featurecollection://, file://, filelist://, geojsonl://, null://, repo://. -leaflet-initial-latitude float The initial latitude for map views to use. (default 37.616906) -leaflet-initial-longitude float @@ -562,8 +569,8 @@ $> ./bin/grpc-server -h The host to listen for requests on (default "localhost") -is-wof Input data is WOF-flavoured GeoJSON. (Pass a value of '0' or 'false' if you need to index non-WOF documents. (default true) - -iterator-uri string - A valid whosonfirst/go-whosonfirst-iterate/v2 URI. Supported schemes are: directory://, featurecollection://, file://, filelist://, geojsonl://, null://, repo://. (default "repo://") + -iterator-uri value + Zero or more URIs denoting data sources to use for indexing the spatial database at startup. URIs take the form of {ITERATOR_URI} + "#" + {PIPE-SEPARATED LIST OF ITERATOR SOURCES}. Where {ITERATOR_URI} is expected to be a registered whosonfirst/go-whosonfirst-iterate/v2 iterator (emitter) URI and {ITERATOR SOURCES} are valid input paths for that iterator. Supported whosonfirst/go-whosonfirst-iterate/v2 iterator schemes are: cwd://, directory://, featurecollection://, file://, filelist://, geojsonl://, null://, repo://. -port int The port to listen for requests on (default 8082) -properties-reader-uri string diff --git a/cmd/grpc-client/main.go b/cmd/grpc-client/main.go index 87218073..53f51f56 100644 --- a/cmd/grpc-client/main.go +++ b/cmd/grpc-client/main.go @@ -4,17 +4,15 @@ import ( "context" "log" - "github.com/whosonfirst/go-whosonfirst-spatial-grpc/app/client" + "github.com/whosonfirst/go-whosonfirst-spatial-grpc/app/client" ) func main() { ctx := context.Background() - logger := log.Default() - - err := client.Run(ctx, logger) + err := client.Run(ctx) if err != nil { - logger.Fatalf("Failed to run client, %v", err) + log.Fatalf("Failed to run client, %v", err) } } diff --git a/cmd/grpc-server/main.go b/cmd/grpc-server/main.go index 2ead6477..cd336c03 100644 --- a/cmd/grpc-server/main.go +++ b/cmd/grpc-server/main.go @@ -1,24 +1,19 @@ package main -import ( - _ "github.com/whosonfirst/go-whosonfirst-spatial-sqlite" -) - import ( "context" "log" - "github.com/whosonfirst/go-whosonfirst-spatial-grpc/app/server" + "github.com/whosonfirst/go-whosonfirst-spatial-grpc/app/server" + _ "github.com/whosonfirst/go-whosonfirst-spatial-sqlite" ) func main() { ctx := context.Background() - logger := log.Default() - - err := server.Run(ctx, logger) + err := server.Run(ctx) if err != nil { - logger.Fatalf("Failed to run client, %v", err) + log.Fatalf("Failed to run client, %v", err) } } diff --git a/cmd/http-server/main.go b/cmd/http-server/main.go index ad6c0566..9365d28d 100644 --- a/cmd/http-server/main.go +++ b/cmd/http-server/main.go @@ -2,8 +2,7 @@ package main import ( "context" - "log/slog" - "os" + "log" _ "github.com/whosonfirst/go-whosonfirst-spatial-sqlite" "github.com/whosonfirst/go-whosonfirst-spatial-www/app/server" @@ -12,12 +11,9 @@ import ( func main() { ctx := context.Background() - logger := slog.Default() - - err := server.Run(ctx, logger) + err := server.Run(ctx) if err != nil { - logger.Error("Failed to run server", "error", err) - os.Exit(1) + log.Fatalf("Failed to run server, %v", err) } } diff --git a/cmd/pip/main.go b/cmd/pip/main.go index 8231c7ce..4fbfabfb 100644 --- a/cmd/pip/main.go +++ b/cmd/pip/main.go @@ -11,11 +11,9 @@ import ( func main() { ctx := context.Background() - logger := log.Default() - - err := pip.Run(ctx, logger) + err := pip.Run(ctx) if err != nil { - logger.Fatal(err) + log.Fatal(err) } } diff --git a/cmd/update-hierarchies/main.go b/cmd/update-hierarchies/main.go index 926cbb05..9ff2965c 100644 --- a/cmd/update-hierarchies/main.go +++ b/cmd/update-hierarchies/main.go @@ -11,11 +11,9 @@ import ( func main() { ctx := context.Background() - logger := log.Default() - - err := update.Run(ctx, logger) + err := update.Run(ctx) if err != nil { - logger.Fatal(err) + log.Fatal(err) } } diff --git a/go.mod b/go.mod index a8905c7c..7d4294ee 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,8 @@ module github.com/whosonfirst/go-whosonfirst-spatial-sqlite -go 1.22.3 +go 1.23 + +toolchain go1.23.2 require ( github.com/aaronland/go-sqlite-modernc v0.0.3 @@ -10,7 +12,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/whosonfirst/go-ioutil v1.0.2 github.com/whosonfirst/go-reader v1.0.2 - github.com/whosonfirst/go-whosonfirst-spatial v0.10.1 + github.com/whosonfirst/go-whosonfirst-spatial v0.10.2 github.com/whosonfirst/go-whosonfirst-spatial-grpc v0.1.2 github.com/whosonfirst/go-whosonfirst-spatial-www v0.2.0 github.com/whosonfirst/go-whosonfirst-spr/v2 v2.3.7 @@ -35,7 +37,7 @@ require ( github.com/aaronland/go-http-server v1.4.1 // indirect github.com/aaronland/go-http-static v0.0.3 // indirect github.com/aaronland/go-http-tangramjs v0.3.0 // indirect - github.com/aaronland/go-json-query v0.1.4 // indirect + github.com/aaronland/go-json-query v0.1.5 // indirect github.com/aaronland/go-log/v2 v2.0.0 // indirect github.com/aaronland/go-pagination v0.2.0 // indirect github.com/aaronland/go-pagination-sql v0.2.0 // indirect @@ -44,7 +46,7 @@ require ( github.com/aaronland/go-string v1.0.0 // indirect github.com/aaronland/go-uid v0.4.0 // indirect github.com/aaronland/go-uid-artisanal v0.0.4 // indirect - github.com/aaronland/go-uid-proxy v0.2.0 // indirect + github.com/aaronland/go-uid-proxy v0.3.0 // indirect github.com/aaronland/go-uid-whosonfirst v0.0.5 // indirect github.com/akrylysov/algnhsa v1.1.0 // indirect github.com/aws/aws-lambda-go v1.47.0 // indirect @@ -99,13 +101,13 @@ require ( github.com/sfomuseum/go-sfomuseum-mapshaper v0.0.3 // indirect github.com/sfomuseum/go-sfomuseum-pmtiles v1.2.0 // indirect github.com/sfomuseum/go-template v1.8.0 // indirect - github.com/sfomuseum/go-timings v1.3.0 // indirect + github.com/sfomuseum/go-timings v1.4.0 // indirect github.com/sfomuseum/iso8601duration v1.1.0 // indirect github.com/sfomuseum/runtimevar v1.1.2 // indirect github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect github.com/tdewolff/minify/v2 v2.19.10 // indirect github.com/tdewolff/parse/v2 v2.6.8 // indirect - github.com/tidwall/gjson v1.17.3 // indirect + github.com/tidwall/gjson v1.18.0 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect github.com/tidwall/sjson v1.2.5 // indirect @@ -113,12 +115,12 @@ require ( github.com/whosonfirst/go-rfc-5646 v0.1.0 // indirect github.com/whosonfirst/go-sanitize v0.1.0 // indirect github.com/whosonfirst/go-whosonfirst-crawl v0.2.2 // indirect - github.com/whosonfirst/go-whosonfirst-export/v2 v2.8.2 // indirect + github.com/whosonfirst/go-whosonfirst-export/v2 v2.8.3 // indirect github.com/whosonfirst/go-whosonfirst-feature v0.0.28 // indirect github.com/whosonfirst/go-whosonfirst-flags v0.5.2 // indirect github.com/whosonfirst/go-whosonfirst-format v0.4.1 // indirect - github.com/whosonfirst/go-whosonfirst-id v1.2.4 // indirect - github.com/whosonfirst/go-whosonfirst-iterate/v2 v2.4.1 // indirect + github.com/whosonfirst/go-whosonfirst-id v1.2.5 // indirect + github.com/whosonfirst/go-whosonfirst-iterate/v2 v2.5.0 // indirect github.com/whosonfirst/go-whosonfirst-names v0.1.0 // indirect github.com/whosonfirst/go-whosonfirst-placetypes v0.7.3 // indirect github.com/whosonfirst/go-whosonfirst-reader v1.0.2 // indirect diff --git a/go.sum b/go.sum index 64e631d8..7f248e8f 100644 --- a/go.sum +++ b/go.sum @@ -41,8 +41,8 @@ github.com/aaronland/go-http-static v0.0.3 h1:0MnYXNwGVDCzre5YwinfPSdAFHInbBbmBv github.com/aaronland/go-http-static v0.0.3/go.mod h1:/s6lHGXq95ZR9nMJmE9slE4uMi92GP34CuG3f9xlfsY= github.com/aaronland/go-http-tangramjs v0.3.0 h1:cXFIC6bHffk5qXogT8AwFX287CYURY5L/BlXeKV+LGk= github.com/aaronland/go-http-tangramjs v0.3.0/go.mod h1:wGX2oqMxHvwOpVE6k4BM3S3m2mJJ71Q4ao1GVeKTnRY= -github.com/aaronland/go-json-query v0.1.4 h1:iM5GkF0VDsOeVgp0/WrDaFUB64ubJvmm+TZ0H4OQxxM= -github.com/aaronland/go-json-query v0.1.4/go.mod h1:S7V5eQko+XDPq+dfdSYub5mZI0VapVgUH2NLG0buZr4= +github.com/aaronland/go-json-query v0.1.5 h1:fSNnOKrNmQzw86Ih6L+xlL4hmJuiEK17HXo9rArYC4o= +github.com/aaronland/go-json-query v0.1.5/go.mod h1:MoyWsbG6fkcX0nXIg2ELGdNMcmLOFv+Xr+29xgr/RdU= github.com/aaronland/go-log/v2 v2.0.0 h1:lMoaVDHd4Etaz2+ibze3ReqvHHG68z2SpuxYXv12WlE= github.com/aaronland/go-log/v2 v2.0.0/go.mod h1:jOLBCaHVyOC7DQpbVFFQSiuU8CA8MRMrqA1mMSJQtLs= github.com/aaronland/go-pagination v0.2.0 h1:ZZ8mNu5oEK5wanAjbYAaE3w5eyQKzFOWu/gsloW1vdw= @@ -63,8 +63,8 @@ github.com/aaronland/go-uid v0.4.0 h1:2qQ2yRQarrUCEU9ApvBpaC9osAcqTCCvD77rOkDp7m github.com/aaronland/go-uid v0.4.0/go.mod h1:HwQ09mooJ8j684z3W5lPKO6Odf557O6h3P3o1PquqXE= github.com/aaronland/go-uid-artisanal v0.0.4 h1:I/29nzNnj32gax6rkBLeNtnwtXLqLAIE0mOlMq6KWWY= github.com/aaronland/go-uid-artisanal v0.0.4/go.mod h1:fNtTeUssikRxhttmzQeR3yDLJpSchzwTVqvsOIlglks= -github.com/aaronland/go-uid-proxy v0.2.0 h1:owPhro/6SlHkxKAIuO60oGIScs4MJjTAVwLj2zfttF4= -github.com/aaronland/go-uid-proxy v0.2.0/go.mod h1:LFZBtJBMR7HNOv2Qvd1C2uCsOsHeL6xpXEVrqiC+6tM= +github.com/aaronland/go-uid-proxy v0.3.0 h1:GxAgpLdtHuHW/cTyx+FhWLQxKIiDasCgLu+QTlWseZo= +github.com/aaronland/go-uid-proxy v0.3.0/go.mod h1:LFZBtJBMR7HNOv2Qvd1C2uCsOsHeL6xpXEVrqiC+6tM= github.com/aaronland/go-uid-whosonfirst v0.0.5 h1:j5/vWjq/im3YPcx43R/8sJDJ4F2e7LlnQSK9/MMfsWw= github.com/aaronland/go-uid-whosonfirst v0.0.5/go.mod h1:Z/VSvb6IzCBnSNjDzgiuiJyptUbKSWhwexrjLEO4+24= github.com/akrylysov/algnhsa v1.1.0 h1:G0SoP16tMRyiism7VNc3JFA0wq/cVgEkp/ExMVnc6PQ= @@ -271,8 +271,8 @@ github.com/sfomuseum/go-sfomuseum-pmtiles v1.2.0 h1:KMBzPURe73GI0uai8Hg6iwat8xyM github.com/sfomuseum/go-sfomuseum-pmtiles v1.2.0/go.mod h1:R2YN78nGHl6SckPXd6CL7JDVgNsMQUx1QTvGKkrzzHU= github.com/sfomuseum/go-template v1.8.0 h1:upXRQ+oeUbfz0KxH79ws/kS2gKF+y5pSXVEQOgvv6IM= github.com/sfomuseum/go-template v1.8.0/go.mod h1:el1YP8YUqKbSmQxnWxh7s8Z6HVNUzKUuNKtu5tvQ4aU= -github.com/sfomuseum/go-timings v1.3.0 h1:dAn5CLqp7GF0JoeDGgg9WlQL7Veq2w16n3wMffrbcBE= -github.com/sfomuseum/go-timings v1.3.0/go.mod h1:jZrCwV4uoY5s4sOZWZLn6xQ2LhsMy2ZvdB3tzLPO76c= +github.com/sfomuseum/go-timings v1.4.0 h1:48TyPhrSlTVbFKI2psZiPD11GA0zXnrPJAyLmtBBmPg= +github.com/sfomuseum/go-timings v1.4.0/go.mod h1:FcDhHe439Uy6i+WpLHrTJirtv37sf6/TxBhAngUQP7M= github.com/sfomuseum/iso8601duration v1.1.0 h1:kMYzbamrZp9dRxi5iFuhjl5CzHXK6s6Bzz/c75wsq8Q= github.com/sfomuseum/iso8601duration v1.1.0/go.mod h1:6EenGWM7y8uVquMPEZwoR+ihpIMJluw7iYiHhDTuOAk= github.com/sfomuseum/runtimevar v1.1.2 h1:YcgxdB39gEqKN1H3wS9E773JsPWYKBVDdk/HF08BLFc= @@ -298,8 +298,8 @@ github.com/tdewolff/parse/v2 v2.6.8/go.mod h1:XHDhaU6IBgsryfdnpzUXBlT6leW/l25yrF github.com/tdewolff/test v1.0.9 h1:SswqJCmeN4B+9gEAi/5uqT0qpi1y2/2O47V/1hhGZT0= github.com/tdewolff/test v1.0.9/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE= github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= @@ -319,18 +319,18 @@ github.com/whosonfirst/go-sanitize v0.1.0 h1:ygSqCnakwdzH/m8UEa15zXGDsoo5/JJeRkg github.com/whosonfirst/go-sanitize v0.1.0/go.mod h1:p/emgbafMM0p5iVAz2XWwecYPl06Tw4Jos9rhTKIrt8= github.com/whosonfirst/go-whosonfirst-crawl v0.2.2 h1:7nwpNV/BFoPR0R7KMMy1iiYAer7wlHJBUOiL+NLzIFs= github.com/whosonfirst/go-whosonfirst-crawl v0.2.2/go.mod h1:2GZkaK9jaOisWRnBQGWzmb7H55TUFl9y9F30lrk2hwk= -github.com/whosonfirst/go-whosonfirst-export/v2 v2.8.2 h1:Jg8Ed4trgPZVKiXjhnH8oFfG9LeosrdgfDRNsYG4k7s= -github.com/whosonfirst/go-whosonfirst-export/v2 v2.8.2/go.mod h1:7LEVZByKDtHRLtu40mNR3/q9Mp0f8Db5YEh7gk7oLaY= +github.com/whosonfirst/go-whosonfirst-export/v2 v2.8.3 h1:mq1OjMP2Trenb+1wJGrYdKaFzkwWWHYSjdfPjok437A= +github.com/whosonfirst/go-whosonfirst-export/v2 v2.8.3/go.mod h1:e75gUUyEq8WhG+BVQ0wktZ6IqDLeJZlONDtXHpjxGtg= github.com/whosonfirst/go-whosonfirst-feature v0.0.28 h1:XCNNzjnk1i50UnqrNtrN9xNvJDwZGjsPHbb3HRPixXA= github.com/whosonfirst/go-whosonfirst-feature v0.0.28/go.mod h1:8kc2Ei7mCankyWQcfzLHdKAc1//B/ptY7uEFsT5I8m4= github.com/whosonfirst/go-whosonfirst-flags v0.5.2 h1:vSx7fcM04HiSAEF+WOKfuyJawac99skN9HJAeqBXWpI= github.com/whosonfirst/go-whosonfirst-flags v0.5.2/go.mod h1:kozBozsyI8cKekUces1m10vJ301sH2EqLZtjX1xCSqQ= github.com/whosonfirst/go-whosonfirst-format v0.4.1 h1:TVSrbbB/sXhAgyaTenaS93lERRITGQHBKIDwoEgxoqA= github.com/whosonfirst/go-whosonfirst-format v0.4.1/go.mod h1:lMBIXCnD9ZA+wCNtu6XFYoq5DTfnEALO8k6OkEn11MM= -github.com/whosonfirst/go-whosonfirst-id v1.2.4 h1:KC5VGR+mweXcECFL5MGfX3GcrlbZscCa+aSoU7OAAtM= -github.com/whosonfirst/go-whosonfirst-id v1.2.4/go.mod h1:3Tr/dxs4o8dvfcTyJrkS0wQ93Os+YjAVcWMD81BCFHE= -github.com/whosonfirst/go-whosonfirst-iterate/v2 v2.4.1 h1:GKm+MmZ878vFr8K/Bk9RLXKPt+va9TUqP3/JCnmynVI= -github.com/whosonfirst/go-whosonfirst-iterate/v2 v2.4.1/go.mod h1:kDIvHxJTo6XgFKmLHliGLxlqeeHhxuYtdeVZBAcP68g= +github.com/whosonfirst/go-whosonfirst-id v1.2.5 h1:WEQafWDflwiHG9zA4XKvo7+k/Tjvb/yf0+6lpXqdRyk= +github.com/whosonfirst/go-whosonfirst-id v1.2.5/go.mod h1:V0xr7Bs7Uuo+JJMRRoALlME6/R2K5CDm0BRp5NNThxc= +github.com/whosonfirst/go-whosonfirst-iterate/v2 v2.5.0 h1:aLThv46NCuScTnulbsgmKPZiCqnv7UH8X4ojO2151KI= +github.com/whosonfirst/go-whosonfirst-iterate/v2 v2.5.0/go.mod h1:wF/nVhSEVJdkWd24+TcXb5Pir92WDUqRa9oLu/qf9N4= github.com/whosonfirst/go-whosonfirst-names v0.1.0 h1:uXop/DwQqH60uDBZvHCPg1yRSQLScbm6VZyqcaED2KE= github.com/whosonfirst/go-whosonfirst-names v0.1.0/go.mod h1:0z86/nedM9T/5C8cAdbCMfRuBrkc33oEQ6vdJ6WybSg= github.com/whosonfirst/go-whosonfirst-placetypes v0.7.3 h1:BuKRV3pal5wanOZxWue7hWFZXlsWevmCY3X06bU+J6s= @@ -339,8 +339,8 @@ github.com/whosonfirst/go-whosonfirst-reader v1.0.2 h1:yLsDd6GJOsfMVJz63noH5Haoo github.com/whosonfirst/go-whosonfirst-reader v1.0.2/go.mod h1:1M6osxb9qXB3+ARINW4vuEaCTIN55abLRBGbBtfpGJ0= github.com/whosonfirst/go-whosonfirst-sources v0.1.0 h1:JuKLa6KWke22jBfJ1pM9WQHoz1/3pbDv2C+aR+THPPQ= github.com/whosonfirst/go-whosonfirst-sources v0.1.0/go.mod h1:EUMHyGzUmqPPxlMmOp+28BFeoBdxxE0HCKRd67lkqGM= -github.com/whosonfirst/go-whosonfirst-spatial v0.10.1 h1:TZtRZXUPh5OWwKWzLAt9v7bbC8kjS8LGshYd00BXzzo= -github.com/whosonfirst/go-whosonfirst-spatial v0.10.1/go.mod h1:MxGPCoIaIA5BnROQohjyeHHhDsf+Sq9pq8J2RUz7gSM= +github.com/whosonfirst/go-whosonfirst-spatial v0.10.2 h1:WAa3Wndk874QPVWxniPSvjZwovIj8KYPJUdPAeAffI4= +github.com/whosonfirst/go-whosonfirst-spatial v0.10.2/go.mod h1:ja79l9imEriYcWFVX1vbW4eMAf407/GqEQ3q5Fpa/1A= github.com/whosonfirst/go-whosonfirst-spatial-grpc v0.1.2 h1:0a+lES3zv/1iz0ppqMiuLIMxHW+IxO4VTwV7yIo+mw0= github.com/whosonfirst/go-whosonfirst-spatial-grpc v0.1.2/go.mod h1:giIqrHTO6grd1Geu3gBa2EY2D+GoVSZAY2l9oJYbtRk= github.com/whosonfirst/go-whosonfirst-spatial-www v0.2.0 h1:LpjuvmBznHQnYbYquo0YPYSJy0dab2sBRP5t6I5A9HU= diff --git a/vendor/github.com/aaronland/go-json-query/.gitignore b/vendor/github.com/aaronland/go-json-query/.gitignore index 6e7e38b3..2791de40 100644 --- a/vendor/github.com/aaronland/go-json-query/.gitignore +++ b/vendor/github.com/aaronland/go-json-query/.gitignore @@ -1,2 +1,4 @@ *~ -bin \ No newline at end of file +bin +.DS_Store +work \ No newline at end of file diff --git a/vendor/github.com/aaronland/go-uid-proxy/proxy.go b/vendor/github.com/aaronland/go-uid-proxy/proxy.go index 4c17c11a..03f9ced3 100644 --- a/vendor/github.com/aaronland/go-uid-proxy/proxy.go +++ b/vendor/github.com/aaronland/go-uid-proxy/proxy.go @@ -44,6 +44,19 @@ func NewProxyProvider(ctx context.Context, uri string) (uid.Provider, error) { q := u.Query() + status_monitor := false + + if q.Has("status-monitor") { + + v, err := strconv.ParseBool(q.Get("status-monitor")) + + if err != nil { + return nil, fmt.Errorf("Invalid ?status-monitor= parameter, %w", err) + } + + status_monitor = v + } + source_uri := q.Get("provider") if source_uri == "" { @@ -105,9 +118,13 @@ func NewProxyProvider(ctx context.Context, uri string) (uid.Provider, error) { } go pr.refillPool(ctx) - go pr.status(ctx) go pr.monitor(ctx) + if status_monitor { + slog.Debug("Starting status monitor") + go pr.status(ctx) + } + if minimum > 0 { refill <- true } @@ -148,6 +165,7 @@ func (pr *ProxyProvider) status(ctx context.Context) { for { select { case <-ctx.Done(): + slog.Debug("Status monitor received done signal, exiting") return case <-time.After(5 * time.Second): slog.Debug("Status", "pool length", pr.pool.Length(ctx)) diff --git a/vendor/github.com/sfomuseum/go-timings/counter.go b/vendor/github.com/sfomuseum/go-timings/counter.go index fae19343..bbb1a801 100644 --- a/vendor/github.com/sfomuseum/go-timings/counter.go +++ b/vendor/github.com/sfomuseum/go-timings/counter.go @@ -4,7 +4,7 @@ import ( "context" "fmt" "io" - _ "log" + "log/slog" "net/url" "strconv" "sync/atomic" @@ -91,6 +91,8 @@ func (t *CounterMonitor) Start(ctx context.Context, wr io.Writer) error { now := time.Now() t.start = now + logger := slog.New(slog.NewTextHandler(wr, nil)) + go func() { for { @@ -104,12 +106,12 @@ func (t *CounterMonitor) Start(ctx context.Context, wr io.Writer) error { var msg string if t.total > 0 { - msg = fmt.Sprintf("processed %d/%d records in %v (started %v)\n", atomic.LoadInt64(&t.counter), t.total, time.Since(t.start), t.start) + msg = fmt.Sprintf("Processed %d/%d records in %v (started %v)", atomic.LoadInt64(&t.counter), t.total, time.Since(t.start), t.start) } else { - msg = fmt.Sprintf("processed %d records in %v (started %v)\n", atomic.LoadInt64(&t.counter), time.Since(t.start), t.start) + msg = fmt.Sprintf("Processed %d records in %v (started %v)", atomic.LoadInt64(&t.counter), time.Since(t.start), t.start) } - wr.Write([]byte(msg)) + logger.Info(msg) } } }() diff --git a/vendor/github.com/sfomuseum/go-timings/since.go b/vendor/github.com/sfomuseum/go-timings/since.go index dc258b86..b2bf66f6 100644 --- a/vendor/github.com/sfomuseum/go-timings/since.go +++ b/vendor/github.com/sfomuseum/go-timings/since.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" "io" - "log" + "log/slog" "net/url" "sync" "time" @@ -88,6 +88,8 @@ func (t *SinceMonitor) Start(ctx context.Context, wr io.Writer) error { now := time.Now() t.start = now + logger := slog.New(slog.NewTextHandler(wr, nil)) + go func() { for { @@ -102,7 +104,7 @@ func (t *SinceMonitor) Start(ctx context.Context, wr io.Writer) error { err := enc.Encode(rsp) if err != nil { - log.Printf("Failed to encode response, %v", err) + logger.Error("Failed to encode response", "rsp", rsp, "error", err) } } } diff --git a/vendor/github.com/tidwall/gjson/README.md b/vendor/github.com/tidwall/gjson/README.md index 7701cae4..387766d5 100644 --- a/vendor/github.com/tidwall/gjson/README.md +++ b/vendor/github.com/tidwall/gjson/README.md @@ -438,15 +438,15 @@ Benchmarks of GJSON alongside [encoding/json](https://golang.org/pkg/encoding/js and [json-iterator](https://github.com/json-iterator/go) ``` -BenchmarkGJSONGet-16 11644512 311 ns/op 0 B/op 0 allocs/op -BenchmarkGJSONUnmarshalMap-16 1122678 3094 ns/op 1920 B/op 26 allocs/op -BenchmarkJSONUnmarshalMap-16 516681 6810 ns/op 2944 B/op 69 allocs/op -BenchmarkJSONUnmarshalStruct-16 697053 5400 ns/op 928 B/op 13 allocs/op -BenchmarkJSONDecoder-16 330450 10217 ns/op 3845 B/op 160 allocs/op -BenchmarkFFJSONLexer-16 1424979 2585 ns/op 880 B/op 8 allocs/op -BenchmarkEasyJSONLexer-16 3000000 729 ns/op 501 B/op 5 allocs/op -BenchmarkJSONParserGet-16 3000000 366 ns/op 21 B/op 0 allocs/op -BenchmarkJSONIterator-16 3000000 869 ns/op 693 B/op 14 allocs/op +BenchmarkGJSONGet-10 17893731 202.1 ns/op 0 B/op 0 allocs/op +BenchmarkGJSONUnmarshalMap-10 1663548 2157 ns/op 1920 B/op 26 allocs/op +BenchmarkJSONUnmarshalMap-10 832236 4279 ns/op 2920 B/op 68 allocs/op +BenchmarkJSONUnmarshalStruct-10 1076475 3219 ns/op 920 B/op 12 allocs/op +BenchmarkJSONDecoder-10 585729 6126 ns/op 3845 B/op 160 allocs/op +BenchmarkFFJSONLexer-10 2508573 1391 ns/op 880 B/op 8 allocs/op +BenchmarkEasyJSONLexer-10 3000000 537.9 ns/op 501 B/op 5 allocs/op +BenchmarkJSONParserGet-10 13707510 263.9 ns/op 21 B/op 0 allocs/op +BenchmarkJSONIterator-10 3000000 561.2 ns/op 693 B/op 14 allocs/op ``` JSON document used: @@ -487,4 +487,6 @@ widget.image.hOffset widget.text.onMouseUp ``` -*These benchmarks were run on a MacBook Pro 16" 2.4 GHz Intel Core i9 using Go 1.17 and can be found [here](https://github.com/tidwall/gjson-benchmarks).* +** + +*These benchmarks were run on a MacBook Pro M1 Max using Go 1.22 and can be found [here](https://github.com/tidwall/gjson-benchmarks).* diff --git a/vendor/github.com/tidwall/gjson/gjson.go b/vendor/github.com/tidwall/gjson/gjson.go index 779fe617..5aa2a4ff 100644 --- a/vendor/github.com/tidwall/gjson/gjson.go +++ b/vendor/github.com/tidwall/gjson/gjson.go @@ -1040,6 +1040,10 @@ func parseObjectPath(path string) (r objectPathResult) { return } +var vchars = [256]byte{ + '"': 2, '{': 3, '(': 3, '[': 3, '}': 1, ')': 1, ']': 1, +} + func parseSquash(json string, i int) (int, string) { // expects that the lead character is a '[' or '{' or '(' // squash the value, ignoring all nested arrays and objects. @@ -1047,43 +1051,137 @@ func parseSquash(json string, i int) (int, string) { s := i i++ depth := 1 - for ; i < len(json); i++ { - if json[i] >= '"' && json[i] <= '}' { - switch json[i] { - case '"': + var c byte + for i < len(json) { + for i < len(json)-8 { + jslice := json[i : i+8] + c = vchars[jslice[0]] + if c != 0 { + i += 0 + goto token + } + c = vchars[jslice[1]] + if c != 0 { + i += 1 + goto token + } + c = vchars[jslice[2]] + if c != 0 { + i += 2 + goto token + } + c = vchars[jslice[3]] + if c != 0 { + i += 3 + goto token + } + c = vchars[jslice[4]] + if c != 0 { + i += 4 + goto token + } + c = vchars[jslice[5]] + if c != 0 { + i += 5 + goto token + } + c = vchars[jslice[6]] + if c != 0 { + i += 6 + goto token + } + c = vchars[jslice[7]] + if c != 0 { + i += 7 + goto token + } + i += 8 + } + c = vchars[json[i]] + if c == 0 { + i++ + continue + } + token: + if c == 2 { + // '"' string + i++ + s2 := i + nextquote: + for i < len(json)-8 { + jslice := json[i : i+8] + if jslice[0] == '"' { + i += 0 + goto strchkesc + } + if jslice[1] == '"' { + i += 1 + goto strchkesc + } + if jslice[2] == '"' { + i += 2 + goto strchkesc + } + if jslice[3] == '"' { + i += 3 + goto strchkesc + } + if jslice[4] == '"' { + i += 4 + goto strchkesc + } + if jslice[5] == '"' { + i += 5 + goto strchkesc + } + if jslice[6] == '"' { + i += 6 + goto strchkesc + } + if jslice[7] == '"' { + i += 7 + goto strchkesc + } + i += 8 + } + goto strchkstd + strchkesc: + if json[i-1] != '\\' { i++ - s2 := i - for ; i < len(json); i++ { - if json[i] > '\\' { - continue - } - if json[i] == '"' { - // look for an escaped slash - if json[i-1] == '\\' { - n := 0 - for j := i - 2; j > s2-1; j-- { - if json[j] != '\\' { - break - } - n++ - } - if n%2 == 0 { - continue - } + continue + } + strchkstd: + for i < len(json) { + if json[i] > '\\' || json[i] != '"' { + i++ + continue + } + // look for an escaped slash + if json[i-1] == '\\' { + n := 0 + for j := i - 2; j > s2-1; j-- { + if json[j] != '\\' { + break } - break + n++ + } + if n%2 == 0 { + i++ + goto nextquote } } - case '{', '[', '(': - depth++ - case '}', ']', ')': - depth-- - if depth == 0 { - i++ - return i, json[s:i] - } + break + } + } else { + // '{', '[', '(', '}', ']', ')' + // open close tokens + depth += int(c) - 2 + if depth == 0 { + i++ + return i, json[s:i] } } + i++ } return i, json[s:] } diff --git a/vendor/github.com/whosonfirst/go-whosonfirst-iterate/v2/emitter/cwd.go b/vendor/github.com/whosonfirst/go-whosonfirst-iterate/v2/emitter/cwd.go new file mode 100644 index 00000000..4a3eea99 --- /dev/null +++ b/vendor/github.com/whosonfirst/go-whosonfirst-iterate/v2/emitter/cwd.go @@ -0,0 +1,131 @@ +package emitter + +import ( + "context" + "fmt" + "io/fs" + "os" + "sync" + + "github.com/whosonfirst/go-ioutil" + "github.com/whosonfirst/go-whosonfirst-iterate/v2/filters" +) + +var walk_once sync.Once +var walk_error error + +func init() { + ctx := context.Background() + RegisterEmitter(ctx, "cwd", NewCwdEmitter) +} + +// CwdEmitter implements the `Emitter` interface for crawling records in the current (working) directory. +type CwdEmitter struct { + Emitter + // filters is a `filters.Filters` instance used to include or exclude specific records from being crawled. + filters filters.Filters + cwd string +} + +// NewCwdEmitter() returns a new `CwdEmitter` instance configured by 'uri' in the form of: +// +// cwd://?{PARAMETERS} +// +// Where {PARAMETERS} may be: +// * `?include=` Zero or more `aaronland/go-json-query` query strings containing rules that must match for a document to be considered for further processing. +// * `?exclude=` Zero or more `aaronland/go-json-query` query strings containing rules that if matched will prevent a document from being considered for further processing. +// * `?include_mode=` A valid `aaronland/go-json-query` query mode string for testing inclusion rules. +// * `?exclude_mode=` A valid `aaronland/go-json-query` query mode string for testing exclusion rules. +func NewCwdEmitter(ctx context.Context, uri string) (Emitter, error) { + + f, err := filters.NewQueryFiltersFromURI(ctx, uri) + + if err != nil { + return nil, fmt.Errorf("Failed to create filters from query, %w", err) + } + + cwd, err := os.Getwd() + + if err != nil { + return nil, fmt.Errorf("Failed to derive current working directory, %w", err) + } + + idx := &CwdEmitter{ + filters: f, + cwd: cwd, + } + + return idx, nil +} + +// WalkURI() walks (crawls) the current directory each file (not excluded by any filters specified +// when `idx` was created) invokes 'index_cb'. +func (idx *CwdEmitter) WalkURI(ctx context.Context, index_cb EmitterCallbackFunc, uri string) error { + + walk_once.Do(func() { + idx.walkOnceFunc(ctx, index_cb) + }) + + if walk_error != nil { + return walk_error + } + + return nil +} + +func (idx *CwdEmitter) walkOnceFunc(ctx context.Context, index_cb EmitterCallbackFunc) { + + cwd_fs := os.DirFS(idx.cwd) + + walk_error = fs.WalkDir(cwd_fs, ".", func(path string, d fs.DirEntry, err error) error { + + if err != nil { + return err + } + + if d.IsDir() { + return nil + } + + r, err := cwd_fs.Open(path) + + if err != nil { + return fmt.Errorf("Failed to open %s for reading, %w", path, err) + } + + rsc, err := ioutil.NewReadSeekCloser(r) + + if err != nil { + return fmt.Errorf("Failed to create ReadSeekCloser for %s, %w", path, err) + } + + defer rsc.Close() + + if idx.filters != nil { + + ok, err := idx.filters.Apply(ctx, rsc) + + if err != nil { + return fmt.Errorf("Failed to apply filters for '%s', %w", path, err) + } + + if !ok { + return nil + } + + _, err = rsc.Seek(0, 0) + + if err != nil { + return fmt.Errorf("Failed to seek(0, 0) on reader for '%s', %w", path, err) + } + } + + err = index_cb(ctx, path, rsc) + + if err != nil { + return fmt.Errorf("Failed to invoke callback for '%s', %w", path, err) + } + + return nil + }) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 0b0dbd50..0a2e6a3a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -48,8 +48,8 @@ github.com/aaronland/go-http-static ## explicit; go 1.18 github.com/aaronland/go-http-tangramjs github.com/aaronland/go-http-tangramjs/static -# github.com/aaronland/go-json-query v0.1.4 -## explicit; go 1.18 +# github.com/aaronland/go-json-query v0.1.5 +## explicit; go 1.22 github.com/aaronland/go-json-query # github.com/aaronland/go-log/v2 v2.0.0 ## explicit; go 1.18 @@ -84,7 +84,7 @@ github.com/aaronland/go-uid # github.com/aaronland/go-uid-artisanal v0.0.4 ## explicit; go 1.18 github.com/aaronland/go-uid-artisanal -# github.com/aaronland/go-uid-proxy v0.2.0 +# github.com/aaronland/go-uid-proxy v0.3.0 ## explicit; go 1.22 github.com/aaronland/go-uid-proxy # github.com/aaronland/go-uid-whosonfirst v0.0.5 @@ -393,8 +393,8 @@ github.com/sfomuseum/go-sfomuseum-pmtiles/http ## explicit; go 1.18 github.com/sfomuseum/go-template/funcs github.com/sfomuseum/go-template/text -# github.com/sfomuseum/go-timings v1.3.0 -## explicit; go 1.18 +# github.com/sfomuseum/go-timings v1.4.0 +## explicit; go 1.22 github.com/sfomuseum/go-timings # github.com/sfomuseum/iso8601duration v1.1.0 ## explicit; go 1.18 @@ -419,7 +419,7 @@ github.com/tdewolff/parse/v2/buffer github.com/tdewolff/parse/v2/css github.com/tdewolff/parse/v2/js github.com/tdewolff/parse/v2/strconv -# github.com/tidwall/gjson v1.17.3 +# github.com/tidwall/gjson v1.18.0 ## explicit; go 1.12 github.com/tidwall/gjson # github.com/tidwall/match v1.1.1 @@ -450,7 +450,7 @@ github.com/whosonfirst/go-sanitize # github.com/whosonfirst/go-whosonfirst-crawl v0.2.2 ## explicit; go 1.18 github.com/whosonfirst/go-whosonfirst-crawl -# github.com/whosonfirst/go-whosonfirst-export/v2 v2.8.2 +# github.com/whosonfirst/go-whosonfirst-export/v2 v2.8.3 ## explicit; go 1.22 github.com/whosonfirst/go-whosonfirst-export/v2 github.com/whosonfirst/go-whosonfirst-export/v2/properties @@ -471,11 +471,11 @@ github.com/whosonfirst/go-whosonfirst-flags/placetypes # github.com/whosonfirst/go-whosonfirst-format v0.4.1 ## explicit; go 1.16 github.com/whosonfirst/go-whosonfirst-format -# github.com/whosonfirst/go-whosonfirst-id v1.2.4 +# github.com/whosonfirst/go-whosonfirst-id v1.2.5 ## explicit; go 1.22 github.com/whosonfirst/go-whosonfirst-id -# github.com/whosonfirst/go-whosonfirst-iterate/v2 v2.4.1 -## explicit; go 1.18 +# github.com/whosonfirst/go-whosonfirst-iterate/v2 v2.5.0 +## explicit; go 1.22 github.com/whosonfirst/go-whosonfirst-iterate/v2/emitter github.com/whosonfirst/go-whosonfirst-iterate/v2/filters github.com/whosonfirst/go-whosonfirst-iterate/v2/iterator @@ -493,8 +493,8 @@ github.com/whosonfirst/go-whosonfirst-reader ## explicit; go 1.12 github.com/whosonfirst/go-whosonfirst-sources github.com/whosonfirst/go-whosonfirst-sources/sources -# github.com/whosonfirst/go-whosonfirst-spatial v0.10.1 -## explicit; go 1.22.2 +# github.com/whosonfirst/go-whosonfirst-spatial v0.10.2 +## explicit; go 1.23 github.com/whosonfirst/go-whosonfirst-spatial github.com/whosonfirst/go-whosonfirst-spatial/app/hierarchy/update github.com/whosonfirst/go-whosonfirst-spatial/app/pip