ashishk-1 commented on a change in pull request #1969: Integration of envoy 
fetcher in pagespeed
URL: 
https://github.com/apache/incubator-pagespeed-mod/pull/1969#discussion_r356637002
 
 

 ##########
 File path: pagespeed/envoy/envoy_fetch.cc
 ##########
 @@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "envoy_fetch.h"
+
+#include <algorithm>
+#include <string>
+#include <vector>
+#include <list>
+#include <map>
+#include <set>
+
+#include "net/instaweb/http/public/async_fetch.h"
+#include "net/instaweb/http/public/inflating_fetch.h"
+#include "pagespeed/kernel/base/basictypes.h"
+#include "pagespeed/kernel/base/condvar.h"
+#include "pagespeed/kernel/base/message_handler.h"
+#include "pagespeed/kernel/base/pool.h"
+#include "pagespeed/kernel/base/pool_element.h"
+#include "pagespeed/kernel/base/statistics.h"
+#include "pagespeed/kernel/base/string_util.h"
+#include "pagespeed/kernel/base/thread_system.h"
+#include "pagespeed/kernel/base/timer.h"
+#include "pagespeed/kernel/base/writer.h"
+#include "pagespeed/kernel/http/request_headers.h"
+#include "pagespeed/kernel/http/response_headers.h"
+#include "pagespeed/kernel/http/response_headers_parser.h"
+#include "pagespeed_remote_data_fetcher.h"
+#include "pagespeed/envoy/header_utils.h"
+
+namespace net_instaweb {
+
+// Default keepalive 60s.
+const int64 keepalive_timeout_ms = 60000;
+
+PagespeedDataFetcherCallback::PagespeedDataFetcherCallback(EnvoyFetch* fetch) 
{ 
+  fetch_ = fetch;
+}
+
+void PagespeedDataFetcherCallback::onSuccess(Envoy::Http::MessagePtr& 
response) {
+  fetch_->setResponse(response->headers(), response->body());
+}
+
+void PagespeedDataFetcherCallback::onFailure(FailureReason reason) {
+  std::cout << "PagespeedDataFetcherCallback::onFailure\n";
+  std::cout.flush();
+}
+
+EnvoyFetch::EnvoyFetch(const GoogleString& url,
+                   AsyncFetch* async_fetch,
+                   MessageHandler* message_handler,
+                   EnvoyClusterManager& cluster_manager)
+    : str_url_(url),
+      fetcher_(NULL),
+      async_fetch_(async_fetch),
+      message_handler_(message_handler),
+      cluster_manager_(cluster_manager),
+      done_(false),
+      content_length_(-1),
+      content_length_known_(false) {
+}
+
+EnvoyFetch::~EnvoyFetch() {
+}
+
+void EnvoyFetch::FetchWithEnvoy() {
+  envoy::api::v2::core::HttpUri http_uri;
+  http_uri.set_uri("http://localhost:80";);
+  http_uri.set_cluster("cluster1");
 
 Review comment:
   Defined cluster1 as static const string. Code pushed in 
https://github.com/apache/incubator-pagespeed-mod/pull/1969/commits/05e80e98faba31ff5a94f1244b1833fa88a1fae4
   
   As of now, hardcoded cluster from cluster.yaml file is getting referred. We 
will move this to API based implementation and then will add dynamic proxy 
support.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to