MCPcopy Create free account
hub / github.com/baidu/EasyFaaS / getCanaryFunctionBrn

Method getCanaryFunctionBrn

pkg/controller/invoke.go:245–277  ·  view source on GitHub ↗
(ctx *InvokeContext)

Source from the content-addressed store, hash-verified

243}
244
245func (controller *Controller) getCanaryFunctionBrn(ctx *InvokeContext) (err error) {
246 input := &api.GetAliasInput{
247 FunctionBrn: ctx.FunctionBRN,
248 Authorization: ctx.Authorization,
249 RequestID: ctx.RequestID,
250 AccountID: ctx.AccountID,
251 WithCache: true,
252 SimpleAuth: true,
253 }
254 // TODO: optimize getAlias api ( inside-v1 and openApi)
255 // uri & query parameter & response structure is totally different !!!
256 // force to use inside api
257 alias, _, err := controller.insideDataStorer.GetAlias(input)
258 if err != nil {
259 ctx.Logger.Debugf("function store get failed, err(%+v)", err)
260 return err
261 }
262 additionalVersion := *alias.AdditionalVersion
263 weight := *alias.AdditionalVersionWeight
264
265 if additionalVersion != "" && weight != 0 {
266 r := rand.Float64()
267 if r > weight {
268 ctx.Qualifier = alias.FunctionVersion
269 } else {
270 ctx.Qualifier = additionalVersion
271 }
272 ctx.Brn.Resource = "function:" + alias.FunctionName + ":" + ctx.Qualifier
273 ctx.FunctionBRN = ctx.Brn.String()
274 }
275
276 return nil
277}
278
279func (controller *Controller) getRuntimeConfiguration(ctx *InvokeContext) (hitCache bool, err error) {
280 if ctx.RunOptions.RecommendedOptions.Features.EnableMetrics {

Callers 1

Calls 3

DebugfMethod · 0.80
GetAliasMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected