Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jan 29, 2020. It is now read-only.
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

App specific listeners for swoole events #69

Open
@marc-mabe

Description

@marc-mabe
  • I was not able to find anopen orclosed issue matching what I'm seeing.
  • This is not a question. (Questions should be asked onchat (Signup here) or ourforums.)

Use swoole tick timer on the worker process to be able to use it as the event loop for guzzle.

PS: By default guzzle uses PHP shutdown handler but this does not work in a swoole environment. To be able to use async Guzzle callbacks within an swoole worker you have to run the task queue of Guzzle manually. This can simply be done using theSwooleServer::tick function of the worker process.

Code to reproduce the issue

// This does not work as "SwooleServer::on()" supports only one listener// and there is already a listener in SwooleRequestHandlerRunner$masterServer =$container->get(SwooleHttpServer::class);$masterServer->on('workerstart',function (SwooleHttpServer$workerServer) {$queue =\GuzzleHttp\Promise\queue();$workerServer->tick(100,function ()use ($queue) {$queue->run();    });});// I had to extend SwooleRequestHandlerRunner// and copy-past SwooleRequestHandlerRunnerFactory// to use an own event manager to add application specific listeners to these events$em =$container->get(EventManagerInterface::class);$em->attach(WorkerStartEvent::class,function (WorkerStartEvent$event) {$queue =\GuzzleHttp\Promise\queue();$workerServer =$event->getServer();$workerServer->tick(1000,function ()use ($queue) {$queue->run();    });});

Expected results

There should already be a way in zend-expressive-swoole to add application specific listeners to such events

Actual results

It's not possible without extendingSwooleRequestHandlerRunner and copy-pastingSwooleRequestHandlerRunnerFactory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp