Giter VIP home page Giter VIP logo

akvo-flow-maps's Introduction

Akvo Flow Maps

Implementation of maps for Akvo Flow, based on Windshaft.

Architecture

Flow will push datapoints to a Kafka queue (one per tenant) and Flow Maps will store the required data in a Postgres DB (one per tenant) that will later be used by Windshaft to draw the tiles.

The components:

Component

Notes:

  1. Nginx is the only component exposed to the external world
  2. The tenant dbs are created when the first datapoint is received
  3. The map consumer and the auth proxy are right now running in the same JVM process

API

The Kafka consumer will consume any topic that matches the regex .*datapoint.*.. It expects an avro message with the schema as defined at Akvo Flow Schemas

To view a map:

View Map

  1. The auth flow in the diagram is a Client Credentials Grant. See also the the keycloak documentation.
  2. The auth proxy checks that the JWT token has a "akvo_flow_maps_client" role.
  3. The /create-map API expects a POST request with a JSON body with two keys:
    1. topic: the name of the Kafka topic that the data is sent to.
    2. map: a Windshaft MapConfig

Developing

To begin developing:

docker-compose up

A Clojure REPL will be listening on port 47480.

Nginx will be listening on localhost:7070, with an example UI.

To add an example dataset, look at the akvo.flow.maps.push-some-test-data namespace in the test directory.

Testing

Testing is fastest through the REPL, as you avoid environment startup time.

(dev/test)

To run the unit tests:

docker-compose exec flow-maps lein test

or the integration tests:

docker-compose exec flow-maps lein test :integration

Legal

Copyright © 2017 Akvo Foundation

Distributed under the GNU Affero General Public License 3.0

akvo-flow-maps's People

Contributors

dlebrero avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

akvo-flow-maps's Issues

Secure the map creation

Only Flow should be able to create new maps.

Secure the create map endpoint by doing some Authz on the Windshaft proxy, maybe by using Keycloak service accounts.

Windshaft tiles endpoint should still be available to external clients. Probably we will need some Nginx proxy to disallow any POST request to Windshaft

Check the log retention of the consumer offset topic

I think the default log retention for the Kafka consumer topic offset topic is one day, which means that if our consumer goes down for more than 24 hours, it will start from the beginning.

Change the retention to one week, so we have more time to detect and fix any possible issue

Support MultiTenant

  • Create a new DB when the first message for a tenant is received
  • Create a new user/pass and store it in the master db
  • Auth proxy to read the credentials from the master db

Monitoring

Make sure that the consumer is consuming and that it doesn't lag behind

Add some resilience to consumer

Right now any exception will crash the consumer thread.

Either make the process more resilient to excepted exceptions (like DB timeouts) or make sure that the process crashes and except K8s to restart the process.

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.