| 260 | } |
| 261 | |
| 262 | func feedMonitors(ctx *Context) { |
| 263 | ctx.Server.Monitors.Range(func(k, v interface{}) bool { |
| 264 | mCtx := v.(*Context) |
| 265 | if mCtx.Client.Namespace != sysAdminNamespace && mCtx.Client.Namespace != ctx.Client.Namespace { |
| 266 | return true |
| 267 | } |
| 268 | |
| 269 | now := time.Now().UnixNano() / 1000 |
| 270 | ts := strconv.FormatFloat(float64(now)/1000000, 'f', -1, 64) |
| 271 | id := strconv.FormatInt(int64(ctx.Client.DB.ID), 10) |
| 272 | |
| 273 | line := ts + " [" + id + " " + ctx.Client.RemoteAddr + "]" + " " + ctx.Name + " " + strings.Join(ctx.Args, " ") |
| 274 | start := time.Now() |
| 275 | err := resp.ReplySimpleString(mCtx.Out, line) |
| 276 | zap.L().Debug("feedMonitors reply", zap.String("name", ctx.Name), zap.Int64("cost(us)", time.Since(start).Nanoseconds()/1000)) |
| 277 | if err != nil { |
| 278 | ctx.Server.Monitors.Delete(k) |
| 279 | } |
| 280 | |
| 281 | return true |
| 282 | }) |
| 283 | } |
| 284 | |
| 285 | // Executor executes a command |
| 286 | type Executor struct { |