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” …Reactively…
Request Response What most of us think happens
And if not, we’ll make it! Request Response What really happens
But… Who does this? Request Response What also really happens
User State Security Query (Challenge) Request Response Keep-Alive Support or Watchdog (UI/Device) @toddlmontgomery
News, Stocks, Texts/SMS, Video, Audio, Social, … Stream What also really happens
Temperature, Heart Rate, Web Logs, Sensor Data, Seismic Readings, Steps, Stairs, Gyro Data, GPS, Acceleration, Breathing, EKG, EEG, … Ingest What also really happens
Pretty much how everything actually works… Request Stream & Ingest Response What also really happens
What also REALLY happens
Request, Response, Stream, and Ingest are really types Message Message Message-Driven The Break Down Message-Driven
Message Driven Elastic Reactive Applications Responsive Resilient http://www.reactivemanifesto.org/
Distributed Systems Evolution Message-Driven REST LISP RPC Function Call
IoT…
HTCPCP RFC 2324, Extended by RFC 7168 "there is a strong, dark, rich requirement for a protocol designed espressoly [sic] for the brewing of coffee" http://en.wikipedia.org/wiki/Hyper_Text_Coffee_Pot_Control_Protocol @toddlmontgomery
@toddlmontgomery
courtesy of
Sometimes it is good to reinvent the wheel
What History Has Taught Us @toddlmontgomery
THE IoT Language!
THE IoT Protocol!
THE IoT Runtime!
THE IoT ______!
Multi-Lingual Multi-Protocol & (and Polyglot) Multi-Standard Internet of Things Huge Scale Multi-“Platform” Highly Integrated
Connected. Integrated. Great time to be a protocol geek!
Multi-Lingual Multi-Protocol (and Polyglot) & Data Format Nuklei Connected. Services. Tools. Location Basic Transparency Low-Level API
Deployment Container Logic Nuklei Reactive Message Stream Protocols Depends on language, Asynchronous runtime, platform, etc. Binary “Loose” Ordering
Simple, consistent usage Choice of protocols becomes allows functional deployment concern composition of protocols Deployment Container Logic Nuklei Reactive Message Stream Protocols Various Basic Protocol read/write Options API Asynchronous Binary Boundary
Shared Memory IPC JMS HTTP /1.1 MQTT TCP /UDP /IP Protocols? CoAP AMQP Not just in the traditional sense… Aeron 0MQ HTTP /2 WebSocket WebRTC
pro·to·col noun \ ˈ pr ō -t ə - ˌ k o ̇ l, - ˌ k ō l, - ˌ käl, -k ə l\ � ... � 3 b : a set of conventions governing the treatment and especially the 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
Protocols are the key to Integration REST has demonstrated this! @toddlmontgomery
Packet/Frame is common Layering becomes natural & building block (Ethernet, trivial. Also forces ATM, etc.) boundaries & decoupling Functional Protocol Composition Not New e.g. HTTP over TCP looks e.g. Streams over Messages same as HTTP over IPC or is a form of Fragmentation/ HTTP over WebSocket or Reassembly HTTP over JMS @toddlmontgomery
FIX / SBE CBOR HPACK JMS Data Format XML Message Divorced from Data Association Map<> and other native JSON YAML associations are better than format specific APIs @toddlmontgomery
Does not need to be human readable Thing 1 Thing 2 Not a human Also, …not a human Binary Encoding Concise Binary Object Representation (CBOR) FIX / Simple Binary Encoding (SBE) HPACK (Part of HTTP /2) … http://tools.ietf.org/html/rfc7049 https://github.com/real-logic/simple-binary-encoding @toddlmontgomery
Simple, Natural, Define an Endpoint & Familiar for Connectivity Addressing URIs - Just , but not only Strings https://www.ietf.org Think about how much context this contains! @toddlmontgomery
Deployment Container Endpoint can be docker, AWS, VM, … anywhere Isolation & Location Transparency Leverage Binding & Resolution to Migration decouple @toddlmontgomery
AMI Deployment Container VM App Server OS level isolation, don’t duplicate at the application layer
BSD Sockets has it right From an old protocol hacker… Basic Low-Level API “Common” Message/Packet/Frame -based @toddlmontgomery
Defining a Service Endpoint ★ Address = String ★ Service Logic = Lambda Because they should be that simple @toddlmontgomery
Previous Protocol @FunctionalInterface Flyweight public interface Mikro { void onMessage( Object header, int typeId, ByteBuffer AtomicBuffer buffer, int offset, on Steroids int length); } @toddlmontgomery
Struct Overlays Semi-Stateful Parsers Flyweights Know how to access fields efficiently Prefer to access via dead reckoning (stateless) @toddlmontgomery
Sending to a Service From anything, not just another Service For Efficiency, Reuse, and Caching ★ Proxy = Resolve(Address) ★ Proxy.send(Data) @toddlmontgomery
@FunctionalInterface public interface Proxy { int send( int typeId, ByteBuffer AtomicBuffer buffer, int offset, on Steroids int length); } @toddlmontgomery
Not an afterthought Also, not an afterthought Flow Control… Security… Additionally… Polyglot?… Schedulers… Java, then JavaScript, C, Think Packet Scheduling? iOS, @toddlmontgomery
Message Message To Sum Up
https://github.com/kaazing/nuklei Connected. Services. Tools. Very Early & Still Evolving
Questions? Kaazing http://www.kaazing.com • GitHub https://github.com/kaazing • Slideshare http://www.slideshare.com/toddleemontgomery • Twitter @toddlmontgomery • Thank You! @toddlmontgomery
Recommend
More recommend