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

Edge cache integration #231

Merged
merged 33 commits into from Oct 5, 2017
Merged

Edge cache integration #231

merged 33 commits into from Oct 5, 2017

Conversation

baconmania
Copy link
Contributor

No description provided.

Copy link
Member

@ssalinas ssalinas left a comment

Choose a reason for hiding this comment

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

👍 overall. Still not sure on making the config more generic. There are some tricky jackson things we could probably do to have separate classes and serialize as a different one depending on the value of that enum field. Alternatively we could have an edge cache associated with a specific baragon group (since they are generally each associated with a domain anyways).

*/
@Override
public boolean invalidateIfNecessary(BaragonRequest request) {
if (request.getLoadBalancerService().getOptions().get("edgeCacheDNS") == null) {
Copy link
Member

Choose a reason for hiding this comment

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

edgeCacheDNS as a static variable since it's used a few times?

}

private Optional<CloudflareZone> getCloudflareZone(String edgeCacheDNS) throws CloudflareClientException {
List<CloudflareZone> zones = cf.getAllZones();
Copy link
Member

Choose a reason for hiding this comment

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

how expensive is this call? Should this be cached at all?


// The following three values are used by the Cloudflare EdgeCache implementation.
// TODO: It's kind of a smell to have implementation-specific configs in the generic EdgeCacheConfiguration block.
// TODO: Is there a better way of doing this?
Copy link
Member

Choose a reason for hiding this comment

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

I think these fields are generic enough that they would work for more cases. Still thinking on ways we could make it more generic/reusable. I'll comment if I come up with something

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, I'm not familiar with how Dropwizard YAML -> Config Class magic works specifically, but can we just have a Map<String, String> options in the EdgeCacheConfiguration class, and then document the specific supported options for each EdgeCache implementation?

}

try {
String edgeCacheDNS = ((String) request.getLoadBalancerService().getOptions().get("edgeCacheDNS"));
Copy link
Member

Choose a reason for hiding this comment

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

would it make more sense to make this an explicit field on the BaragonService instead of having it be something in the options? The options have generally been used with the purpose of injecting data into the templates to be rendered, which is why it is a <String, Object> instead of something more specific. If we have an optional field on the baragon service, it's then a much cleaner call like service.getEdgeCacheDNS.isPresent().

Also, I could see a case where an app is hosted on multiple domains (multiple Baragon groups) and might need multiple things cleared in which case it'd need to be more of a list of domains. Do we expect to need to handle that use case?


return cf.purgeCache(
zoneId,
Collections.singletonList( // TODO this isn't the right way to get the env, is it vvv
Copy link
Member

Choose a reason for hiding this comment

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

Baragon doesn't have a concept of the internal HubSpot env. Would it make more sense to either:

  • have the list of cache tag formats provided on the BaragonService

or

  • configure the list of cache tag formats to be cleared in the config yaml

Copy link
Member

@ssalinas ssalinas left a comment

Choose a reason for hiding this comment

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

Looks good. Not required for this PR by any means, by as a future nice to have it could be good to have some indicator on the BaragonResponse as to whether or not the cache purge succeeded or failed

@ssalinas ssalinas changed the title (WIP) Edge cache integration Edge cache integration Oct 4, 2017
@ssalinas ssalinas added the qa label Oct 4, 2017
@ssalinas ssalinas merged commit f234c94 into master Oct 5, 2017
@ssalinas ssalinas deleted the edge-cache-integration branch October 5, 2017 14:16
@ssalinas ssalinas added this to the 0.6.0 milestone Feb 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants