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 で言うところのアレは TypeScript で言うとコレ / Kyoto.なんか #7
Search
Susisu
August 23, 2025
Technology
2.8k
7
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Go で言うところのアレは TypeScript で言うとコレ / Kyoto.なんか #7
Kyoto.なんか #7
https://kyoto-nanka.connpass.com/event/365370/
Susisu
August 23, 2025
More Decks by Susisu
See All by Susisu
Stage 3 Decorators でできること / できないこと / TSKaigi 2026
susisu
1
1.8k
君だけのオリジナル async / await を作ろう / TSKaigi 2025
susisu
20
15k
null or undefined
susisu
25
7.9k
Mackerel のフロントエンドフレームワーク移行 序章 / Hatena Engineer Seminar #13
susisu
0
2.3k
スクリーンショット撮影のために Puppeteer を操る / Kyoto.js 16
susisu
0
980
BuckleScript 使ってみた
susisu
0
420
Atom パッケージ開発のすゝめ
susisu
1
2.3k
5分でわかる Curry–Howard 同型対応
susisu
0
1.2k
ジェネレータを有効活用し隊 / Kyoto.js 11 LT
susisu
2
2.3k
Other Decks in Technology
See All in Technology
Oracle Exadata Database Service on Cloud@Customer X11M (ExaDB-C@C) サービス概要
oracle4engineer
PRO
2
8.3k
組織における AI-DLC 実践
askul
0
300
認証認可だけじゃない! ID管理の構成要素と ライフサイクルを意識しよう
ritou
1
460
AIエージェントとPhysical AIが拓く製造業の変革(ハノーバーメッセリキャップ)
iotcomjpadmin
0
210
“ID沼入口” - 基本とセキュリティから始める、考え続けるためのID管理技術勉強会 告知&イントロ
ritou
0
380
GitHub Copilot運用のリアル ~AI Credit時代にどう向き合うか~
takafumisu2uk1
0
620
Why is RC4 still being used?
tamaiyutaro
0
280
知見・人・API・DB・予算 ─ ナイナイ尽くしだった人事データ整備 with dbt、5年間の学び
ken6377
1
140
SRE歴2ヶ月でも開発6年の知見を活かして、チームで止まっていた環境改善を前に進めた話
a_ono
0
180
攻撃者がいなくてもAIエージェントはインシデントを起こす
nomizone
0
190
初めてのDatabricks勉強会
taka_aki
2
230
“全部コピーしない”ファイルデータの活用 : — FSx for ONTAP × S3 Tables × Icebergで作るメタデータカタログ
yoshiki0705
0
330
Featured
See All Featured
Faster Mobile Websites
deanohume
310
32k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
240
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
6k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
640
Optimising Largest Contentful Paint
csswizardry
37
3.8k
Skip the Path - Find Your Career Trail
mkilby
1
160
We Are The Robots
honzajavorek
0
260
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.5k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
120k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
480
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
340
Transcript
id:susisu / 2025-08-23 Kyoto.ͳΜ͔ #7 GoͰݴ͏ͱ͜ΖͷΞϨ TypeScriptͰݴ͏ͱίϨ
None
None
࠷ۙॻ͍ͨTypeScript
࠷ۙॻ͍ͨTypeScriptʢ̍ʣ • ಠཱͳ worker Λෳىಈͯ͠δϣϒΛॲཧͯ͠Β͏ main workerα workerβ workerγ ⋮
δϣϒΛΤϯΩϡʔ
࠷ۙॻ͍ͨTypeScriptʢ̍ʣ • main ͷऴྃ࣌ʹ worker ॲཧதͷδϣϒ͕ऴΘΓ࣍ୈఀࢭͤ͞Δ main workerα workerβ workerγ
⋮ ܬͷޫ SIGTERM
• API αʔόʔ͔ΒͷετϦʔϜΛӬଓԽͭͭ͠ΫϥΠΞϯτʹฦ͢ app server ࠷ۙॻ͍ͨTypeScriptʢ̎ʣ req handler worker API
server DB client ϦΫΤετ ϦΫΤετ ىಈ
• API αʔόʔ͔ΒͷετϦʔϜΛӬଓԽͭͭ͠ΫϥΠΞϯτʹฦ͢ app server ࠷ۙॻ͍ͨTypeScriptʢ̎ʣ req handler worker API
server DB client Ϩεϙϯε Ϩεϙϯε ӬଓԽ Ϩεϙϯε
• ΫϥΠΞϯτ్͕தͰஅ͞ΕͯӬଓԽͳͲͷॲཧଓ͚Δ app server ࠷ۙॻ͍ͨTypeScriptʢ̎ʣ req handler worker API server
DB client X X ӬଓԽ Ϩεϙϯε
app server req handler worker API server DB client X
X ӬଓԽ Ϩεϙϯε main workerα workerβ workerγ ⋮ ܬͷޫ SIGTERM Go͔ʁ
͍͔ʹGoͰॻ͖ͦ͏ • ಠཱͨ͠ worker → goroutine • தஅγάφϧͷ → context
• worker ؒͷσʔλૹड৴ → channel
TypeScriptͰͲ͏͢Δʁ • ಠཱͨ͠ worker → ? • தஅγάφϧͷ → ?
• worker ؒͷσʔλૹड৴ → ?
goroutine • ܰྔεϨου, ฒߦɾฒྻॲཧ go func() { time.Sleep(time.Second) fmt.Println("Pong") }()
fmt.Println("Ping") // Ping // (1s) // Pong
goroutine → async function • ϚϧνεϨου͕ཉ͍͠ͳΒ Web Workers ͳͲ͕ඞཁ͚ͩͲ (async
function() { await setTimeout(1000); console.log("Pong"); })(); console.log("Ping"); // Ping // (1s) // Pong
context • தஅγάφϧͷ ctx, cancel := context.WithCancel(context.Background()) startWorker(ctx) // ...
cancel()
context → AbortController • DOM Standard Ͱఆٛ͞Ε͍ͯΔ AbortController ͕͑Δ const
ac = new AbortController(); startWorker(ac.signal); // ... ac.abort();
context • ϦΫΤετείʔϓͷͷʹΘΕΔ ctx := context.WithValue(context.Background(), "requestId", "c0ffee") handler(ctx) //
handler: ctx.Value("requestId") // = "c0ffee"
context → ? • ୯ʹΦϒδΣΫτΛҾͰ͢ͷ͕جຊ͚ͩͲ... const ctx = { requestId:
"c0ffee" }; handler(ctx); // handler: ctx.requestId; // = "c0ffee"
context → AsyncLocalStorage • ҾΛ͢ͷ͕͍࣌͠ AsyncLocalStorage (ඇඪ४) ͕ศར͔ const storage
= new AsyncLocalStorage<{ requestId: string }>(); const ctx = { requestId: "c0ffee" }; storage.run(ctx, () => { handler(); }); // handler: storage.getStore()?.requestId; // = "c0ffee"
channel • goroutine ؒͷσʔλͷૹड৴ c := make(chan int) go func()
{ for n := 0; n < 10; n++ { c <- n } close(c) }() for n := range c { fmt.Println(n) } // 0, 1, 2, ..., 9
channel → Streams • Streams API ͰࣅͨΑ͏ͳ͜ͱ͕Ͱ͖·͢ const { readable,
writable } = new TransformStream<number, number>(); (async function() { const writer = writable.getWriter(); for (let n = 0; n < 10; n++) { await writer.write(n); } await writer.close(); })(); for await (const n of readable) { console.log(n); } // 0, 1, 2, ..., 9
channel • ͪͳΈʹऴྃΛ͚ͭͩͳΒ c := make(chan struct{}) go func() {
// ... close(c) }() // ... <-c
channel → await • await ͰΑ͍Ͱ͢Ͷ const promise = (async
function() { // ... })(); // ... await promise;
·ͱΊʢ̍ʣ • Go Ͱݴ͏ͱ͜ΖͷΞϨ TypeScript Ͱݴ͏ͱίϨ • goroutine → async
function • context → AbortController, AsyncLocalStorage • channel → Streams ͳͲ
·ͱΊʢ̎ʣ • TypeScript Λॻ͍͍ͯͯৗʹ TypeScript Ͱߟ͍͑ͯΔΘ͚Ͱͳ͍ • ࣮ࡍߟ͍͑͢ݴޠϝϯλϧϞσϧͬͯߟ͍͑ͯΔ • ࠓճͨ·ͨ·
Go ͬΆ͔ͬͨ • ৭ʑ͍ͬͯΔͱศར