Claude Codeで非同期ジョブパターンを設計する:長時間処理の非同期化・ポーリング・Webhook通知

はじめに 「PDF生成処理が30秒かかってタイムアウトする」「レポート生成中にユーザーが待ちきれず何度もボタンを押す」——長時間処理を非同期ジョブとして切り出し、ポーリングまたはWebhookで完了を通知する設計をClaude Codeに生成させる。 CLAUDE.mdに非同期ジョブパターン設計ルールを書く ## 非同期ジョブパターン設計ルール ### ジョブ登録 - 長時間処理(>2...

By · · 1 min read
Claude Codeで非同期ジョブパターンを設計する:長時間処理の非同期化・ポーリング・Webhook通知

Source: DEV Community

はじめに 「PDF生成処理が30秒かかってタイムアウトする」「レポート生成中にユーザーが待ちきれず何度もボタンを押す」——長時間処理を非同期ジョブとして切り出し、ポーリングまたはWebhookで完了を通知する設計をClaude Codeに生成させる。 CLAUDE.mdに非同期ジョブパターン設計ルールを書く ## 非同期ジョブパターン設計ルール ### ジョブ登録 - 長時間処理(>2秒)は非同期ジョブに変換 - 即座にジョブIDを返す(202 Accepted) - ジョブIDでステータスをポーリング可能 ### ステータス管理 - PENDING → RUNNING → COMPLETED / FAILED - 実行中は進捗率(0-100%)も提供 - 失敗時はエラー詳細を記録 ### 通知 - ポーリング: GET /jobs/{id} でステータス確認 - Webhook: 完了時にクライアントのURLにPOST - SSE: クライアントが接続中はリアルタイムでプッシュ 非同期ジョブ実装の生成 非同期ジョブシステムを設計してください。 要件: - ジョブキューとワーカー - ステータスポーリングAPI - Webhook通知 - 進捗追跡 生成ファイル: src/jobs/ 生成される非同期ジョブ実装 // src/jobs/jobManager.ts — ジョブ管理 export type JobStatus = 'pending' | 'running' | 'completed' | 'failed'; export interface Job<TInput = unknown, TOutput = unknown> { id: string; type: string; status: JobStatus; input: TInput; output?: TOutput; progress: number; // 0-100 errorMessage?: string; createdAt: Date; startedAt?: Date; completedAt?: Date; webhookUrl?: string; // 完了時の通知先 } export class JobManager { // ジョブを登録(即座にIDを返

Related Posts

Similar Topics

#ai (35)#webdev (21)#fix (18)#feat (18)#javascript (15)#opensource (13)#chore (10)#mcp (9)#api (9)#large language models (4)#programming (6)#react (6)#security (6)#backbonejs (6)#css (6)#node (6)#modernization (6)#nextjs (6)#es6 (6)#tutorial (6)

Trending on ShareHub

  1. Understanding Modern JavaScript Frameworks in 2026
    by Alex Chen · Feb 12, 2026 · 0 likes
  2. The System Design Primer
    by Sarah Kim · Feb 12, 2026 · 0 likes
  3. Just shipped my first open-source project!
    by Alex Chen · Feb 12, 2026 · 0 likes
  4. OpenAI Blog
    by Sarah Kim · Feb 12, 2026 · 0 likes
  5. Building Accessible Web Applications: A Practical Guide
    by Alex Chen · Feb 12, 2026 · 0 likes
  6. Rapper Lil Poppa dead at 25, days after releasing new music
    Rapper Lil Poppa dead at 25, days after releasing new music
    by Anonymous User · Feb 19, 2026 · 0 likes
  7. write-for-us
    by Volt Raven · Mar 7, 2026 · 0 likes
  8. Before the Coffee Gets Cold: Heartfelt Story of Time Travel and Second Chances
    Before the Coffee Gets Cold: Heartfelt Story of Time Travel and Second Chances
    by Anonymous User · Feb 12, 2026 · 0 likes
    #coffee gets cold #the #time travel
  9. Best DoorDash Promo Code Reddit Finds for Top Discounts
    Best DoorDash Promo Code Reddit Finds for Top Discounts
    by Anonymous User · Feb 12, 2026 · 0 likes
    #doordash #promo #reddit
  10. Premium SEO Services That Boost Rankings & Revenue | VirtualSEO.Expert
    by Anonymous User · Feb 12, 2026 · 0 likes
  11. NBC under fire for commentary about Team USA women's hockey team
    NBC under fire for commentary about Team USA women's hockey team
    by Anonymous User · Feb 18, 2026 · 0 likes
  12. Where to Watch The Nanny: Streaming and Online Viewing Options
    Where to Watch The Nanny: Streaming and Online Viewing Options
    by Anonymous User · Feb 12, 2026 · 0 likes
    #streaming #the nanny #where
  13. How Much Is Kindle Unlimited? Subscription Cost and Plan Details
    How Much Is Kindle Unlimited? Subscription Cost and Plan Details
    by Anonymous User · Feb 12, 2026 · 0 likes
    #kindle unlimited #subscription #unlimited
  14. Russian skater facing backlash for comment about Amber Glenn
    Russian skater facing backlash for comment about Amber Glenn
    by Anonymous User · Feb 18, 2026 · 0 likes
  15. Google News
    Google News
    by Anonymous User · Feb 18, 2026 · 0 likes

Latest on ShareHub

Browse Topics

#artificial intelligence (31571)#data science (24018)#ai (17153)#generative ai (15034)#crypto (15008)#machine learning (14681)#bitcoin (14257)#featured (13566)#news & insights (13064)#crypto news (11091)

Around the Network