Files
fission-src/router/util.go
T
Erwin van EykandSoam Vasani 33f967b61b Fission workflow env integration (#336)
Add a flag to the environment to control multiple specialization -- the max number of functions per container. This can be set to 1 or infinity. 

Add an api proxy to workflow apiserver from the controller.

Add function metadata to FunctionLoadRequest; every v2 environment now knows which function it's loading (but can ignore that information if it wants to).

Add function identity headers to router. This is useful for multiple specialization, so the router can disambiguate between different function calls. (If this turns out to be a non-trivial perf overhead, we could add these headers conditionally, but for now they are always added.)
2017-09-26 18:36:07 -07:00

29 lines
961 B
Go

package router
import (
"fmt"
"k8s.io/client-go/1.5/pkg/api"
"k8s.io/client-go/1.5/pkg/types"
"net/http"
)
const (
HEADERS_FISSION_FUNCTION_PREFIX = "Fission-Function"
)
func MetadataToHeaders(prefix string, meta *api.ObjectMeta, request *http.Request) {
request.Header.Add(fmt.Sprintf("X-%s-Uid", prefix), string(meta.UID))
request.Header.Add(fmt.Sprintf("X-%s-Name", prefix), meta.Name)
request.Header.Add(fmt.Sprintf("X-%s-Namespace", prefix), meta.Namespace)
request.Header.Add(fmt.Sprintf("X-%s-ResourceVersion", prefix), meta.ResourceVersion)
}
func HeadersToMetadata(prefix string, headers http.Header) *api.ObjectMeta {
return &api.ObjectMeta{
Name: headers.Get(fmt.Sprintf("X-%s-Name", prefix)),
UID: types.UID(headers.Get(fmt.Sprintf("X-%s-Uid", prefix))),
Namespace: headers.Get(fmt.Sprintf("X-%s-Namespace", prefix)),
ResourceVersion: headers.Get(fmt.Sprintf("X-%s-ResourceVersion", prefix)),
}
}