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:
Soam Vasani
2016-11-04 23:05:29 -07:00
parent 22583481a4
commit f3eba4b825
3 changed files with 67 additions and 2 deletions
+17
View File
@@ -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
}