Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Goを使ったセンサーデータ収集基盤の事例のお話 / golang.tokyo 26 LT
Takeshi Shinoda
September 25, 2019
Programming
0
600
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
API Gateway / Lambda / Kinesis を使ったストリーミングなバッチ実行基盤の実装
takesinoda
12
7.8k
捨てて開発できるチームづくり
takesinoda
50
14k
Rubyを始点としてもう一つのエンタープライズ開発を続けたあるSIerの事例 - Oedo RubyKaigi 03 Edition
takesinoda
2
3.1k
エンタープライズ開発にもう一つの文化を
takesinoda
4
9.7k
Rubyを始点としてもう一つのエンタープライズ開発を続けたあるSIerの事例
takesinoda
5
3.8k
Introduction of thinreports-rails
takesinoda
6
2.3k
Other Decks in Programming
See All in Programming
社会人 20 年目エンジニア、発信で技術学びなおしてる話
e99h2121
1
140
Amazon QuickSightのアップデート -re:Invent 2022の復習&2022年ハイライト-
shogo452
0
220
domain層のモジュール化 / MoT TechTalk #15
mot_techtalk
0
110
Quarto Tips for Academic Presentation
nicetak
0
930
Becoming an Android Librarian (Android World Wide 2023 Jan)
skydoves
1
200
xarray-Datatree: Hierarchical Data Structures for Multi-Model Science
tomnicholas
0
220
PHPDocにおける配列の型定義を少し知る
shimabox
1
140
Most Valuable Bug(?) ~インシデント未遂から得た学び~
tatsumiakahori
0
150
10年以上続くプロダクトの フロントエンド刷新プロジェクトのふりかえり
yotahada3
2
340
LIFFで動く割り勘アプリTATEKAをリリースしてみた話
inoue2002
0
250
Hatena Engineer Seminar #23「新卒研修で気軽に『ありがとう』を伝え合える Slack アプリを開発した話」
slashnephy
0
290
AWS App Runnerがそろそろ本番環境でも使い物になりそう
n1215
PRO
0
1.1k
Featured
See All Featured
Git: the NoSQL Database
bkeepers
PRO
419
60k
Thoughts on Productivity
jonyablonski
49
2.7k
Done Done
chrislema
178
14k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
182
15k
Building Applications with DynamoDB
mza
85
5k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
109
16k
Why Our Code Smells
bkeepers
PRO
326
55k
WebSockets: Embracing the real-time Web
robhawkes
58
6k
Clear Off the Table
cherdarchuk
79
290k
In The Pink: A Labor of Love
frogandcode
132
21k
Ruby is Unlike a Banana
tanoku
93
9.5k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
152
13k
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҆͘͢͝৺
ͭ͠Μ
͋Γ͕ͱ͏ ͍͟͝·ͨ͠