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

Add Fastly support #451

Merged
merged 13 commits into from Dec 9, 2019
Merged

Add Fastly support #451

merged 13 commits into from Dec 9, 2019

Conversation

andrerom
Copy link
Contributor

@andrerom andrerom commented May 6, 2019

Closes #403

Changes:

  • Use batch tag purging to reduce risk of hitting API limits
  • Support PurgeCapable
  • Drop multi services, does not seems to be a good fit for Purge, & unsure what the use case is
  • Added unit testing

Follow Up topics:

Context of this:

  • eZ Platform (v3) is being worked on by @ViniTou to remove several of our HttpCache abstractions and move to FosHttpCache 2.x, which means we among other things we'd like Fastly support on FosHttpCache level instead ;)

@dbu
Copy link
Contributor

dbu commented May 7, 2019

thanks for picking this one up again. great if we can get this in!

while having some demo or something to validate that it works with the actual api, i agree that the automated tests should not talk with actual fastly. could you use the MockClient of httplug to expect requests and return canned responses so we can do a functional test within our application boundary?

src/ProxyClient/Fastly.php Outdated Show resolved Hide resolved
src/Test/Proxy/FastlyProxy.php Outdated Show resolved Hide resolved
@andrerom andrerom changed the title Fastly support [WIP] Fastly support Jun 13, 2019
@dbu
Copy link
Contributor

dbu commented Jun 13, 2019 via email

@andrerom
Copy link
Contributor Author

I suggest that we do some functional tests with the httplug mock client
and/or the vcr-plugin.

Any existing FOSHttpCache examples of that?

@dbu
Copy link
Contributor

dbu commented Jun 14, 2019

no such examples, so far we have only unit tests and full integration tests (we install nginx and varnish in travis-ci).
you can set the vcr plugin to record mode and run it with an actual fastly, to have it generate the fixtures. maybe we can use a constant that can be set to activate passthrough mode and configuration for a fastly account so that phpunit.xml can be used to locally run tests against an actual fastly instance, while using the fixtures in the ci.

@dbu dbu mentioned this pull request Jun 20, 2019
@andrerom andrerom changed the title [WIP] Fastly support Add Fastly support Jul 29, 2019
@andrerom
Copy link
Contributor Author

andrerom commented Jul 29, 2019

@dbu / @Toflar Unit tests added, so I'm considering this to be more or less ready.

Only thing I'm considering from my POV is adding refresh() using two requests, one to soft purge the url and then second one to load it. WDYT?

@Toflar
Copy link
Contributor

Toflar commented Jul 29, 2019

Only thing I'm considering from my POV is adding refresh() using two requests, one to soft purge the url and then second one to load it. WDYT?

I did that in my LiteSpeed PR as well so if it works, why not? 😄

@dbu
Copy link
Contributor

dbu commented Jul 29, 2019

sure, if we can't do it in one then that sounds fine. with varnish / symfony you can do a request forcing a backend lookup, but when that is not available, doing 2 requests seems fine to me. needs to be sure there is no race condition though (doing the request before the cache got purged)

@andrerom
Copy link
Contributor Author

Added.

@vvuksan Would you be able to verify if what's added here* successfully will trigger a refresh of a url? Or if you would recommend another way? e.g undocumented API or something ;)

* TL;DR;

  1. soft PURGE of url
  2. HEAD request for url

@andrerom
Copy link
Contributor Author

andrerom commented Aug 7, 2019

@dbu / @Toflar Ready for review afaik.

@dbu
Copy link
Contributor

dbu commented Aug 7, 2019

build errors should go away once symfony/symfony#32802 is tagged

Copy link
Contributor

@dbu dbu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! this seems reasonable uncomplicated

src/ProxyClient/Fastly.php Outdated Show resolved Hide resolved
src/ProxyClient/Fastly.php Show resolved Hide resolved
@dbu
Copy link
Contributor

dbu commented Aug 8, 2019

oh, and link to fastly docs is of course a good idea!

can you please also add an entry in the changelog and add info in the documentation? https://github.com/FriendsOfSymfony/FOSHttpCache/tree/master/doc

i'd squash all commits, even though that will mash together the git attribution to just one of you. hope you don't mind? otherwise i squash to 2 commits to keep your things separate.

@Toflar do you see anything else or should i merge when we have the documentation? i plan a new minor version once this is released.

Copy link
Contributor

@Toflar Toflar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Toflar do you see anything else or should i merge when we have the documentation? i plan a new minor version once this is released.

Just a minor CS nitpick, the rest looks very simple and straightforward to me. Great addition because it requires zero proxy setup. I wish we had the same for KeyCDN :)
Should definitely be merged once the docs are added. Well done, @andrerom!

