-
Notifications
You must be signed in to change notification settings - Fork 10
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
[Feature] Async generation #84
base: main
Are you sure you want to change the base?
[Feature] Async generation #84
Conversation
After discussing this with @ConstantBqt we have another usecase to take into account : If we generate the PDF but the webhook is not setup in our own app but is external. We should be able to declare such case. WDYT @maelanleborgne ? |
This is already present in the PR : // ...
$this->gotenberg->html()
->webhookUrls('https://external.service/webhook', 'https://external.service/webhook-error')
->webhookExtraHeaders(['X-ExternalService-Secret' => 'a_secret'])
->generateAsync()
; or via the configuration : sensiolabs_gotenberg:
# ...
webhook:
external_service:
success:
url: 'https://external.service/webhook'
error:
url: 'https://external.service/webhook-error'
default_options:
pdf:
html:
webhook: 'external_service' Or maybe I'm missing the point. |
Could this part be done in a dedicated PR ?
|
f7e3db6
to
a2ad358
Compare
a2ad358
to
13eb438
Compare
13eb438
to
075dedd
Compare
075dedd
to
9915a29
Compare
8d579fe
to
b26c12f
Compare
…re/webhook-integration
…ture/webhook-integration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick review
'time' => $swEvent?->getDuration(), | ||
'memory' => $swEvent?->getMemory(), | ||
'size' => null, | ||
'fileName' => null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can add a mention/icon to distinguish sync and async calls in the profiler?
Closes #46
Gotenberg allows async generation of files by passing webhooks urls in dedicated headers. Doing this, the request to Gotenberg server returns a 204 immediately, and once the file is generated, a call will be made by Gotenberg server on the specified endpoint to upload the generated file. This PR aims at enabling easy integration of this feature with the bundle.
The base of the feature is a new interface
AsyncBuilderInterface
that defines agenerateAsync
method. TheAbstractPdfBuilder
andAbstractScreenshotBuilder
now implement this interface.Another important addition is the
webhookUrls(string $successWebhook, string|null $errorWebhook)
that allows directly setting the webhooks url to use with the builders.To make things easier when not working directly with urls (if you'd like to generate the url from a route, or if using the Webhook component), a some new configuration options are available :
TODO: