Call poolmgr from router while using a cached service
Poolmgr needs to know usage statistics for a function's pod. This change asynchronously taps poolmgr API when router uses a service. Poolmgr can use this information to control pod expiry. It may also be useful later as one of the metrics for autoscaling.
This commit is contained in:
@@ -24,6 +24,7 @@ import (
|
||||
"encoding/json"
|
||||
"github.com/platform9/fission"
|
||||
"io/ioutil"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
@@ -58,3 +59,19 @@ func (c *Client) GetServiceForFunction(metadata *fission.Metadata) (string, erro
|
||||
|
||||
return string(svcName), nil
|
||||
}
|
||||
|
||||
func (c *Client) TapService(serviceUrl *url.URL) error {
|
||||
url := c.poolmgrUrl + "/v1/tapService"
|
||||
|
||||
serviceUrlStr := serviceUrl.String()
|
||||
|
||||
resp, err := http.Post(url, "application/octet-stream", bytes.NewReader([]byte(serviceUrlStr)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != 200 {
|
||||
return fission.MakeErrorFromHTTP(resp)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user