Skip to content

PDOK/gomagpie

Repository files navigation

Gomagpie

Gomagpie

Location search and geocoding API. To be used in concert with OGC APIs.

Build Lint (go) Go Report Card Coverage (go) GitHub license Docker Pulls

Description

This application offers location search and geocoding.

Build

docker build -t pdok/gomagpie .

Run

NAME:
   Gomagpie - Location search and geocoding API

USAGE:
   Gomagpie [global options] command [command options]

COMMANDS:
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --host value             bind host (default: "0.0.0.0") [$HOST]
   --port value             bind port (default: 8080) [$PORT]
   --debug-port value       bind port for debug server (disabled by default), do not expose this port publicly (default: -1) [$DEBUG_PORT]
   --shutdown-delay value   delay (in seconds) before initiating graceful shutdown (e.g. useful in k8s to allow ingress controller to update their endpoints list) (default: 0) [$SHUTDOWN_DELAY]
   --config-file value      reference to YAML configuration file [$CONFIG_FILE]
   --enable-trailing-slash  allow API calls to URLs with a trailing slash. (default: false) [$ALLOW_TRAILING_SLASH]
   --enable-cors            enable Cross-Origin Resource Sharing (CORS) as required by OGC API specs. Disable if you handle CORS elsewhere. (default: false) [$ENABLE_CORS]
   --help, -h               show help

Example (config-file is mandatory):

docker run -v `pwd`/examples:/examples -p 8080:8080 -it pdok/gomagpie --config-file /examples/config.yaml

Now open http://localhost:8080. See examples for more details.

Observability

Health checks

Health endpoint is available on /health.

Profiling

Besides the main server, Gomagpie can also start a debug server. This server binds to localhost and a different port which you must specify using the --debug-port flag. You shouldn't expose this port publicly but only access it through a tunnel/port-forward. The debug server exposes /debug for use by pprof. For example with --debug-port 9001:

  • Create a tunnel to the debug server e.g. in k8s: kubectl port-forward gomagpie-75f59d57f4-4nd6q 9001:9001
  • Create CPU profile: go tool pprof http://localhost:9001/debug/pprof/profile?seconds=20
  • Start pprof visualization go tool pprof -http=":8000" pprofbin <path to pb.gz file>
  • Open http://localhost:8000 to explore CPU flamegraphs and such.

A similar flow can be used to profile memory issues.

Develop

Build/run as Go application

go build -o gomagpie cmd/main.go
./gomagpie

To troubleshoot, review the Dockerfile since compilation also happens there.

Linting

Install golangci-lint and run golangci-lint run from the root.

IntelliJ / GoLand

  • Install the Go Template plugin
  • Open Preferences > Editor > File Types select Go Template files and add the following file patterns:
    • "*.go.html"
    • "*.go.json"
    • "*.go.tilejson"
    • "*.go.xml"
  • Now add template language support by running the setup-jetbrains-gotemplates.sh script.
  • Reopen the project (or restart IDE). Now you'll have full IDE support in the gomagpie templates.

Also:

  • Set import order in Preferences > Editor > Code Style > Go > Imports to goimports to align with VSCode and goimports usage in golangci-lint.

VSCode

  • Install the Go Template extension
  • Open Extension Settings and add the following file patterns:
    • "*.go.html"
    • "*.go.json"
    • "*.go.tilejson"
    • "*.go.xml"
  • Also add html, json and xml to the list of Go template languages.
  • Now you'll have IDE support in the gomagpie templates.

Misc

Origin

Gomagpie started as a fork of GoKoala.

How to Contribute

Make a pull request...

Contact

Contacting the maintainers can be done through the issue tracker.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published