Community라이팅 & 에디팅github.com

Queue (WelineFramework 큐 작업)

WelineFramework 소스 저장소 내에서 큐 검사, 수리 및 운영을 위한 기술입니다. 프레임워크 쿼리 프로바이더와 큐 CLI를 선호합니다.

Queue (WelineFramework 큐 작업)란 무엇인가요?

이 스킬은 WelineFramework 애플리케이션에서 큐 시스템을 진단하고 관리하는 데 사용됩니다. 소스 저장소 내의 큐 관련 파일(QueueQueryProvider, Console 명령어, Model 등)을 분석하여 큐 항목을 조회, 생성, 업데이트, 삭제하고 실행합니다. `w_query('queue', ...)` 함수와 `php bin/w queue:*` CLI 명령어를 통해 데이터베이스 직접 접근 없이도 프레임워크의 캐스팅, EAV, 이벤트 디스패칭 등 내부 동작을 안전하게 다룰 수 있습니다. 새로운 큐 컨슈머를 구현할 때는 `QueueConsumerInterface`를 사용하며, 기존 서드파티 호환성을 위해 `QueueInterface`도 지원합니다. 주요 작업으로는 큐 타입 수집, 목록 조회, 항목 실행(강제 모드 포함), 상태별 필터링, 비즈니스 키 기반 검색 등이 있으며, CLI와 PHP 런타임 코드 예제를 통해 다양한 진단 및 운영 시나리오를 지원합니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add Aiweline/WelineFramework

Installed? Explore more 라이팅 & 에디팅 skills: steipete/notion, langchain-ai/langchain, bytedance/podcast-generation · View all 6 →

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

Queue

WelineFramework 소스 저장소 내에서 큐 검사, 수리 및 운영을 위해 이 스킬을 사용하세요. 소스 수준 진단을 위해 모델 내부가 필요한 경우가 아니라면, 프레임워크 쿼리 프로바이더와 큐 CLI를 데이터베이스 직접 접근보다 선호하세요.

첫 번째 단계

  1. 문서가 최신이라고 가정하기 전에 현재 큐 소스를 읽으세요:
    • app/code/Weline/Queue/extends/module/Weline_Framework/Query/QueueQueryProvider.php
    • app/code/Weline/Queue/Console/Queue/Collect.php
    • app/code/Weline/Queue/Console/Queue/Run.php
    • app/code/Weline/Queue/Console/Queue/Type/Listing.php
    • app/code/Weline/Queue/Model/Queue.php
  2. 런타임 큐 읽기 및 비즈니스 수준 쓰기에는 w_query('queue', ...)를 사용하세요. 데이터베이스 직접 읽기는 프레임워크 캐스팅, EAV/모델 동작, 이벤트 디스패칭 및 현재 쿼리 프로바이더 의미를 놓칠 수 있습니다.
  3. 부작용 경계를 유지하세요. stats, get, getByBizKey, list, getTypeIdByClass, queue:type:listing은 진단용입니다. create, update, delete, queue:collect, queue:run은 상태를 변경하거나 작업을 실행합니다.
  4. 새로운 크로스 모듈 컨슈머는 Weline\Queue\Api\QueueConsumerInterface를 구현하고 QueueTaskContextInterface를 받습니다. Weline\Queue\QueueInterface는 기존 서드파티 컨슈머를 위한 런타임 호환성 경계로만 남아 있습니다.

큐 CLI

저장소 루트에서 다음 명령어를 사용하세요.

php bin/w queue:collect

모듈에서 큐 타입을 수집하여 weline_queue_type에 저장합니다. 큐 클래스를 추가하거나 변경한 후, 또는 getTypeIdByClass가 클래스를 찾을 수 없을 때 실행하세요. 수집기는 공용 Weline\Queue\Api\QueueConsumerInterface 또는 레거시 Weline\Queue\QueueInterface 중 하나를 구현하는 인스턴스화 가능한 클래스만 등록합니다. Queue/ 디렉토리의 헬퍼/정적 클래스는 큐 구현이 아닙니다.

php bin/w queue:type:listing
php bin/w queue:type:listing ExampleQueue
php bin/w queue:type:listing Vendor_Module

등록된 큐 타입을 나열합니다. 추가 인수는 이름, 모듈 및 클래스에 대해 일치시키는 검색어입니다.

php bin/w queue:run --id=77
php bin/w queue:run --id=77 -f
php bin/w queue:run --id=77 --force

weline_queue.queue_id로 하나의 큐 항목을 실행합니다.

