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
920
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
1.3k
API Gateway / Lambda / Kinesis を使ったストリーミングなバッチ実行基盤の実装
takesinoda
12
8.9k
捨てて開発できるチームづくり
takesinoda
50
15k
Rubyを始点としてもう一つのエンタープライズ開発を続けたあるSIerの事例 - Oedo RubyKaigi 03 Edition
takesinoda
2
3.4k
エンタープライズ開発にもう一つの文化を
takesinoda
4
10k
Rubyを始点としてもう一つのエンタープライズ開発を続けたあるSIerの事例
takesinoda
5
4.1k
Introduction of thinreports-rails
takesinoda
6
2.6k
Other Decks in Programming
See All in Programming
5分で理解する SOLID 原則 #phpcon_nagoya
shogogg
1
320
仕様変更に耐えるための"今の"DRY原則を考える
mkmk884
9
3.2k
Formの複雑さに立ち向かう
bmthd
1
940
How mixi2 Uses TiDB for SNS Scalability and Performance
kanmo
41
16k
PRレビューのお供にDanger
stoticdev
1
230
CDKを使ったPagerDuty連携インフラのテンプレート化
shibuya_shogo
0
110
責務と認知負荷を整える! 抽象レベルを意識した関心の分離
yahiru
8
1.3k
一休.com のログイン体験を支える技術 〜Web Components x Vue.js 活用事例と最適化について〜
atsumim
0
1k
バッチを作らなきゃとなったときに考えること
irof
2
530
Bedrock Agentsレスポンス解析によるAgentのOps
licux
3
930
SwiftUI Viewの責務分離
elmetal
PRO
2
270
Rails 1.0 のコードで学ぶ find_by* と method_missing の仕組み / Learn how find_by_* and method_missing work in Rails 1.0 code
maimux2x
1
240
Featured
See All Featured
Bootstrapping a Software Product
garrettdimon
PRO
306
110k
Scaling GitHub
holman
459
140k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
193
16k
Making Projects Easy
brettharned
116
6k
Writing Fast Ruby
sferik
628
61k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
RailsConf 2023
tenderlove
29
1k
How to train your dragon (web standard)
notwaldorf
91
5.9k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.2k
Typedesign – Prime Four
hannesfritz
40
2.5k
Producing Creativity
orderedlist
PRO
344
40k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.3k
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҆͘͢͝৺
ͭ͠Μ
͋Γ͕ͱ͏ ͍͟͝·ͨ͠