本文整理匯總了Golang中github.com/codedellemc/libstorage/api/types.Context.Warn方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.Warn方法的具體用法?Golang Context.Warn怎麽用?Golang Context.Warn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/codedellemc/libstorage/api/types.Context
的用法示例。
在下文中一共展示了Context.Warn方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: handleWithMiddleware
func (s *server) handleWithMiddleware(
ctx types.Context,
route types.Route) types.APIFunc {
/*if route.GetMethod() == "HEAD" {
return route.GetHandler()
}*/
handler := route.GetHandler()
middlewaresForRouteName, ok := s.routeHandlers[route.GetName()]
if !ok {
ctx.Warn("no middlewares for route")
} else {
for h := range reverse(middlewaresForRouteName) {
handler = h.Handler(handler)
ctx.WithField(
"middleware", h.Name()).Debug("added route middleware")
}
}
// add the global handlers
for h := range reverse(s.globalHandlers) {
handler = h.Handler(handler)
ctx.WithField(
"middleware", h.Name()).Debug("added global middleware")
}
return handler
}
示例2: dial
func (c *client) dial(ctx types.Context) error {
ctx.WithField("path", lsxMutex).Info("lsx lock file path")
svcInfos, err := c.Services(ctx)
if err != nil {
return err
}
// controller clients do not have any additional dialer logic
if c.isController() {
return nil
}
store := utils.NewStore()
c.ctx = c.ctx.WithValue(context.ServerKey, c.ServerName())
if !c.config.GetBool(types.ConfigExecutorNoDownload) {
ctx.Info("initializing executors cache")
if _, err := c.Executors(ctx); err != nil {
return err
}
if err := c.updateExecutor(ctx); err != nil {
return err
}
}
for service, _ := range svcInfos {
ctx := c.ctx.WithValue(context.ServiceKey, service)
ctx.Info("initializing supported cache")
supported, err := c.Supported(ctx, store)
if err != nil {
return goof.WithError("error initializing supported cache", err)
}
if !supported {
ctx.Warn("executor not supported")
continue
}
ctx.Info("initializing instance ID cache")
if _, err := c.InstanceID(ctx, store); err != nil {
if err == types.ErrNotImplemented {
ctx.WithError(err).Warn("cannot get instance ID")
continue
}
return goof.WithError("error initializing instance ID cache", err)
}
}
return nil
}