| 69 | } |
| 70 | |
| 71 | func (i *imlMonitorService) MapByCluster(ctx context.Context, partitionIds ...string) (map[string]*Monitor, error) { |
| 72 | if len(partitionIds) == 0 { |
| 73 | return make(map[string]*Monitor), nil |
| 74 | } |
| 75 | list, err := i.store.List(ctx, map[string]interface{}{ |
| 76 | "cluster": partitionIds, |
| 77 | }) |
| 78 | if err != nil { |
| 79 | return nil, err |
| 80 | } |
| 81 | return utils.SliceToMapO(list, func(m *monitor.Monitor) (string, *Monitor) { |
| 82 | return m.Cluster, &Monitor{ |
| 83 | ID: m.UUID, |
| 84 | Cluster: m.Cluster, |
| 85 | Driver: m.Driver, |
| 86 | Config: m.Config, |
| 87 | Creator: m.Creator, |
| 88 | Updater: m.Updater, |
| 89 | CreateAt: m.CreateAt, |
| 90 | UpdateAt: m.UpdateAt, |
| 91 | } |
| 92 | }), nil |
| 93 | } |
| 94 | |
| 95 | func (i *imlMonitorService) Save(ctx context.Context, m *SaveMonitor) error { |
| 96 | userId := utils.UserId(ctx) |