MCPcopy Index your code
hub / github.com/openfaas/faas / NewExternalServiceQuery

Function NewExternalServiceQuery

gateway/plugin/external.go:36–59  ·  view source on GitHub ↗

NewExternalServiceQuery proxies service queries to external plugin via HTTP

(externalURL url.URL, authInjector middleware.AuthInjector)

Source from the content-addressed store, hash-verified

34
35// NewExternalServiceQuery proxies service queries to external plugin via HTTP
36func NewExternalServiceQuery(externalURL url.URL, authInjector middleware.AuthInjector) scaling.ServiceQuery {
37 timeout := 3 * time.Second
38
39 proxyClient := http.Client{
40 Transport: &http.Transport{
41 Proxy: http.ProxyFromEnvironment,
42 DialContext: (&net.Dialer{
43 Timeout: timeout,
44 KeepAlive: 0,
45 }).DialContext,
46 MaxIdleConns: 1,
47 DisableKeepAlives: true,
48 IdleConnTimeout: 120 * time.Millisecond,
49 ExpectContinueTimeout: 1500 * time.Millisecond,
50 },
51 }
52
53 return ExternalServiceQuery{
54 URL: externalURL,
55 ProxyClient: proxyClient,
56 AuthInjector: authInjector,
57 IncludeUsage: false,
58 }
59}
60
61// GetReplicas replica count for function
62func (s ExternalServiceQuery) GetReplicas(serviceName, serviceNamespace string) (scaling.ServiceQueryResponse, error) {

Callers 5

mainFunction · 0.92

Calls

no outgoing calls

Tested by 4

Used in the wild real call sites across dependent graphs

searching dependent graphs…