Giter VIP home page Giter VIP logo

Comments (6)

brendan-ward avatar brendan-ward commented on May 25, 2024 2

Another approach would be to respond to OS signals and restart based on those:
https://stackoverflow.com/questions/18106749/golang-catch-signals

For example, use HUP signal to trigger a reload of tilesets, without taking the server all the way down and back up.

One of the issues with a filewatcher approach is that files may not be fully ready when they are first detected on the filesystem, either due to copy in progress, or tile generation in progress.

from mbtileserver.

fawick avatar fawick commented on May 25, 2024

Here is an unpolished idea how to implement this now that we have the handlers package.

What if *mbtiles.ServiceSet did not have a Handler()method but would implement the http.Handler interface itself and muxes each request in the ServeHTTP method. Then we could dynamically check on the registered *mbtiles.DBs and route accordingly. And, as aimed for, we could even add more DBs while the webserver is already listening. Of course we would need to protect ServiceSet.tilesets with a mutex. Also the performance might be a tiny bit worse then using a dedicated and pre-filled *http.ServeMux (just a guess, benchmarks would be needed to be sure).

I reckon there are not many consumers of handlers in its current form, yet (maybe I am still the only one), so having a breaking API change is probably not a problem.

from mbtileserver.

brendan-ward avatar brendan-ward commented on May 25, 2024

@fawick what event would trigger adding more once the server is running? A file watcher detecting a change, an API call, or something else?

from mbtileserver.

fawick avatar fawick commented on May 25, 2024

In general, I think the answer depends on the needs of the users of the package handlers because from the outside a call to ServiceSet.AddDBOnPath would load the new tileset at runtime. For convenience, we could refactor filepath.Walk over a given directory into an own exported method so it does not need to be reimplemented on the outside. (That method could also remove any mbtiles.DBs, that are gone in the meantime).

Specific to the mbtileserver main, we could delegate the decision to the user, too, and have command line switches that trigger either the installation of an HTTP API endpoint, or the installation of a file watcher, or both. My point here is that all of this is outside of handlers.

from mbtileserver.

brendan-ward avatar brendan-ward commented on May 25, 2024

The new concurrent map in Go 1.9 should give us what we need for managing concurrency: https://golang.org/doc/go1.9#sync-map. No need for a separate library.

from mbtileserver.

brendan-ward avatar brendan-ward commented on May 25, 2024

Resolved by #69

from mbtileserver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.