Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[client] Lazy producer. #845

Merged
merged 6 commits into from
May 14, 2019
Merged

[client] Lazy producer. #845

merged 6 commits into from
May 14, 2019

Conversation

makasim
Copy link
Member

@makasim makasim commented May 14, 2019

Problem: The proper ENQUEUE_DSN is not available during warmup which happens on CI. Warmup would throw an exception if the producer is used in an event listener. To workaround, we should fake DSN.

The PR introduces a lazy producer which could be safely injected to event listeners and be used during warm up. It throws an exception on sendEvent or sendCommand call.

@makasim makasim requested a review from ASKozienko May 14, 2019 13:03
@makasim makasim merged commit a98e66f into master May 14, 2019
@makasim makasim deleted the lazy-producer branch May 14, 2019 14:15
@ivoba
Copy link

ivoba commented May 17, 2019

Since update to 0.9.10 i get this error in tests, i think its related to this PR:

Error: Call to undefined method Enqueue\Symfony\Client\LazyProducer::clearTraces()

In test env enqueue is configured to use traceable producer


enqueue:
    default:
        transport: '%env(resolve:ENQUEUE_DSN)%'
        client:
            traceable_producer: true

In tests clearTraces is used in setUp

    protected function setUp()
    {
        parent::setUp();
        /** @var TraceableProducer $producer */
        $producer = static::$container->get(ProducerInterface::class);
        $producer->clearTraces();
    }

@makasim
Copy link
Member Author

makasim commented May 17, 2019

this works for me:

<?php
    private function getProducer(): TraceableProducer
    {
        return self::$container->get('enqueue.client.default.traceable_producer');
    }

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.

2 participants