简体   繁体   中英

amphp/parallel-functions in Symfony

/** @var array<ServiceInterface> */
    protected $services;

    public function __construct(array $services)
    {
        $this->services = $services;
    }

    public function checkRkoDuplicates(Payload $payload)
    {
        $services = $this->services;

        try {
            $results = Promise\wait(parallelMap($services, function (ServiceInterface $service) use ($payload) {
                return $service->exchange($payload); // ?string
            }));
        } catch (MultiReasonException $exception) {
            foreach ($exception->getReasons() as $reason) {
                var_dump($reason->getMessage());
            }

            return null;
        }

        return $results;
    }

If in Symfony I use APP_ENV = dev everything works. If APP_ENV = prod then I get error The given data could not be serialized: Serialization of 'Closure' is not allowed .

Why it happens? How to make it work?

Monolog tried to write logs from services to prod.log. But excluded_http_codes: [404, 405] was breaking the entry. Since the service logs are stored separately, I disabled the logs from services in prod.log

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM