Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .cursor/rules/context.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ alwaysApply: false
- **Existing Patterns**: Follow the existing code structure, naming conventions, and architectural patterns found in the codebase. Consistency is key.
- **Bail Early**: Use early returns in functions and methods to improve readability and reduce cognitive load.
---
description: Rules for implementing Pigeon tasks and features in PHP.
description: Rules for implementing Shepherd tasks and features in PHP.
globs:
- "src/**/*.php"
---
### Tasks
- All tasks **must** extend `StellarWP\Pigeon\Abstracts\Task_Abstract`.
- All tasks **must** extend `StellarWP\Shepherd\Abstracts\Task_Abstract`.
- Task arguments must be passed to `parent::__construct()` to ensure they are correctly stored.
- The core logic of a task resides in the `process()` method.
- To trigger a retry, a task **must** overwrite the `get_max_retries` method.
Expand Down
2 changes: 1 addition & 1 deletion .cursor/rules/php-docblocks.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ For properties they should be like:
*
* @since TBD
*
* @package StellarWP\Pigeon
* @package StellarWP\Shepherd
*/
6 changes: 0 additions & 6 deletions .cursor/rules/what-is-pigeon.mdc

This file was deleted.

6 changes: 6 additions & 0 deletions .cursor/rules/what-is-shepherd.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
description:
globs:
alwaysApply: true
---
Shpeherd is a background offloading API. It's a wrapper of WooCommerce's Action Scheduler and on top of AS adds more functionality.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ codeception.* export-ignore
phpcs.xml export-ignore
phpstan.neon.dist export-ignore
docs export-ignore
pigeon.php export-ignore
shepherd.php export-ignore
8 changes: 4 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing to Pigeon
# Contributing to Shepherd

Thank you for contributing to Pigeon! This guide outlines the standards and processes for commits and pull requests.
Thank you for contributing to Shepherd! This guide outlines the standards and processes for commits and pull requests.

## Table of Contents

Expand Down Expand Up @@ -250,8 +250,8 @@ Related to #789
* @param Task $task The task to schedule.
* @param int $delay Delay in seconds before execution. Default 0.
*
* @throws PigeonTaskException If task scheduling fails.
* @throws PigeonTaskAlreadyExistsException If duplicate task exists.
* @throws ShepherdTaskException If task scheduling fails.
* @throws ShepherdTaskAlreadyExistsException If duplicate task exists.
*
* @return void
*/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
${SLIC_BIN} config
- name: Start the Chrome container
run: ${SLIC_BIN} up chrome
- name: Set up StellarWP Pigeon
- name: Set up StellarWP Shepherd
run: |
${SLIC_BIN} use shepherd
${SLIC_BIN} composer install
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/update_as.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ jobs:
- name: Install WooCommerce
run: ${SLIC_BIN} site-cli plugin install woocommerce

