question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple loaders configured at once

See original GitHub issue

It would be nice to be able to configure multiple loaders at once, e.g. URL & S3 loader like we do with the detectors:

LOADER = [
    'tc_aws.loaders.s3_loader',
    'thumbor.loaders.http_loader'
]

Thus the following URLs would get handled differently:

https://thumbor-server/fit-in/400x300/my/s3/image.png -> handled by tc_aws.loaders.s3_loader https://thumbor-server/fit-in/400x300/https://example.com/my/url/image.png -> handled by thumbor.loaders.http_loader, as tc_aws.loaders.s3_loader failed to load the image

This would allow for stacking multiple loaders and would make the thumbor.loaders.file_loader_http_fallback obsolete, as this could be handled by configuring the file and http loader.

We currently need this feature for the s3 loader and this loader has no fallback, like the default file loader. This change in handling loaders would it make obsolete to have a fallback for each loader implementation.

What do you guys think?

_Edit: Correction, the s3 loader actually has a http fallback (TC_AWS_ENABLE_HTTP_LOADER), see https://github.com/thumbor-community/aws_

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
heynemanncommented, Jan 29, 2019

Hey @bkonetzny I prefer to keep it simpler. If we introduce this logic, we would have to change our loaders to actually perform the logic you described whereas if we just introduce a new loader (FallbackLoader?) we can be explicit on what the user wants.

Something like you described would be the config for this loader:

FALLBACK_LOADER_LOADERS = [
    'thumbor.loaders.file_loader',
    'thumbor.loaders.http_loader',
]

That way we keep thumbor working the way it is, this pattern already exists in the codebase (MixedStorage) and it keeps working with whatever loader is out there.

The first loader that responds without error “wins”. What do you guys think?

2reactions
heynemanncommented, Mar 20, 2019

Go ahead! 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Loaders - webpack
Loaders are transformations that are applied to the source code of a module. They allow you to pre-process files as you import or...
Read more >
How to add a query to a webpack loader with multiple loaders?
The way to do this is to set the query parameters in the loader string itself, as the query object key will only...
Read more >
How to properly use multiple loaders with this plugin? #330
I am trying to configure this plugin to extract multiple loaders (start with sass, end with css). The piece of configuration code in...
Read more >
Webpack — The Confusing Parts - Medium
Multiple Loaders can be chained and made to work on the same file type. The chaining works from right-to-left and the loader are...
Read more >
API - esbuild
echo 'let x: number = 1' | esbuild --loader=tslet x = 1; require('esbuild'). ... The build API call operates on one or more...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found