동일한 큐 항목을 의도적으로 인수하거나 재구축할 때만 -f/--force를 사용하세요. 현재 동작:

  • 동일한 큐가 running으로 표시된 경우, 강제 모드는 계속 진행하기 전에 이전 동일 ID 프로세스를 종료합니다.
  • 콘텐츠가 JSON인 경우 큐 콘텐츠에 _force_rebuild=1을 주입합니다.
  • 새 로그를 읽기 쉽게 이전 result 및 process를 지웁니다.

현재 소스에 명령어 클래스가 포함되어 있지 않은 한 queue:status를 실제 명령어로 인용하지 마세요.

w_query 예제

임시 진단을 위해 앱을 부트스트랩하세요:

php -r "require __DIR__ . '/app/bootstrap.php'; var_export(w_query('queue', 'stats'));"

하나의 큐 읽기:

php -r "require __DIR__ . '/app/bootstrap.php'; print_r(w_query('queue', 'get', ['queue_id' => 77]));"

비즈니스 키로 최신 큐 찾기:

php -r "require __DIR__ . '/app/bootstrap.php'; print_r(w_query('queue', 'getByBizKey', ['biz_key' => 'example:1']));"

방대한 스트림 로그를 덤프하지 않고 최근 큐 나열:

php -r "require __DIR__ . '/app/bootstrap.php'; \$r=w_query('queue','list',['page_size'=>10]); foreach(\$r['items'] as \$it){ \$row=is_object(\$it)&&method_exists(\$it,'getData')?\$it->getData():\$it; echo json_encode(['queue_id'=>\$row['queue_id']??null,'status'=>\$row['status']??null,'module'=>\$row['module']??null,'name'=>\$row['name']??null,'biz_key'=>\$row['biz_key']??null], JSON_UNESCAPED_UNICODE), PHP_EOL; }"

상태 또는 검색 텍스트로 필터링:

php -r "require __DIR__ . '/app/bootstrap.php'; \$r=w_query('queue','list',['status'=>'error','q'=>'example','page_size'=>20]); foreach(\$r['items'] as \$it){ \$row=is_object(\$it)&&method_exists(\$it,'getData')?\$it->getData():\$it; echo (\$row['queue_id']??'') . ' ' . (\$row['status']??'') . ' ' . (\$row['name']??'') . PHP_EOL; }"

클래스로 타입 ID 확인:

php -r "require __DIR__ . '/app/bootstrap.php'; var_export(w_query('queue','getTypeIdByClass',['class'=>'Vendor\\Module\\Queue\\ExampleQueue']));"

프로바이더를 통해 큐 생성:

php -r "require __DIR__ . '/app/bootstrap.php'; print_r(w_query('queue','create',['class'=>'Vendor\\Module\\Queue\\ExampleQueue','name'=>'Example task','module'=>'Vendor_Module','content'=>['foo'=>'bar'],'biz_key'=>'example:1']));"

안전한 필드 하위 집합 업데이트:

php -r "require __DIR__ . '/app/bootstrap.php'; print_r(w_query('queue','update',['queue_id'=>77,'patch'=>['status'=>'pending','pid'=>0,'result'=>'','process'=>'']]));"

의도된 경우에만 삭제:

php -r "require __DIR__ . '/app/bootstrap.php'; print_r(w_query('queue','delete',['queue_id'=>77]));"

큐가 실행 중이고 삭제가 명시적으로 의도된 경우에만 force => true를 사용하세요.

프로바이더 작업

w_query('queue', OP, PARAMS)는 현재 다음을 지원합니다:

  • get / load: queue_id 또는 id 필요; 하나의 큐 행 또는 null 반환.
  • getByBizKey: biz_key 필요; 일치하는 최신 행 반환.
  • list: 필터에는 page, page_size, module, status, type_id, queue_id, biz_key, q 포함; items 및 pagination 반환.
  • stats: all, pending, running, done, error, stop에 대한 개수 반환.
  • getTypeIdByClass: 공용 또는 레거시 큐 컨슈머 클래스를 type_id로 확인; 없으면 내부적으로 수집 실행.
  • create: name, module 필수, 그리고 type_id 또는 class 중 하나; 선택적 content, status, auto, biz_key.
  • update: queue_id/id 또는 biz_key로 찾기; patch 또는 최상위 필드 전달. 안전한 패치 필드에는 name, module, status, content, result, process, biz_key, auto, finished, pid, type_id가 포함됩니다.
  • delete: queue_id/id 또는 biz_key로 찾기; 실행 중인 큐는 force 필요.

유효한 상태는 pending, running, done, error, stop입니다.

검증

큐 등록 또는 컨슈머 계약 필터링 변경 후:

php -l app/code/Weline/Queue/Helper/Helper.php
php bin/w queue:collect
php bin/w queue:type:listing

명령어 동작 변경 후:

php bin/w queue:run --help
php bin/w queue:collect --help
php bin/w queue:type:listing --help

관련 스킬