- name: Get Pigeon's AS Version from composer.json
- name: Get Shepherd's AS Version from composer.json
run: |
cd ${GITHUB_WORKSPACE}/
PIGEON_AS_VERSION=$(grep -E '"woocommerce/action-scheduler": "[0-9]+\.[0-9]+\.[0-9]+"' composer.json | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
echo "Pigeon's AS Version: $PIGEON_AS_VERSION"
echo "PIGEON_AS_VERSION=$PIGEON_AS_VERSION" >> $GITHUB_ENV
SHEPHERD_AS_VERSION=$(grep -E '"woocommerce/action-scheduler": "[0-9]+\.[0-9]+\.[0-9]+"' composer.json | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
echo "Shepherd's AS Version: $SHEPHERD_AS_VERSION"
echo "SHEPHERD_AS_VERSION=$SHEPHERD_AS_VERSION" >> $GITHUB_ENV

- name: Get WooCommerce's AS Version php eval
run: |
Expand All @@ -89,10 +89,10 @@ jobs:
echo "WooCommerce's AS Version: $WC_AS_VERSION"
echo "WC_AS_VERSION=$WC_AS_VERSION" >> $GITHUB_ENV

- name: Compare Pigeon's and WooCommerce's AS Versions
- name: Compare Shepherd's and WooCommerce's AS Versions
run: |
if [ "$PIGEON_AS_VERSION" != "$WC_AS_VERSION" ]; then
echo "Pigeon's AS Version: $PIGEON_AS_VERSION"
if [ "$SHEPHERD_AS_VERSION" != "$WC_AS_VERSION" ]; then
echo "Shepherd's AS Version: $SHEPHERD_AS_VERSION"
echo "WooCommerce's AS Version: $WC_AS_VERSION"
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ All notable changes to this project will be documented in this file. This projec
* Docs - Documentation
* Tests - Automated tests

[1.0.0]: https://github.com/stellarwp/pigeon/releases/tag/1.0.0
[1.0.0]: https://github.com/stellarwp/shepherd/releases/tag/1.0.0
58 changes: 29 additions & 29 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# StellarWP Pigeon - AI Assistant Context
# StellarWP Shepherd - AI Assistant Context

## Project Overview

Pigeon is a lightweight background processing library for WordPress built on top of Action Scheduler. It provides a clean, fluent API for defining and dispatching asynchronous tasks with built-in support for retries, debouncing, and logging.
Shepherd is a lightweight background processing library for WordPress built on top of Action Scheduler. It provides a clean, fluent API for defining and dispatching asynchronous tasks with built-in support for retries, debouncing, and logging.

## Key Features

Expand All @@ -26,8 +26,8 @@ Pigeon is a lightweight background processing library for WordPress built on top

### Database Schema

- `pigeon_{prefix}_tasks`: Stores task data and retry information
- `pigeon_{prefix}_task_logs`: Tracks task lifecycle events
- `shepherd_{prefix}_tasks`: Stores task data and retry information
- `shepherd_{prefix}_task_logs`: Tracks task lifecycle events

### Task Lifecycle States

Expand All @@ -44,18 +44,18 @@ Pigeon is a lightweight background processing library for WordPress built on top
### Installation

```bash
composer require stellarwp/pigeon
composer require stellarwp/shepherd
```

### Registration

Pigeon requires a DI container implementing `StellarWP\ContainerContract\ContainerInterface`. Register it on the `plugins_loaded` action at the LATEST:
Shepherd requires a DI container implementing `StellarWP\ContainerContract\ContainerInterface`. Register it on the `plugins_loaded` action at the LATEST:

```php
\StellarWP\Pigeon\Config::set_hook_prefix( 'my_app' ); // Needs to be set before the container is registered.
\StellarWP\Shepherd\Config::set_hook_prefix( 'my_app' ); // Needs to be set before the container is registered.
$container = get_my_apps_container(); // Your container instance
$container->singleton( \StellarWP\Pigeon\Provider::class );
$container->get( \StellarWP\Pigeon\Provider::class )->register();
$container->singleton( \StellarWP\Shepherd\Provider::class );
$container->get( \StellarWP\Shepherd\Provider::class )->register();
```

## Creating Tasks
Expand All @@ -76,7 +76,7 @@ class My_Task extends Task_Abstract {

// Task logic here
if ( ! $result ) {
throw new PigeonTaskException( 'Task failed' );
throw new ShepherdTaskException( 'Task failed' );
}
}

Expand All @@ -100,14 +100,14 @@ class My_Task extends Task_Abstract {

```php
// Dispatch a task immediately
pigeon()->dispatch(new My_Task($arg1, $arg2));
shepherd()->dispatch(new My_Task($arg1, $arg2));

// Dispatch with delay (in seconds)
pigeon()->dispatch(new My_Task($arg1, $arg2), 300); // 5 minutes
shepherd()->dispatch(new My_Task($arg1, $arg2), 300); // 5 minutes

// Retrieve task logs
use StellarWP\Pigeon\Contracts\Logger;
use StellarWP\Pigeon\Provider;
use StellarWP\Shepherd\Contracts\Logger;
use StellarWP\Shepherd\Provider;

$logger = Provider::get_container()->get( Logger::class );
$logs = $logger->retrieve_logs( $task_id );
Expand All @@ -120,7 +120,7 @@ $logs = $logger->retrieve_logs( $task_id );
Sends emails asynchronously with automatic retries (up to 5 attempts):

```php
use StellarWP\Pigeon\Tasks\Email;
use StellarWP\Shepherd\Tasks\Email;

$email_task = new Email(
'recipient@example.com',
Expand All @@ -130,14 +130,14 @@ $email_task = new Email(
['/path/to/attachment.pdf']
);

pigeon()->dispatch($email_task);
shepherd()->dispatch($email_task);
```

## Logging System

### Default Logger Change (TBD)

Pigeon now uses `ActionScheduler_DB_Logger` as the default logger instead of `DB_Logger`. This change:
Shepherd now uses `ActionScheduler_DB_Logger` as the default logger instead of `DB_Logger`. This change:

- **Reduces database overhead** by reusing Action Scheduler's existing `actionscheduler_logs` table
- **Maintains compatibility** with the existing Logger interface
Expand All @@ -146,14 +146,14 @@ Pigeon now uses `ActionScheduler_DB_Logger` as the default logger instead of `DB
### Logger Options

```php
use StellarWP\Pigeon\Config;
use StellarWP\Pigeon\Loggers\ActionScheduler_DB_Logger;
use StellarWP\Pigeon\Loggers\DB_Logger;
use StellarWP\Shepherd\Config;
use StellarWP\Shepherd\Loggers\ActionScheduler_DB_Logger;
use StellarWP\Shepherd\Loggers\DB_Logger;

// Default: Use Action Scheduler's logs table
Config::set_logger( new ActionScheduler_DB_Logger() );

// Alternative: Use Pigeon's dedicated logs table
// Alternative: Use Shepherd's dedicated logs table
Config::set_logger( new DB_Logger() );
```

Expand All @@ -162,17 +162,17 @@ Config::set_logger( new DB_Logger() );
When using `ActionScheduler_DB_Logger`, logs are stored in a special format within the `message` column:

```
pigeon_{hook_prefix}||{task_id}||{type}||{level}||{json_entry}
shepherd_{hook_prefix}||{task_id}||{type}||{level}||{json_entry}
```

This format allows Pigeon to store its metadata while maintaining compatibility with Action Scheduler's table structure.
This format allows Shepherd to store its metadata while maintaining compatibility with Action Scheduler's table structure.

## Development Commands

### Testing

```bash
# You need to have slic installed and configured to use pigeon.
# You need to have slic installed and configured to use shepherd.

# Then you can run each suite like:
slic run wpunit
Expand Down Expand Up @@ -202,7 +202,7 @@ composer install --ignore-platform-req=ext-uopz

## Important Files and Locations

- **Main entry point**: `pigeon.php`
- **Main entry point**: `shepherd.php`
- **Core logic**: `src/Regulator.php`
- **Task base class**: `src/Abstracts/Task_Abstract.php`
- **Database schemas**: `src/Tables/`
Expand All @@ -222,7 +222,7 @@ composer install --ignore-platform-req=ext-uopz
- Follows WordPress coding standards and more Specifically StellarWP's coding standards.
- Uses PHPStan for static analysis (level defined in `phpstan.neon.dist`)
- PHP 7.4+ compatibility required
- PSR-4 autoloading under `StellarWP\Pigeon` namespace
- PSR-4 autoloading under `StellarWP\Shepherd` namespace

## Dependencies

Expand All @@ -239,7 +239,7 @@ composer install --ignore-platform-req=ext-uopz
1. Create a new class extending `Task_Abstract` in `src/Tasks/`
2. Implement required methods (`process()`, `get_task_prefix()`)
3. Optionally override retry configuration methods
4. If implemented withing Pigeon, add tests in `tests/unit/Tasks/`
4. If implemented withing Shepherd, add tests in `tests/unit/Tasks/`

### Modifying Database Schema

Expand All @@ -265,14 +265,14 @@ composer install --ignore-platform-req=ext-uopz
You can implement a custom logger by implementing the `Logger` interface:

```php
use StellarWP\Pigeon\Contracts\Logger;
use StellarWP\Shepherd\Contracts\Logger;

class My_Custom_Logger implements Logger {
// Implement required methods
}

// Set before Provider::register()
\StellarWP\Pigeon\Config::set_logger( new My_Custom_Logger() );
\StellarWP\Shepherd\Config::set_logger( new My_Custom_Logger() );
```

## Task Behavior Details
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Pigeon
# Shepherd

Pigeon is a lightweight and powerful background processing library for WordPress, built on top of Action Scheduler. It provides a simple, fluent API for defining and dispatching asynchronous tasks, with built-in support for retries, debouncing, and logging.
Shepherd is a lightweight and powerful background processing library for WordPress, built on top of Action Scheduler. It provides a simple, fluent API for defining and dispatching asynchronous tasks, with built-in support for retries, debouncing, and logging.

## Features

Expand All @@ -13,15 +13,15 @@ Pigeon is a lightweight and powerful background processing library for WordPress

## Getting Started

For a guide on how to install Pigeon and get started with creating and dispatching your first task, please see our [Getting Started guide](./docs/getting-started.md).
For a guide on how to install Shepherd and get started with creating and dispatching your first task, please see our [Getting Started guide](./docs/getting-started.md).

## Advanced Usage

For more detailed information on advanced features like task retries, debouncing, unique tasks, and logging, please refer to our [Advanced Usage guide](./docs/advanced-usage.md).

## Built-in Tasks

Pigeon comes with a set of pre-packaged tasks to handle common background operations. For more information, please see our [Tasks guide](./docs/tasks.md).
Shepherd comes with a set of pre-packaged tasks to handle common background operations. For more information, please see our [Tasks guide](./docs/tasks.md).

## Contributing

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "stellarwp/pigeon",
"name": "stellarwp/shepherd",
"description": "A library for offloading tasks to background processes.",
"type": "library",
"license": "GPL-2.0",
Expand All @@ -13,15 +13,15 @@
},
"autoload": {
"psr-4": {
"StellarWP\\Pigeon\\": "src/"
"StellarWP\\Shepherd\\": "src/"
},
"files": [
"src/functions.php"
]
},
"autoload-dev": {
"psr-4": {
"StellarWP\\Pigeon\\Tests\\": "tests/_support/Helper/"
"StellarWP\\Shepherd\\Tests\\": "tests/_support/Helper/"
}
},
"authors": [
Expand Down
Loading
Loading