Git Product home page Git Product logo

iot-server-demo's Introduction

Codacy Badge Build Status

IOT Server Demo

A POC Experiment

don't take this code too seriously


A system of Akka actors that maintain device, location, and fleet state.

A system of sliding windows maintains all the observations for a location by observation name (ie: water_level or oil_temp, etc...). The currently active window is available as it is being populated - ie: you can see all prior 10-minute windows as if they were tumbled with no overlap, but the current window is always the most recent 10 minutes (rounded to step time) - overlapping the prior window by step-time until it is complete and the next one is started.

All current assessments at the device level are available from the device actor.

All current assessments at the location level are available from the location actor for 24 hours.

The windowing code is based on Software Mill's excellent post about Akka Streams and windowing.

To Run

  • run Kafka with Docker docker run -d --name my-kafka -p 2181:2181 -p 9092:9092 --env ADVERTISED_HOST=ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p' --env ADVERTISED_PORT=9092 spotify/kafka
  • run Cassandra with Docker docker run -p 9042:9042 --name my-cassandra -d cassandra:3.11
  • or run redis with Docker: docker run -p 6379:6379 --name my-redis -d redis export REDIS_HOST=ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'
  • sbt run
  • see examples/get.rest for API usage examples
  • see application.conf for config and ENV VAR details

Features

  • Device twins and location twins can be inspected via an HTTP API
  • Device observations - telemetry - can be posted via HTTP
  • Observations are processed in Kafka with Akka Streams
    • End-to-end backpressure
    • Resume supervision strategy
    • Kafka offset persistence
  • Sliding windows with watermarking

Entities

  • Observation - a named time-stamped measurement
  • Device - a source of observations
  • Location - a collection of devices
  • Fleet - a collection of locations and fleets
  • Assessment - a processed observation or collection of observations

TODO

  • Actor persistence and serialization
  • Cluster deployment with sharding and discovery
  • Move Kafka offset persistence to after the windows processing
  • AUTH
  • HTTP2
  • Let observations reference devices by meaningful names (IOT devices won't like predefined UUIDs)
  • Parameterize the window size, step, and watermarking settings

iot-server-demo's People

Contributors

codacy-badger avatar navicore avatar

Watchers

 avatar  avatar

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.