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

Method getFunctionByFunctionBrn

pkg/controller/invoke.go:207–243  ·  view source on GitHub ↗
(ctx *InvokeContext, input *api.GetFunctionInput)

Source from the content-addressed store, hash-verified

205}
206
207func (controller *Controller) getFunctionByFunctionBrn(ctx *InvokeContext, input *api.GetFunctionInput) (hitCache bool, err error) {
208 hitCache = false
209 if ctx.Brn, err = parseBrn(ctx); err != nil {
210 return
211 }
212 // get latest version function without cache
213 ctx.Logger.V(6).Infof("brn version %+v", ctx.Qualifier)
214
215 if !api.RegVersion.MatchString(ctx.Qualifier) {
216 if !controller.runOptions.EnableCanary {
217 err = innerErr.NewInvalidParameterValueException("invalid brn", nil)
218 return false, err
219 }
220 if err := controller.getCanaryFunctionBrn(ctx); err != nil {
221 return false, err
222 }
223 }
224
225 if ctx.Qualifier == "$LATEST" {
226 input.WithCache = false
227 }
228 brnStr := ctx.Brn.String()
229 input.SetFunctionName(brnStr).SetQualifier(ctx.Qualifier)
230 ctx.Logger.Debugf("function_input=%v", input)
231
232 defer ctx.Logger.TimeTrack(time.Now(), "GetFunction",
233 zap.String("function_name", *input.FunctionName),
234 zap.String("qualifier", *input.Qualifier),
235 )
236
237 if ctx.Function, hitCache, err = ctx.Clients.DataStorer.GetFunction(input); err != nil {
238 ctx.Logger.Debugf("function store get failed, err(%+v)", err)
239 return hitCache, err
240 }
241
242 return hitCache, nil
243}
244
245func (controller *Controller) getCanaryFunctionBrn(ctx *InvokeContext) (err error) {
246 input := &api.GetAliasInput{

Callers 1

getFunctionMethod · 0.95

Calls 8

getCanaryFunctionBrnMethod · 0.95
parseBrnFunction · 0.85
InfofMethod · 0.80
VMethod · 0.80
DebugfMethod · 0.80
TimeTrackMethod · 0.80
StringMethod · 0.65
GetFunctionMethod · 0.65

Tested by

no test coverage detected