Reactive Programming Models for IoT
Todd L. Montgomery @toddlmontgomery
Reactive Programming Models for IoT Todd L. Montgomery - - PowerPoint PPT Presentation
Reactive Programming Models for IoT Todd L. Montgomery @toddlmontgomery Psst! Already Here! Not New! Internet of Things? Just a Silicon Valley buzzword? Psst! Also Not New! Reactive Programming? Just another buzzword? Connecting Things
Todd L. Montgomery @toddlmontgomery
Psst! Already Here! Not New!
Psst! Also Not New!
Request Response
Request Response
And if not, we’ll make it!
Request Response
But… Who does this?
@toddlmontgomery
Request Response
Stream
News, Stocks, Texts/SMS, Video, Audio, Social, …
Ingest
Temperature, Heart Rate, Web Logs, Sensor Data, Seismic Readings, Steps, Stairs, Gyro Data, GPS, Acceleration, Breathing, EKG, EEG, …
Request Response
Stream & Ingest
Pretty much how everything actually works…
Message Message
Request, Response, Stream, and Ingest are really types Message-Driven Message-Driven
Message Driven Responsive Resilient Elastic
http://www.reactivemanifesto.org/
REST RPC Function Call Message-Driven LISP
@toddlmontgomery
http://en.wikipedia.org/wiki/Hyper_Text_Coffee_Pot_Control_Protocol
"there is a strong, dark, rich requirement for a protocol designed espressoly [sic] for the brewing of coffee"
@toddlmontgomery
courtesy of
Sometimes it is good to reinvent the wheel
@toddlmontgomery
Multi-Lingual (and Polyglot) Multi-Protocol & Multi-Standard Multi-“Platform” Huge Scale Highly Integrated
Multi-Lingual (and Polyglot) Location Transparency Multi-Protocol & Data Format Basic Low-Level API
Protocols
Nuklei
Deployment Container
Logic
Reactive Message Stream
Depends on language, runtime, platform, etc. Asynchronous Binary “Loose” Ordering
Protocols
Nuklei Logic
Reactive Message Stream
Asynchronous Binary Boundary Basic read/write API Various Protocol Options
Choice of protocols becomes deployment concern
Deployment Container
Simple, consistent usage allows functional composition of protocols
Shared Memory IPC WebSocket JMS WebRTC
Not just in the traditional sense…
HTTP /1.1 MQTT HTTP /2 AMQP CoAP TCP /UDP /IP Aeron 0MQ
@toddlmontgomery
pro·to·col noun \ˈprō-tə-ˌkȯl, -ˌkōl, -ˌkäl, -kəl\
formatting of data in an electronic communications system <network protocols> ... 3 a : a code prescribing strict adherence to correct etiquette and precedence (as in diplomatic exchange and in the military services) <a breach of protocol>
@toddlmontgomery
@toddlmontgomery
e.g. HTTP over TCP looks same as HTTP over IPC or HTTP over WebSocket or HTTP over JMS e.g. Streams over Messages is a form of Fragmentation/ Reassembly Packet/Frame is common building block (Ethernet, ATM, etc.) Layering becomes natural &
boundaries & decoupling
Not New
@toddlmontgomery
JSON FIX / SBE CBOR YAML XML JMS Message
Divorced from Data Association
Map<> and other native associations are better than format specific APIs
HPACK
@toddlmontgomery
Thing 1 Thing 2
Not a human Also, …not a human Does not need to be human readable
http://tools.ietf.org/html/rfc7049
Concise Binary Object Representation (CBOR) FIX / Simple Binary Encoding (SBE)
https://github.com/real-logic/simple-binary-encoding
HPACK (Part of HTTP /2) …
@toddlmontgomery
URIs - Just, but not only Strings https://www.ietf.org
Think about how much context this contains!
Define an Endpoint for Connectivity Simple, Natural, & Familiar
@toddlmontgomery
Deployment Container docker, AWS, VM, … Leverage Binding & Resolution to decouple Migration Endpoint can be anywhere
OS level isolation, don’t duplicate at the application layer
VM AMI App Server
@toddlmontgomery
“Common” Message/Packet/Frame -based BSD Sockets has it right
From an old protocol hacker…
@toddlmontgomery
★ Address = String ★ Service Logic = Lambda
Endpoint Because they should be that simple
@toddlmontgomery
@FunctionalInterface public interface Mikro { void onMessage( Object header, int typeId, AtomicBuffer buffer, int offset, int length); }
Previous Protocol Flyweight ByteBuffer
@toddlmontgomery
Struct Overlays Semi-Stateful Parsers Know how to access fields efficiently Prefer to access via dead reckoning (stateless)
@toddlmontgomery
★ Proxy = Resolve(Address) ★ Proxy.send(Data)
From anything, not just another Service
For Efficiency, Reuse, and Caching
@toddlmontgomery
@FunctionalInterface public interface Proxy { int send( int typeId, AtomicBuffer buffer, int offset, int length); }
ByteBuffer
@toddlmontgomery
Flow Control… Security… Schedulers… Polyglot?…
Think Packet Scheduling? Java, then JavaScript, C, iOS, Not an afterthought Also, not an afterthought
Message Message
@toddlmontgomery