Large functions: API proxy for storage svc, upload support in the CLI (#304)

This change contains CLI support for uploading large functions to the storage service.

It also adds a reverse proxy into the storage service to the fission API.

The helm chart is not yet updated to actually run the storage service -- that will come in the next change.
This commit is contained in:
Soam Vasani
2017-08-31 15:42:59 -07:00
committed by GitHub
parent 9d1b096bac
commit 8d103fa35b
4 changed files with 115 additions and 35 deletions
+13 -2
View File
@@ -35,7 +35,8 @@ import (
type (
API struct {
fissionClient *tpr.FissionClient
fissionClient *tpr.FissionClient
storageServiceUrl string
}
logDBConfig struct {
@@ -46,7 +47,16 @@ type (
)
func MakeAPI() (*API, error) {
return makeTPRBackedAPI()
api, err := makeTPRBackedAPI()
u := os.Getenv("STORAGE_SERVICE_URL")
if len(u) > 0 {
api.storageServiceUrl = strings.TrimSuffix(u, "/")
} else {
api.storageServiceUrl = "http://storagesvc"
}
return api, err
}
func (api *API) respondWithSuccess(w http.ResponseWriter, resp []byte) {
@@ -149,6 +159,7 @@ func (api *API) Serve(port int) {
r.HandleFunc("/v2/triggers/messagequeue/{mqTrigger}", api.MessageQueueTriggerApiDelete).Methods("DELETE")
r.HandleFunc("/proxy/{dbType}", api.FunctionLogsApiPost).Methods("POST")
r.HandleFunc("/proxy/storage/v1/archive", api.StorageServiceProxy)
address := fmt.Sprintf(":%v", port)
+38
View File
@@ -0,0 +1,38 @@
/*
Copyright 2017 The Fission Authors.
Licensed 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.
*/
package controller
import (
"fmt"
"log"
"net/http"
"net/http/httputil"
"net/url"
)
func (api *API) StorageServiceProxy(w http.ResponseWriter, r *http.Request) {
u := api.storageServiceUrl + "/v1/archive"
ssUrl, err := url.Parse(u)
if err != nil {
msg := fmt.Sprintf("Error parsing url %v: %v", u, err)
log.Println(msg)
http.Error(w, msg, 500)
return
}
proxy := httputil.NewSingleHostReverseProxy(ssUrl)
proxy.ServeHTTP(w, r)
}