tests/Unit/ProxyClient/FastlyTest.php Outdated Show resolved Hide resolved
@andrerom
Copy link
Contributor Author

andrerom commented Aug 8, 2019

Fixed a few things, notable:

  • Please use GH suggest feature so we can speed up here ;)
  • Realized that I was missing API endpoint for invalidation() and clear() => So unless unclear: There has been no functional tests here yet, that is a must before release. Contribution on that would be great, otherwise I'll need to check internally who might be able to do that.


* ``service_identifier``: Identifier for your Fastly service account.
* ``authentication_token``: User token for authentication against Fastly APIs.
* NB: To be able to clear all cache(`->clear()`), you'll need a token for user with Fastly "Engineer permissions".
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very cool! this is exactly what such documentation should help people with, remove wtf moments 👍

@dbu dbu mentioned this pull request Aug 8, 2019
src/ProxyClient/Fastly.php Outdated Show resolved Hide resolved
src/ProxyClient/Fastly.php Outdated Show resolved Hide resolved
src/ProxyClient/Fastly.php Outdated Show resolved Hide resolved
@dbu
Copy link
Contributor

dbu commented Aug 8, 2019

Please use GH suggest feature so we can speed up here ;)

oh, will try that next time, seems nice.

Realized that I was missing API endpoint for invalidation() and clear() => So unless unclear: There has been no functional tests here yet, that is a must before release. Contribution on that would be great, otherwise I'll need to check internally who might be able to do that.

i never used fastly. maybe @hpatoio wants to try to do that?

@hpatoio
Copy link
Contributor

hpatoio commented Aug 8, 2019

i never used fastly. maybe @hpatoio wants to try to do that?

Ciao. Cool you finalized my PR. We are not using this bundle anymore (went for a different solution) but I'm happy to help. What do you exactly need ? Sorry but the conversation in the PR is a bit long and a recap could help

@dbu
Copy link
Contributor

dbu commented Aug 8, 2019

hey hpatoio, good to see you (even if just virtually) - andré said that there are some tests missing. @andrerom can you explain in more detail what tests you would want? end-to-end tests with an actual fastly seems difficult to achieve to me...

@andrerom
Copy link
Contributor Author

andrerom commented Aug 9, 2019

end-to-end tests with an actual fastly seems difficult to achieve to me...

this is what I had in mind

@hpatoio
Copy link
Contributor

hpatoio commented Aug 9, 2019

end-to-end tests with an actual fastly seems difficult to achieve to me...

Got it. For NGINX/Varnish we create services usign the .sh and the we run the e2e tests. For Fastly you wanna do the same but using a real Fastly service. Going to figure out something.

@dbu
Copy link
Contributor

dbu commented Nov 27, 2019

can we wrap this up somehow? i'd be ok to merge without functional test and add a warning in the doc that fastly support is experimental.

@Toflar
Copy link
Contributor

Toflar commented Nov 27, 2019

To be fair I think there's nothing else we can do other than checking that the API requests are correct. We don't need to functional test the API of Fastly, that's their responsiblity. So imho this doesn't need to be experimental :)

@andrerom
Copy link
Contributor Author

Ok with me, rebased and pushed.

@dbu
Copy link
Contributor

dbu commented Nov 27, 2019

@Toflar well, without an end-to-end test we can't be sure that our assumptions about the fastly api are correct. but yeah, utlimately that is up to everybody building an application with these components, as otherwise we still can't be sure if it works. and really would not want to run something that talks to fastly in the FOSHttpCache travis-ci setup.

@andrerom can you please apply the cs fixer thingies? the travis failure is "only" the python sphinx installation to test the doc. that is a known problem and not related to your changes.

@andrerom
Copy link
Contributor Author

andrerom commented Dec 8, 2019

@dbu CS fixes and change to use request body has been pushed.

Copy link
Contributor

@Toflar Toflar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a minor docs formatting issue but I would love to see this merged as is 👍

doc/proxy-clients.rst Outdated Show resolved Hide resolved
Co-Authored-By: Yanick Witschi <yanick.witschi@terminal42.ch>
Copy link
Contributor

@dbu dbu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hooray!

@dbu dbu merged commit 3c1cb34 into FriendsOfSymfony:master Dec 9, 2019
@dbu
Copy link
Contributor

dbu commented Dec 9, 2019

thanks a lot for your persistence!

@Toflar
Copy link
Contributor

Toflar commented Dec 9, 2019

Thanks André - great stuff!

@andrerom andrerom deleted the fastly_support branch December 9, 2019 09:26
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.

None yet

5 participants