Skip to content

feat: Plugins implementation#724

Open
xepozz wants to merge 26 commits intomasterfrom
plugin
Open

feat: Plugins implementation#724
xepozz wants to merge 26 commits intomasterfrom
plugin

Conversation

@xepozz
Copy link
Collaborator

@xepozz xepozz commented Mar 6, 2026

What was changed

  • Added interfaces for the plugins
  • Each interface has several methods that are called during the sdk working process
  • Each interface has no-op trait to be able to implement only necessary methods
  • There is AbstractPlugin instead of SimplePlugin as from the rest implementations
  • Using plugins with the same name raise an error
  • There's a convenient way to add plugins to a test class with php attribute
  • Worker provides used plugins, but RoadRunner plugin doesn't support it yet

Why?

Resolves #644

Checklist

  1. Closes

  2. How was this tested:

  1. Any docs updates needed?

@vercel
Copy link

vercel bot commented Mar 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
php Ready Ready Preview, Comment Mar 25, 2026 3:29pm

Request Review

@xepozz xepozz marked this pull request as ready for review March 19, 2026 08:23
@xepozz xepozz requested review from a team, roxblnfk and wolfy-j as code owners March 19, 2026 08:23
Copy link
Member

@Sushisource Sushisource left a comment

Choose a reason for hiding this comment

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

General notes:

  • Not seeing a way to configure the replay worker explicitly. This exists in the other SDKs.
  • The new interfaces should be marked experimental

* them to set API keys, gRPC metadata, TLS context, and other
* connection-level options.
*/
interface ConnectionPluginInterface
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't extend PluginInterface but probably should?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Missed one, thanks!

* Use this hook to configure connection-level settings such as
* API keys, gRPC metadata, auth tokens, or context options.
*/
public function configureServiceClient(ConnectionPluginContext $context): void;
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't do chain-of-responsibility like in the other SDKs - as a general rule I think we want all of the plugins to be able to work that way, as it allows for true interception rather than just configuration.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Some of changes were made on purpose. I've changed signature to public function configureServiceClient(ServiceClientInterface $serviceClient, callable $next): ServiceClientInterface. Is it what you wanted?
Any other methods?

*
* @param callable(WorkerFactoryInterface): int $next Calls the next plugin or the actual run loop.
*/
public function run(WorkerFactoryInterface $factory, callable $next): int;
Copy link
Member

Choose a reason for hiding this comment

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

I think we probably need a runWorker or something which can wrap individual worker start calls? There are equivalents for this in the other SDKs.

);
$factory->newWorker();

self::assertSame(['from-factory', 'from-client'], $order);
Copy link
Member

Choose a reason for hiding this comment

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

I believe we would want the client plugins to be applied first. The other SDKs are generally prepending the ones from the client.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, changed.

Comment on lines +66 to +67
// Use only plugin interceptors - the base pipeline is lost in this edge case.
// Users should either use plugins OR a custom PipelineProvider, not both.
Copy link
Member

Choose a reason for hiding this comment

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

I know this is kind of already called out in the docstring, but, the fact that you could silently lose some config here probably deserves to be highlighted (ideally prevented if somehow possible).

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.

[Feature Request] Plugin support

2 participants