Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Goを使ったセンサーデータ収集基盤の事例のお話 / golang.tokyo 26 LT
Search
Takeshi Shinoda
September 25, 2019
Programming
0
760
Goを使ったセンサーデータ収集基盤の事例のお話 / golang.tokyo 26 LT
golang.tokyo #26 LT
https://golangtokyo.connpass.com/event/147175/
Takeshi Shinoda
September 25, 2019
Tweet
Share
More Decks by Takeshi Shinoda
See All by Takeshi Shinoda
多様なプロトコルと 駆動モデルをサポートするIoTゲートウェイの開発と運用の知見
takesinoda
1
940
API Gateway / Lambda / Kinesis を使ったストリーミングなバッチ実行基盤の実装
takesinoda
12
8.4k
捨てて開発できるチームづくり
takesinoda
50
15k
Rubyを始点としてもう一つのエンタープライズ開発を続けたあるSIerの事例 - Oedo RubyKaigi 03 Edition
takesinoda
2
3.2k
エンタープライズ開発にもう一つの文化を
takesinoda
4
10k
Rubyを始点としてもう一つのエンタープライズ開発を続けたあるSIerの事例
takesinoda
5
3.9k
Introduction of thinreports-rails
takesinoda
6
2.4k
Other Decks in Programming
See All in Programming
Laravel OpenAPIによる"辛くない"スキーマ駆動開発
kentaroutakeda
2
2.1k
ファイル先頭の use の意味、説明できますか? 〜PHP の namespace と autoloading の関係を正しく理解しよう〜 / namespace and autoloading in php
okashoi
2
470
導入から5年が経って見えた Datadog APM 運用の課題
bgpat
2
540
マイ隙間家具OSSたちのご紹介
karupanerura
2
160
イベントストーミングによるオブジェクトモデリング・オブジェクト指向プログラミングの適用・開発プロセスの変遷・アーキテクチャの変革 / Object modeling with Event Storming.
nrslib
12
3.2k
Crafting a Own PHP - ウキウキ手作りミニマリストPHP
uzulla
4
1.1k
Creating Retro-Style Photos Using Swift
ski
1
370
WinUI 3デモ - "CommunityToolkit.Mvvm"NuGetパッケージ編
andrewkeepcoding
0
140
孤独のCTOグルメという やや奇抜な企画をやった目的と効果
shoheimitani
3
1k
TCA魔法学入門🪄
dazy
0
280
どうしてこうなった命名集 ~🔥編~ / OOC 2024 LT
pictiny
4
2.9k
Parallel Socket Communication in Swift
s_shimotori
0
260
Featured
See All Featured
ReactJS: Keep Simple. Everything can be a component!
pedronauck
657
120k
Making the Leap to Tech Lead
cromwellryan
123
8.4k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
34
8.8k
Writing Fast Ruby
sferik
619
59k
Docker and Python
trallard
33
2.6k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
355
22k
The MySQL Ecosystem @ GitHub 2015
samlambert
242
12k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
18
1.7k
The Brand Is Dead. Long Live the Brand.
mthomps
48
22k
Design by the Numbers
sachag
274
18k
Building Effective Engineering Teams - LeadDev
addyosmani
25
1.8k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
12
1.4k
Transcript
GoΛͬͨ ηϯαʔσʔλऩूج൫ ͷ ࣄྫͷ͓ @takeshinoda
ࣗݾհ • ࣰా ݈ (͠ͷͩ ͚ͨ͠) • @takeshinoda • MODE,
Inc ۈ • ීஈRubyist • னGoͱTypeScriptॻ͍ͯ·͢ • Go݁ߏ͖
MODE, Inc. • γϦίϯόϨʔʹͯ2014ۀ • B2BͳIoTج൫Λఏڙ • ϦΞϧͷσʔλऩू • ϦΞϧσʔλͬͨϏδωεͷ͓ख͍
None
ϓϩμΫγϣϯͷ͓ख͍ MODE Ϋϥυ ࣌ܥྻ DB WebHook Πϕϯτج൫ OTA (Over-the-Air) ϩάऩू
σόΠεཧ ೝূ Users / Devices / API access MODE ήʔτΣΠ MODE αʔϏε ϏδωεɾۀαʔϏε ݱ࣮σʔλ ηϯαʔ/֤छػثσʔλ ͜͜ͷϨΠϠʔʹରͯ͠ PoCϨϕϧ͔Β ϓϩμΫγϣϯϨϕϧ·Ͱͷ ٕज़Λఏڙ͢Δ
MODE Ϋϥυ MODE ήʔτΣΠ MODE αʔϏε Ϣʔβʔɾఏܞاۀ ݱ࣮ੈք Sensor Cloud
Mobility Cloud Factory Cloud ࣌ܥྻ DB ࣌ܥྻ DB/SDS ࣌ܥྻ DB
MODE Gateway PLC Bluetooth MODbus GPS OBD-II ControllerPC RS-485 Bluetooth
LE MODbus/RTU NMEA 0183 CANbus / ISO9141-2 Smb protocol MODE Platform Application TSDB Event Dispatcher Manage Devices OTA Update Authentica tion Application MQTT REST API REST API
MODE Gateway PLC Bluetooth MODbus GPS OBD-II ControllerPC RS-485 Bluetooth
LE MODbus/RTU NMEA 0183 CANbus / ISO9141-2 Smb protocol MODE Platform Application TSDB Event Dispatcher Manage Devices OTA Update Authentica tion Application MQTT REST API REST API Go: Gateway, Server side TypeScript: Frontend, Gateway
Gateway OS: Ubuntu 16.04, 18.04, Yocto… Gateway main process Node
process WiFi / 3G OTA Updater Log collector
GoIoTͰศར Intel, ARM Ubuntu, Yocto Intel NUC, VIA, OpenBlocks, etc…
GoIoTͰศར • ࠷ॳظES6 • ΫϩείϯύΠϧͷखؒͷ • ඇಉظσʔλ௨৴ͷ੍ޚͷ؆ศ͞ • select, channel,
goroutine • σϓϩΠͷ؆ศ͞ • ͜ͷྖҬͷ؆ศ͞ͱͦͦ͜͜ศརͳܕ
Server side ඇಉظॲཧͱ ಉظॲཧ͕ࠞͬͯ͟Δ Gateway Eventॲཧ ࠶ૹॲཧ ࠶ଓॲཧ Event όοϑΝϦϯά
Command Synced data
GoIoTͰศར • ඇಉظ෦channelͱgoroutine • ಉظ෦௨ৗͷίʔυ • channelͱselect͕ͳ͍߹ɺͨ͘͞ΜͷΠϕ ϯτۦಈͰσʔλ͕ൃੜ͢ΔσʔλΛඇಉظ ॲཧͰॻ͘ͷ͕େม •
nodeEventEmitterͳͲͰద͍ͯͨ͠ • ֤छGWσϓϩΠͷ؆ศ͞ͱσόοάͷ؆ศ ͞ͰGo͕࠾༻͞Εͨ
Πϕϯτൃੜॲཧ TS for await (const sensorData of sensorModule.dataIterator()) { try
{ await timeout(dataSender.sendData(sensorData), timeout); } catch (error) { logger.error(`Failed: ${error}`); } } async* dataIterator(): AsyncIterable<SensorData[]> { while (true) { let sensorData: SensorData[]; try { sensorData = await this.next(); } catch (error) { throw error; // break loop } yield sensorData; } }
Πϕϯτൃੜॲཧ Go select { case l := <- serial.Rx: return
string(l), nil case <-time.After(timeout): return "", errors.New(“readtimeout”) } for { buf := make([]bytes, 1024) if _, err := s.Read(buf); err != nil { … } serial.Rx <- buf }
GoIoTͰศར • Ͳ͕ͬͪྑ͍͔͍͘͢͝͠ • ͲͬͪͳΜͱ͔ͳΔ • nodeGoඇಉظॲཧ༏ल • ݸਓతʹGoͷํ͕҆৺ •
TSతͳॻ͖ํʹ׳Εͯͳ͍ͷͪΖΜ͋Δ • ͔͠͠nodeͰΔͱ͖ʹTS҆͘͢͝৺
ͭ͠Μ
͋Γ͕ͱ͏ ͍͟͝·ͨ͠