Skip to content

リファクタリング Phase 2: 設計改善(DI / ENV集約)#87

Merged
limit7412 merged 2 commits into
masterfrom
refactor/phase-2-design
Jun 15, 2026
Merged

リファクタリング Phase 2: 設計改善(DI / ENV集約)#87
limit7412 merged 2 commits into
masterfrom
refactor/phase-2-design

Conversation

@limit7412

Copy link
Copy Markdown
Owner

Part of #84(3分割 PR の 2/3)

⚠️ base は refactor/phase-1-idioms(PR #86)。Phase 1 マージ後に base を master へ切り替えるか、#86 → 本PR の順でマージしてください。

設計面の改善。挙動は不変

  • Github::NotificationsGithub::Notification(1件を表すため単数形)
  • Github::UsecaseNotificationRepository をコンストラクタ注入し、attachment 1件ごとに HTTP::Client を生成していた N+1 を解消
  • ENV 参照を main.cr(composition root)に集約し起動時に解決。各 usecase は依存をコンストラクタで受け取る
  • Slack::PostRepository@uri のみ保持、send_attachmentsend_attachments へ委譲

検証: crystal build 成功。

🤖 Generated with Claude Code

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the codebase to use dependency injection across use cases and repositories, moves environment variable resolution to startup in src/main.cr, and renames Github::Notifications to Github::Notification. Feedback focuses on performance improvements: first, instantiating repositories and use cases outside of the Lambda handler in src/main.cr to leverage warm starts; second, maintaining an HTTP::Client instance in Slack::PostRepository to enable connection reuse and keep-alive.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/main.cr
Comment thread src/slack/repository.cr
@limit7412 limit7412 force-pushed the refactor/phase-2-design branch from f86ca5f to 819971c Compare June 15, 2026 06:13
@limit7412 limit7412 force-pushed the refactor/phase-1-idioms branch from de50b63 to f704124 Compare June 15, 2026 06:29
@limit7412 limit7412 force-pushed the refactor/phase-2-design branch from 819971c to bbc54ea Compare June 15, 2026 06:29
Base automatically changed from refactor/phase-1-idioms to master June 15, 2026 06:42
limit7412 added a commit that referenced this pull request Jun 15, 2026
Address review feedback on PR #87:
- main.cr: instantiate repositories and usecases once at cold start (module
  scope) instead of per-invocation, so they are reused across warm Lambda
  invocations
- Slack::PostRepository: hold a persistent HTTP::Client and reuse it, enabling
  keep-alive connection reuse (matches the existing Github repository pattern)

refs #84

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
limit7412 added a commit that referenced this pull request Jun 15, 2026
Address review feedback on PR #87:
- main.cr: instantiate repositories and usecases once at cold start (module
  scope) instead of per-invocation, so they are reused across warm Lambda
  invocations
- Slack::PostRepository: hold a persistent HTTP::Client and reuse it, enabling
  keep-alive connection reuse (matches the existing Github repository pattern)

refs #84

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@limit7412 limit7412 force-pushed the refactor/phase-2-design branch from a697d1b to 7d39fb7 Compare June 15, 2026 06:50

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a697d1b8ad

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/main.cr
limit7412 and others added 2 commits June 15, 2026 15:53
- rename Github::Notifications -> Github::Notification (singular)
- inject NotificationRepository into Github::Usecase to remove per-attachment
  HTTP::Client creation (N+1)
- centralize ENV access in main.cr (composition root); usecases receive
  dependencies via constructor
- Slack::PostRepository keeps only @uri; send_attachment delegates to
  send_attachments

refs #84

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Address review feedback on PR #87:
- main.cr: instantiate repositories and usecases once at cold start (module
  scope) instead of per-invocation, so they are reused across warm Lambda
  invocations
- Slack::PostRepository: hold a persistent HTTP::Client and reuse it, enabling
  keep-alive connection reuse (matches the existing Github repository pattern)

refs #84

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@limit7412 limit7412 force-pushed the refactor/phase-2-design branch from 7d39fb7 to 9c68868 Compare June 15, 2026 06:54
@limit7412 limit7412 merged commit 5e9d913 into master Jun 15, 2026
1 check passed
@limit7412 limit7412 deleted the refactor/phase-2-design branch June 15, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant