Skip to content

[REFAC#411] internal/publisher → internal/bus rename - #412

Merged
juhy0987 merged 3 commits into
mainfrom
refactor/#411/publisher-to-worker-bus
May 13, 2026
Merged

juhy0987 merged 3 commits into
mainfrom
refactor/#411/publisher-to-worker-bus

Conversation

@juhy0987

@juhy0987 juhy0987 commented May 13, 2026

Copy link
Copy Markdown
Member

연관 이슈

Closes #411

구현 내용

메타 #385 (Publisher 통합) 완료 직후 패키지 명명 정정. 도입 시점에 "publisher" 로 명명됐던 hub 패키지가 Kafka I/O 단일 진입점 + PriorityResolver chain + IngestionLock/PipelineGuard + RetryScheduler 등 다중 책임을 갖는 worker stage 간 중심 통로 (message bus) 로 진화함에 따라 명명 정정.

디렉토리 / 패키지 이동

internal/publisher/      → internal/worker/
test/internal/publisher/ → test/internal/worker/
  • 모든 파일 package publisherpackage worker
  • 진입점 파일 publisher.goworker.go (자체 doc 일관성)

호출처 import alias

internal/processor/fetcher/worker 와 같은 worker 이름이라 import 충돌. 호출처에서 bus alias 로 import:

import bus "issuetracker/internal/worker"

bus 단어 선정 근거: message bus 패턴의 표준 어휘. 여러 stage (fetcher / parser / validate) 가 발행/구독하는 중심 통로 역할을 직관적으로 표현. Kafka 도메인 고정 없이 의도적 추상화 방향 (Consumer/Message 별칭 등) 과 일관.

식별자 일괄 치환 (~25 호출처)

publisher.Xbus.X:

카테고리 식별자
Facade New, Publisher
인터페이스 별칭 Consumer, Message
Retry RetryScheduler, NewKafkaImmediateRetryScheduler, NewRedisDelayedRetryScheduler, RetrySchedulerHolder, RedisRetrySchedulerConfig, DefaultRedisRetrySchedulerConfig
PublishX 인터페이스 SeedPublisher, UpgradePublisher, JobPublisher
Priority routing CrawlTopic, NewCompositeResolver, ExplicitPriorityResolver, SourcePriorityResolver, RuleBasedPriorityResolver, PriorityResolver
Sentinel ErrPublishSkipped

CI / 머지 게이트 점검

  • gofmt -l internal/ cmd/ test/ pkg/ examples/ — clean
  • go build ./internal/... ./cmd/... ./pkg/... ./test/... ./examples/... — pass
  • go test -race -count=1 -timeout=180s ./test/... — 전 패키지 통과
  • PR 타이틀 [REFAC#411]
  • commit [REFAC]: prefix + 한국어

변경 영향 범위 + 위험도

  • 영향: 32 파일 (7 file rename + 12 rename in test/ + 25 importer 갱신)
  • 위험도 Low:
    • 순수 명명 정정 — 구현 / API / 동작 무변경
    • bus alias 일괄 적용으로 식별자 가독성 향상 (publisher 라는 다중 의미 단어 → bus 의 명확한 hub 역할)
    • 모든 기존 테스트 새 import 로 통과

후속

롤백 계획

PR revert 시 32 파일 동시 원복 — 디렉토리 / 패키지 / 호출처 모두 동시에 publisher 로 복귀.

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Refactor
    • Consolidated internal job publishing, retry scheduling, and priority resolution components into a unified worker package facade for improved code organization and consistency across the system.

Review Change Stack

…411)

메타 #385 (Publisher 통합) 완료 직후 패키지 명명 정정.

도입 시점에 \"publisher\" 로 명명됐던 hub 패키지가 Kafka I/O 단일 진입점 + PriorityResolver
chain + IngestionLock/PipelineGuard + RetryScheduler 등 다중 책임을 가진 worker stage 간
중심 통로 (message bus) 로 진화. 본질 (역할) 을 드러내는 worker 명명으로 정정.

## 디렉토리 / 패키지 이동

- internal/publisher/ → internal/worker/
- test/internal/publisher/ → test/internal/worker/
- 모든 파일 package 선언 publisher → worker
- 진입점 파일 publisher.go → worker.go (자체 doc 일관성)

## 호출처 alias

internal/processor/fetcher/worker 와 같은 worker 이름이라 import 충돌. 호출처에서
\`bus\` alias 로 import:

  import bus \"issuetracker/internal/worker\"

선정 근거: message bus 패턴의 표준 어휘. 여러 stage 가 발행/구독하는 중심 통로 역할 직관적
표현. Kafka 도메인 고정 없이 의도적 추상화 방향 (Consumer/Message 별칭 등) 과 일관.

## 식별자 일괄 치환

publisher.X → bus.X (~25 호출처):
- publisher.New / publisher.Publisher / publisher.Consumer / publisher.Message
- publisher.RetryScheduler / publisher.NewRedisDelayedRetryScheduler / publisher.RetrySchedulerHolder
- publisher.SeedPublisher / publisher.UpgradePublisher / publisher.JobPublisher (인터페이스)
- publisher.CrawlTopic / publisher.NewCompositeResolver / publisher.ExplicitPriorityResolver
- publisher.PriorityResolver / publisher.ErrPublishSkipped

## 검증

- go build ./internal/... ./cmd/... ./pkg/... ./test/... ./examples/... — pass
- go test -race -count=1 -timeout=180s ./test/... — 전 패키지 통과
- gofmt clean

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 13, 2026 06:31
@juhy0987 juhy0987 added the refactor Code refactoring label May 13, 2026
@coderabbitai

coderabbitai Bot commented May 13, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@juhy0987 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 50 minutes and 10 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a04e1ca9-d640-48a1-8cf4-9fe60768462d

📥 Commits

Reviewing files that changed from the base of the PR and between 094a4ca and c36161e.

📒 Files selected for processing (32)
  • cmd/issuetracker/main.go
  • cmd/processor/main.go
  • examples/kafka_pipeline/main.go
  • internal/bus/chain.go
  • internal/bus/guard.go
  • internal/bus/resolver.go
  • internal/bus/retry.go
  • internal/bus/seed.go
  • internal/bus/upgrade.go
  • internal/bus/worker.go
  • internal/processor/fetcher/domain/general/chain_handler.go
  • internal/processor/fetcher/domain/general/sources/registry.go
  • internal/processor/fetcher/domain/general/types.go
  • internal/processor/fetcher/domain/search/handler.go
  • internal/processor/fetcher/rule/upgrader.go
  • internal/processor/fetcher/worker/manager.go
  • internal/processor/fetcher/worker/pool.go
  • internal/processor/parser/worker/parser_worker.go
  • internal/processor/validate/worker.go
  • internal/scheduler/scheduler.go
  • internal/scheduler/throttle.go
  • test/internal/bus/publisher_gate_test.go
  • test/internal/bus/publisher_ingestion_lock_test.go
  • test/internal/bus/retry_test.go
  • test/internal/bus/seed_test.go
  • test/internal/bus/upgrade_test.go
  • test/internal/processor/fetcher/domain/general/chain_handler_chromedp_routing_test.go
  • test/internal/processor/fetcher/domain/general/chain_handler_reparse_propagation_test.go
  • test/internal/processor/fetcher/worker/pool_retry_scheduler_test.go
  • test/internal/processor/fetcher/worker/pool_test.go
  • test/internal/processor/parser/worker/helpers_test.go
  • test/internal/processor/validate/worker_test.go
📝 Walkthrough

Walkthrough

This PR renames the internal/publisher package to internal/worker with a bus import alias at all call sites. Core worker module files transition to the new package namespace, and 40+ affected files update their imports and type references accordingly. No functional logic or API signatures change—only package declarations, documentation, and caller-side alias applications.

Changes

Worker Package Rename and Core Abstractions

Layer / File(s) Summary
Worker package declarations and abstractions
internal/worker/worker.go, internal/worker/chain.go, internal/worker/guard.go, internal/worker/resolver.go, internal/worker/retry.go, internal/worker/seed.go, internal/worker/upgrade.go
Core worker module files transition from package publisher to package worker. Package-level documentation and usage examples updated to reflect worker namespace. All exported types (Consumer, Message, Publisher, PriorityResolver, RetryScheduler, SeedPublisher, UpgradePublisher) and their methods now belong to worker package.
Entry point wiring with bus facade
cmd/issuetracker/main.go, cmd/processor/main.go, examples/kafka_pipeline/main.go
Main orchestration entry points import internal/worker as bus alias. Crawler job publisher, priority resolvers, and retry schedulers constructed via bus.New(...), bus.NewCompositeResolver(...), and bus.NewRedisDelayedRetryScheduler(...); validate worker publisher similarly constructed via bus.New(...); pipeline example updated to use bus facade.
Chain handler and source registry wiring
internal/processor/fetcher/domain/general/chain_handler.go, internal/processor/fetcher/domain/general/sources/registry.go, internal/processor/fetcher/domain/general/types.go, internal/processor/fetcher/domain/search/handler.go
ChainHandler.Pub field and RegisterAll/buildHandler function parameters rettyped from *publisher.Publisher to *bus.Publisher. Imports updated to use bus alias. Documentation comments referencing publisher implementation updated to reference worker.Publisher.
Rule upgrader and parser worker wiring
internal/processor/fetcher/rule/upgrader.go, internal/processor/parser/worker/parser_worker.go
Upgrader struct and ParserWorker struct update to use bus.UpgradePublisher and bus.Consumer/*bus.Publisher. Constructors and struct field types updated. Imports switched to bus alias. Flow comments updated to reference bus.Publish.
Pool manager and retry scheduler wiring
internal/processor/fetcher/worker/manager.go, internal/processor/fetcher/worker/pool.go
PoolManager and KafkaConsumerPool update to use bus.Publisher, bus.Consumer, bus.PriorityResolver, bus.RetryScheduler. Constructor parameters and struct fields rettyped. Topic derivation switched from publisher.CrawlTopic(...) to bus.CrawlTopic(...); SetRetryScheduler and resolveRetryScheduler updated to work with bus scheduler types and create bus.NewKafkaImmediateRetryScheduler(...) when unconfigured.
Validate worker and scheduler migrations
internal/processor/validate/worker.go, internal/scheduler/scheduler.go, internal/scheduler/throttle.go
Validate worker struct/constructor updated to use bus.Consumer/*bus.Publisher. Scheduler struct/constructor updated to use bus.SeedPublisher, with error handling switched to check bus.ErrPublishSkipped. Throttler updated to use bus.CrawlTopic(...) for backlog topic lookup. All imports updated to bus alias.
Core worker tests
test/internal/worker/publisher_gate_test.go, test/internal/worker/publisher_ingestion_lock_test.go, test/internal/worker/retry_test.go, test/internal/worker/seed_test.go, test/internal/worker/upgrade_test.go
Test package declarations transitioned from publisher_test to worker_test. Publisher helper functions updated from publisher.New(...) to worker.New(...); retry scheduler test helpers now construct via worker.NewKafkaImmediateRetryScheduler(...) and worker.NewRedisDelayedRetryScheduler(...) with worker.DefaultRedisRetrySchedulerConfig(). Error assertions updated to check worker.ErrPublishSkipped.
Processor and fetcher integration tests
test/internal/processor/fetcher/domain/general/chain_handler_chromedp_routing_test.go, test/internal/processor/fetcher/domain/general/chain_handler_reparse_propagation_test.go, test/internal/processor/fetcher/worker/pool_retry_scheduler_test.go, test/internal/processor/fetcher/worker/pool_test.go, test/internal/processor/parser/worker/helpers_test.go, test/internal/processor/validate/worker_test.go
Test helper functions updated to construct publishers via bus.New(...) instead of publisher.New(...); imports updated to use bus alias for internal/worker. Retry scheduler test wires bus.NewRedisDelayedRetryScheduler(...) with bus.RedisRetrySchedulerConfig.

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly Related PRs

  • EinSofINTEREST/IssueTracker#400: Both PRs refactor fetcher/worker Kafka I/O wiring through a facade—this PR migrates those same PoolManager/KafkaConsumerPool and scheduler dependencies from internal/publisher to the new internal/worker bus.
  • EinSofINTEREST/IssueTracker#409: Both PRs modify cmd/issuetracker/main.go and PoolManager wiring to route priority resolution through the publisher/bus resolver chain.
  • EinSofINTEREST/IssueTracker#397: Both PRs modify internal/scheduler/scheduler.go to change the scheduler's publisher dependency wiring.

Suggested Labels

refactor

Poem

🐰 From publisher to bus we hop,
A naming bloom that'll never stop—
The worker stage finds clearer voice,
With alias wiring, our joyful choice,
No logic bends, just types we've brushed! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The PR meets all coding requirements from issue #411: internal/publisher→internal/worker package rename, test migration, bus alias application at ~25 call sites, and API stability maintained.
Out of Scope Changes check ✅ Passed All changes are scoped to package renaming, import alias updates, and associated documentation fixes. No unrelated functionality or behavioral modifications are present.
Docstring Coverage ✅ Passed Docstring coverage is 86.54% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The title '[REFAC#411] internal/publisher → internal/worker rename' accurately and concisely describes the main structural refactoring in the changeset, which is renaming the internal/publisher package to internal/worker.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/#411/publisher-to-worker-bus

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@juhy0987 juhy0987 self-assigned this May 13, 2026

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/processor/fetcher/domain/search/handler.go`:
- Around line 36-37: Update the inline comment that currently mentions
bus.Publish to reflect the actual API being called (PublishChained); locate the
comment near the fanout description in handler.go and replace
"bus.Publish(crawlerName=host, TargetTypeArticle)" with
"bus.PublishChained(crawlerName=host, TargetTypeArticle)" (or similar wording
matching the PublishChained signature) so the comment accurately describes the
code path and function name.

In `@internal/processor/parser/worker/parser_worker.go`:
- Around line 9-10: Update the inaccurate comments that reference bus.Publish to
reflect the actual fanout API: replace mentions of "bus.Publish" with
"PublishChained" in the parser_worker.go comment blocks (specifically the block
describing Category/TargetTypeCategory and the comment at lines ~92-93). Ensure
the comment text shows the correct fanout path (e.g., rule.Parser.ParseLinks →
PublishChained (chained jobs)) and keep the Article path wording consistent with
the real pipeline names (rule.Parser.ParsePage → ConvertPage → content store +
publish normalized).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 526bf137-65e4-4373-a2ea-446cfa937da3

📥 Commits

Reviewing files that changed from the base of the PR and between b30c635 and 094a4ca.

📒 Files selected for processing (32)
  • cmd/issuetracker/main.go
  • cmd/processor/main.go
  • examples/kafka_pipeline/main.go
  • internal/processor/fetcher/domain/general/chain_handler.go
  • internal/processor/fetcher/domain/general/sources/registry.go
  • internal/processor/fetcher/domain/general/types.go
  • internal/processor/fetcher/domain/search/handler.go
  • internal/processor/fetcher/rule/upgrader.go
  • internal/processor/fetcher/worker/manager.go
  • internal/processor/fetcher/worker/pool.go
  • internal/processor/parser/worker/parser_worker.go
  • internal/processor/validate/worker.go
  • internal/scheduler/scheduler.go
  • internal/scheduler/throttle.go
  • internal/worker/chain.go
  • internal/worker/guard.go
  • internal/worker/resolver.go
  • internal/worker/retry.go
  • internal/worker/seed.go
  • internal/worker/upgrade.go
  • internal/worker/worker.go
  • test/internal/processor/fetcher/domain/general/chain_handler_chromedp_routing_test.go
  • test/internal/processor/fetcher/domain/general/chain_handler_reparse_propagation_test.go
  • test/internal/processor/fetcher/worker/pool_retry_scheduler_test.go
  • test/internal/processor/fetcher/worker/pool_test.go
  • test/internal/processor/parser/worker/helpers_test.go
  • test/internal/processor/validate/worker_test.go
  • test/internal/worker/publisher_gate_test.go
  • test/internal/worker/publisher_ingestion_lock_test.go
  • test/internal/worker/retry_test.go
  • test/internal/worker/seed_test.go
  • test/internal/worker/upgrade_test.go

Comment thread internal/processor/fetcher/domain/search/handler.go Outdated
Comment thread internal/processor/parser/worker/parser_worker.go Outdated

@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 renames the internal/publisher package to internal/worker and adopts the bus alias throughout the codebase to prevent naming collisions with the fetcher worker. The review feedback focuses on ensuring that documentation and code examples within comments consistently use the bus alias instead of the raw package name worker to maintain clarity and alignment with the new architectural naming convention.

Comment thread internal/bus/worker.go Outdated
Comment thread internal/bus/resolver.go Outdated
Comment thread internal/bus/seed.go Outdated
Comment thread internal/bus/seed.go Outdated
Comment thread internal/processor/fetcher/domain/general/types.go Outdated
Comment thread internal/processor/fetcher/rule/upgrader.go
Comment thread internal/bus/upgrade.go Outdated
이전 commit 의 worker 명명이 internal/processor/fetcher/worker 와 충돌해 모든 호출처에서
bus alias 필수. alias 없이 패키지 이름 자체를 bus 로 변경 → 호출처 import 가 자연스럽게
정렬됨.

## 변경

- internal/worker/ → internal/bus/, package worker → package bus
- test/internal/worker/ → test/internal/bus/, package worker_test → package bus_test
- 진입점 file 이름 worker.go 는 그대로 유지 (패키지 hub 의미 — bus.go 도 가능했으나 추가
  rename 비용 회피)
- 호출처 import 갱신:
  - 구: import bus \"issuetracker/internal/worker\"  (alias 필요)
  - 신: import \"issuetracker/internal/bus\"          (alias 불필요, 패키지명 = bus)
- test/internal/bus 내부 SUT 참조 worker.X → bus.X 일괄 치환

## 검증

- go build ./internal/... ./cmd/... ./pkg/... ./test/... ./examples/... — pass
- go test -race -count=1 -timeout=180s ./test/... — 전 패키지 통과
- gofmt clean

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@juhy0987 juhy0987 changed the title [REFAC#411] internal/publisher → internal/worker rename + bus alias [REFAC#411] internal/publisher → internal/bus rename May 13, 2026
…일관성 (CodeRabbit + gemini)

리뷰 피드백 9건 반영 (전부 doc comment 정정):

## CodeRabbit Minor (2건)
- parser_worker.go / search/handler.go: 주석의 \"bus.Publish (chained jobs)\" 가 실제
  API 명 (PublishChained) 과 불일치. PublishChained 로 정정.

## gemini Medium (7건)
주석 내 worker.X / publisher.X prefix 를 모두 bus.X 로 통일 — PR 의 alias 표준화 일관:
- internal/bus/worker.go: pub := bus.New(producer, resolver, log)
- internal/bus/resolver.go: composite := bus.NewCompositeResolver(...) / bus.ExplicitPriorityResolver
- internal/bus/seed.go: errors.Is(err, bus.ErrPublishSkipped) / bus.Publisher
- internal/bus/upgrade.go: defensive nil check (bus.New 가 log 검증 안 하므로 caller 보호)
- internal/processor/fetcher/domain/general/types.go: bus.Publisher 가 본 인터페이스를 구현
- internal/processor/fetcher/rule/upgrader.go: upgradePub bus.UpgradePublisher

구현 / API / 동작 무변경 — 순수 doc 정정.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@juhy0987
juhy0987 merged commit 23f63ca into main May 13, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Code refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REFACTOR] internal/publisher → internal/bus rename

2 participants