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
TinyGoで使えるORM sqllaの 紹介とTinyGoで使えるようにするための工夫
Search
mackee
October 13, 2023
Programming
0
1.2k
TinyGoで使えるORM sqllaの 紹介とTinyGoで使えるようにするための工夫
Asakusa.go #1
https://asakusago.connpass.com/event/295512/
mackee
October 13, 2023
Tweet
Share
More Decks by mackee
See All by mackee
range over funcの使い道と非同期N+1リゾルバーの夢 / about a range over func
mackee
0
78
perl for shell, awk and sed programmers
mackee
2
1.5k
今更GoのWebフレームワークを作ろうとしているワケ / Why am I trying to create a Go web framework now?
mackee
1
69
マイクロサービス化を利用した Goへの移行事例
mackee
0
120
PerlでつくるフルスクラッチWebAuthn/パスキー認証 / Demonstration of full-scratch WebAuthn/Passkey Authentication written in Perl
mackee
3
3.3k
SRE定例やその辺の取り組みをアプリケーションエンジニア目線で語る / "Observe" about SRE Meeting by Application Engineer
mackee
0
1.8k
Go向けORM sqllaの紹介と JOINやUNIONを含んだクエリの扱い方
mackee
0
4.5k
デプロイ今昔物語 〜CGIからサーバーレスまで〜 / The deployment technics
mackee
10
12k
E2Eテストから負荷試験シナリオを作ってみた / Why do we make a scenario of load testing from E2E testing scenarios
mackee
3
5.5k
Other Decks in Programming
See All in Programming
17年周年のWebアプリケーションにTanStack Queryを導入する / Implementing TanStack Query in a 17th Anniversary Web Application
saitolume
0
240
Refactor your code - refactor yourself
xosofox
1
230
Java 23の概要とJava Web Frameworkの現状 / Java 23 and Java web framework
kishida
2
400
テスト自動化失敗から再挑戦しチームにオーナーシップを委譲した話/STAC2024 macho
ma_cho29
1
1.3k
Jakarta EE meets AI
ivargrimstad
0
1.3k
たのしいparse.y
ydah
3
120
layerx_20241129.pdf
kyoheig3
2
280
似たもの同士のPerlとPHP
uzulla
1
120
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
260
Go の GC の不得意な部分を克服したい
taiyow
2
730
物流システムにおけるリファクタリングとアーキテクチャの再構築 〜依存関係とモジュール分割の重要性〜
deeprain
1
1.2k
RWC 2024 DICOM & ISO/IEC 2022
m_seki
0
190
Featured
See All Featured
Art, The Web, and Tiny UX
lynnandtonic
298
20k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
5
440
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
48
2.2k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
32
2.7k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Embracing the Ebb and Flow
colly
84
4.5k
It's Worth the Effort
3n
183
28k
Making the Leap to Tech Lead
cromwellryan
133
9k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
VelocityConf: Rendering Performance Case Studies
addyosmani
326
24k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
270
Transcript
TinyGoͰ͑ΔORM sqllaͷ հͱTinyGoͰ͑ΔΑ͏ʹ ͢ΔͨΊͷ Asakusa.go #1 @mackee_w a.k.a
୭ • @mackee_w at Twitter(formally X), @mackee at GitHub •
໘ന๏ਓΧϠοΫ (ຊח͔Βདྷ·ͨ͠ʂ) • ISUCON11༏উ • ISUCON12༧બ ग़(SQLiteͷͭͰ͢) • ීஈPerlίϛϡχςΟͰΒ͍ͯ͠·͢ ͕ࣄ΄ͱΜͲGoͰ͢ • YAPC::Hiroshima͍ͬͯ͏Ξπ͍Πϕϯτ͕དྷ݄̎ʹ͋ΔͷͰདྷͯ͘Εʂʂʂ
TinyGoΛझຯͷΈࠐΈϓϩάϥϛϯάͰͬ ͍ͯ·͢
sqlla ͱ͍͏ORMΛ࡞͍ͬͯ·͢ • ΧϥϜʹରԠ͢Δϝ ιουΛੜͯ͠ SQLΛGoͷจ๏Ͱॻ ͚ΔΫΤϦϏϧμʔ • re fl
ectΛ༻͍ͳ͍ ίʔυੜʹΑΔ structϚοϐϯά ࣄͰ୲͍ͯ͠ΔWebαʔϏεͰࠓݩؾʹಈ͍͍ͯ·͢
࠷ۙͬͨτʔΫ https://speakerdeck.com/mackee/goxiang-keorm-sqllanoshao-jie-to-joinyaunionwohan- ndakuerinoxi-ifang
Cloud fl are D1
github.com/syumai/workersͰD1͕͑Δʂ
Ͱ͖ΕTinyGoͰಈ͔͍ͨ͠ • Of fi cial Go : 6105.21 KiB /
gzip: 1650.72 KiB • TinyGo: 2215.79 KiB / gzip: 769.47 KiB • Of fi cial Go Compiler൛ͩͱແྉͰΞοϓϩʔυͰ͖ͳ͍ • ※ํ՝͍ۚͯ͠·͢ɻ͓Ұਓ༷misskeyͷϑϩϯτʹஔ͍͍ͯΔ
ͱ͍͏͜ͱͰsqllaΛCloud fl are Workers + TinyGoͰಈ͔ͯ͠ΈΔ
DBεΩʔϚΛఆٛ
DBεΩʔϚΛఆٛ $ go generate ./
connectionΛ༻ҙ
Chatॻ͖ࠐΈΤϯυϙΠϯτΛ࣮
Chatॻ͖ࠐΈΤϯυϙΠϯτΛ࣮ ͍͍ͭͬͯΔ github.com/julienschmidt/httprouter ͕͑ͣ ࣗલͰศརwrapperΛ࣮͍ͯ͠·͢
Ұ୴Ϗϧυ…ग़དྷͣ
go-sql-driver/mysqlͷϥϯλΠϜͷґଘΛ֎͢ • sqllaੜ༻ͷίʔυͱϥϯλΠϜͰ͏ίʔυ͕Ұମʹͳ͍ͬͯΔ • ϥϯλΠϜίʔυͷҰ෦Ͱgo-sql-driver/mysqlΛimport͍ͯ͠Δ • mysql.NullTimeΛϚοϐϯά͢Δίʔυ(ޙํޓͷͨΊͯ͋͠Δ) • D1ͰΘͳ͍ͷͰɺͦͦϏϧυλάͰ֎͢ •
ͦͷଞίʔυੜͰ͔͠Θͳ͍ίʔυϏϧυλάΛ͚ͭΔ
go-sql-driver/mysqlͷϥϯλΠϜͷґଘΛ֎͢
go-sql-driver/mysqlͷϥϯλΠϜͷґଘΛ֎͢ ϏϧυͰ͖ΔΑ͏ʹ ͳͬͨʂ
΄ͳදࣔͰ͖Δ Α͏ʹ͠Α͔ʙ
΄ͳදࣔͰ͖Δ Α͏ʹ͠Α͔ʙ !! දࣔ͞Εͳ͍ !!
html/templateͰมճ͢ͱ͜ΖͰࢮΜͰ͍Δ • ͜Ε͔֬ʹre fl ect͏ͳ͋ • TinyGore fl ectsocket͏ܥَ͕ͳײ͡(ؒҧͬͯͨΒڭ͑ͯ͘ ͍ͩ͞)
• encoding/json ͑Δ
͓ͱͳ͘͠ JSONͰฦ͢ ΤϯυϙΠ ϯτ࡞ͬͯ fetchͰऔΔ Α͏ʹͨ͠
ಈ͘Α͏ʹͳΓ·ͨ͠
ͦͷଞࠔͬͨ͜ͱ • time.TimeΛͦͷ··insert͠Α͏ͱ͢Δͱࢮ͵ • தͰre fl ect͕ΘΕ͍ͯΔͨΊʁ `panic: ValueOf: invalid
value` • int64ʹม͍ͯ͠Δ • ϩʔΧϧϞʔυͩͱ`time.Now`͕ΊͪΌͪ͘Όڰ͍ͬͯΔ • ʆ2077-07-23 14:29:52.008999936 +0900 UTC+9 m=+3394243792.008999937ʆ
࣮ࠔ͍ͬͯΔ͜ͱ • Cloud fl are Workersʹdeploy͢ΔͱSELECT͕ࣦഊ͢Δ • `panic: syscall/js: Value.Call:
property close is not a function, got unde fi ned` • ެࣜGoίϯύΠϥͰࣦഊ͢Δ • લ௨ͬͯͨΑ͏ͳ… • INSERT௨Δ • (syumai͞Μʹ૬ஊ͍ͨ͠…)
Θ͋ʂ͜Μͳͷग़ͨʂ
Ҏ্ʂ