Skip to content

Conversation

@pfefferle
Copy link
Member

@pfefferle pfefferle commented Oct 22, 2025

Added new configuration options to better manage traffic spikes when federating posts, allowing finer control over retry limits, delays, and batch pauses.

Proposed changes:

  • Add filters to change the default options

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

  • Go to '..'

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Added - for new features
  • Changed - for changes in existing functionality
  • Deprecated - for soon-to-be removed features
  • Removed - for now removed features
  • Fixed - for any bug fixes
  • Security - in case of vulnerabilities

Message

Added new configuration options to better manage traffic spikes when federating posts, allowing finer control over retry limits, delays, and batch pauses.

Introduces ACTIVITYPUB_OUTBOX_RETRY_MAX_ATTEMPTS, ACTIVITYPUB_OUTBOX_RETRY_DELAY_UNIT, and ACTIVITYPUB_ASYNC_BATCH_PAUSE constants for improved control over retry logic and async batch scheduling. Updates Dispatcher and Scheduler classes to use these new constants for retries and batch pauses.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds three new configurable constants to improve control over ActivityPub outbox retry logic and async batch scheduling, addressing traffic peak handling when federating new posts. The constants allow customization of retry attempts, retry delays, and pause intervals between async batches.

Key changes:

  • Introduces three new constants: ACTIVITYPUB_OUTBOX_RETRY_MAX_ATTEMPTS, ACTIVITYPUB_OUTBOX_RETRY_DELAY_UNIT, and ACTIVITYPUB_ASYNC_BATCH_PAUSE
  • Updates Dispatcher and Scheduler classes to use configurable static properties instead of hardcoded values

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
includes/constants.php Defines three new constants for retry attempts (3), retry delay unit (1 hour), and async batch pause (30 seconds)
includes/class-scheduler.php Adds static property for async batch pause and uses it instead of hardcoded 30-second value
includes/class-dispatcher.php Adds static properties for retry max attempts and retry delay unit, replacing hardcoded values in retry logic

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@pfefferle pfefferle marked this pull request as ready for review October 22, 2025 15:29
@pfefferle
Copy link
Member Author

@obenland I know that you are not a fan of consts, but that is how the rest works, so I tried to be consistent. Happy to change the whole system to use filters and/or options instead.

@obenland
Copy link
Member

Filters are probably the most flexible approach

Replaces direct usage of constants and static properties for batch size, retry attempts, delay unit, error codes, and async batch pause with getter methods that apply WordPress filters. This improves flexibility and allows these values to be customized via hooks. Removes related constants from constants.php.
@pfefferle pfefferle requested a review from Copilot October 23, 2025 16:19
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

pfefferle and others added 4 commits October 23, 2025 21:18
Co-authored-by: Konstantin Obenland <[email protected]>
Co-authored-by: Konstantin Obenland <[email protected]>
Updated Dispatcher to use ACTIVITYPUB_OUTBOX_PROCESSING_BATCH_SIZE as the default batch size. Renamed Scheduler's get_async_batch_pause() to get_retry_delay() and updated references to improve clarity and consistency in batch processing and scheduling.
Replaces the use of get_retry_delay_unit() with get_retry_delay() in the retry scheduling logic to ensure the correct delay value is applied for activity retries.
@pfefferle
Copy link
Member Author

Today was not mAI day :(

@pfefferle pfefferle requested a review from obenland October 23, 2025 19:25
@pfefferle pfefferle merged commit 50cc93a into trunk Oct 23, 2025
13 checks passed
@pfefferle pfefferle deleted the customize-dispatcher branch October 23, 2025 19:38
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.

3 participants