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
520
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.5k
捨てて開発できるチームづくり
takesinoda
49
14k
Rubyを始点としてもう一つのエンタープライズ開発を続けたあるSIerの事例 - Oedo RubyKaigi 03 Edition
takesinoda
2
3k
エンタープライズ開発にもう一つの文化を
takesinoda
4
9.5k
Rubyを始点としてもう一つのエンタープライズ開発を続けたあるSIerの事例
takesinoda
5
3.7k
Introduction of thinreports-rails
takesinoda
6
2.3k
Other Decks in Programming
See All in Programming
WindowsコンテナDojo : 第1回 Visual StudioでWindowsコンテナアプリ作成
oniak3ibm
PRO
0
320
ebpfとWASMに思いを馳せる2022 / techfeed-conference-2022-ebpf-wasm-amsy810
masayaaoyama
0
460
Is Rust a great language for building Kubernetes ecosystem
deepu105
0
140
Git Rebase
bkuhlmann
7
1k
roadmap to rust 2024
matsu7874
1
590
近況PHP / PHP in now a days
uzulla
4
1.4k
About Type Syntax Proposal
quramy
1
900
microCMS × imgixを活用して品質とレスポンスを両立したポートフォリオサイトを作成した話
takehitogoto
0
390
脱オブジェクト指向講座(5分LT資料)
kishida
8
11k
Enterprise Angular: Frontend Moduliths with Nx and Standalone Components @jax2022
manfredsteyer
PRO
0
290
SRE NEXT 2022: Sensible Incident Management for Software Startups
takanabe
2
230
書籍『良いコード/悪いコードで学ぶ設計入門』でエンジニアリングの当たり前を変える
minodriven
3
1k
Featured
See All Featured
It's Worth the Effort
3n
172
25k
Building Adaptive Systems
keathley
25
1.1k
Infographics Made Easy
chrislema
233
17k
Web Components: a chance to create the future
zenorocha
303
40k
Keith and Marios Guide to Fast Websites
keithpitt
404
21k
The Brand Is Dead. Long Live the Brand.
mthomps
45
2.7k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
226
15k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
12
890
Documentation Writing (for coders)
carmenhchung
48
2.5k
Mobile First: as difficult as doing things right
swwweet
212
7.5k
Bootstrapping a Software Product
garrettdimon
295
110k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
237
19k
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҆͘͢͝৺
ͭ͠Μ
͋Γ͕ͱ͏ ͍͟͝·ͨ͠