feat(seo): 사이트맵 증분 저장소 + 리소스 리스너 재배선
사이트맵을 리소스 단위로 영속화(sitemap_urls)해 진정한 증분 갱신과 도메인 재쿼리 없는 파일 재작성을 구현했다. 리소스 공개/비공개/삭제 시 해당 항목만 색인이 갱신되고, 관리자=full·스케줄러=auto·리소스 변경=증분으로 동작한다. - sitemap_urls 마이그레이션 + SitemapUrl 모델. loc(2048) 를 unique 에 직접 넣으면 InnoDB 키 길이를 초과하므로 loc_hash(sha256) 컬럼을 identity 로 사용 - SitemapUrlRepository(멱등 upsert / remove / 스트리밍) + SitemapIndexer (+ 제3자용 sitemap.index.collect_for_resource 필터 훅) - 4 리스너 재배선: 공개→색인 / 비공개·삭제→색인 해제 + 재생성 잡 디바운스 디스패치. 3 기여자가 resource_type/resource_id 를 함께 emit 해 전체·증분 identity 를 일치 - 재생성 모드를 SitemapGenerationMode Backed Enum 으로 통일(Command→Job→Manager) - seo:generate-sitemap 에 --rebuild / --mode 옵션 추가
This commit is contained in:
1 parent
1a6fca0d6b
commit
1629684156
34 files changed
+2027
-23
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Enums\SitemapGenerationMode;
|
||||
use App\Jobs\GenerateSitemapJob;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
@@ -17,7 +18,10 @@ class SeoGenerateSitemapCommand extends Command
|
||||
/**
|
||||
* @var string 커맨드 시그니처
|
||||
*/
|
||||
protected $signature = 'seo:generate-sitemap {--sync : 큐 드라이버를 무시하고 동기 실행}';
|
||||
protected $signature = 'seo:generate-sitemap
|
||||
{--sync : 큐 드라이버를 무시하고 동기 실행}
|
||||
{--rebuild : 저장소 상태와 무관하게 전체 재생성 (--mode=full 과 동일)}
|
||||
{--mode=auto : 재생성 모드 (full|auto|incremental)}';
|
||||
|
||||
/**
|
||||
* @var string 커맨드 설명
|
||||
@@ -31,6 +35,14 @@ class SeoGenerateSitemapCommand extends Command
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$mode = $this->resolveMode();
|
||||
if ($mode === null) {
|
||||
$allowed = implode(', ', array_map(fn (SitemapGenerationMode $m): string => $m->value, SitemapGenerationMode::cases()));
|
||||
$this->error('잘못된 모드입니다. 허용: '.$allowed);
|
||||
|
||||
return Command::INVALID;
|
||||
}
|
||||
|
||||
$forceSync = (bool) $this->option('sync');
|
||||
// queue.default 는 SettingsServiceProvider 가 drivers.queue_driver 와 동기화하되,
|
||||
// testing 환경에서는 phpunit.xml 값을 보존하므로 격리가 유지된다.
|
||||
@@ -38,13 +50,29 @@ class SeoGenerateSitemapCommand extends Command
|
||||
$isSyncDriver = $connection === 'sync';
|
||||
|
||||
if ($forceSync || $isSyncDriver) {
|
||||
GenerateSitemapJob::dispatchSync();
|
||||
$this->info('Sitemap이 생성되었습니다.');
|
||||
GenerateSitemapJob::dispatchSync($mode);
|
||||
$this->info("Sitemap이 생성되었습니다. (모드: {$mode->value})");
|
||||
} else {
|
||||
GenerateSitemapJob::dispatch();
|
||||
$this->info('Sitemap 생성이 큐에 디스패치되었습니다.');
|
||||
GenerateSitemapJob::dispatch($mode);
|
||||
$this->info("Sitemap 생성이 큐에 디스패치되었습니다. (모드: {$mode->value})");
|
||||
}
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* --rebuild / --mode 옵션으로부터 재생성 모드를 해석합니다.
|
||||
*
|
||||
* --rebuild 는 --mode 보다 우선하며 Full 로 강제합니다.
|
||||
*
|
||||
* @return SitemapGenerationMode|null 재생성 모드 (유효하지 않으면 null)
|
||||
*/
|
||||
private function resolveMode(): ?SitemapGenerationMode
|
||||
{
|
||||
if ((bool) $this->option('rebuild')) {
|
||||
return SitemapGenerationMode::Full;
|
||||
}
|
||||
|
||||
return SitemapGenerationMode::tryFrom((string) $this->option('mode'));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user