MCPcopy Create free account
hub / github.com/APIParkLab/APIPark / Save

Method Save

service/monitor/iml.go:95–121  ·  view source on GitHub ↗
(ctx context.Context, m *SaveMonitor)

Source from the content-addressed store, hash-verified

93}
94
95func (i *imlMonitorService) Save(ctx context.Context, m *SaveMonitor) error {
96 userId := utils.UserId(ctx)
97 now := time.Now()
98 info, err := i.store.First(ctx, map[string]interface{}{
99 "cluster": m.Cluster,
100 })
101 if err != nil {
102 if !errors.Is(err, gorm.ErrRecordNotFound) {
103 return err
104 }
105 info = &monitor.Monitor{
106 UUID: uuid.New().String(),
107 Cluster: m.Cluster,
108 Driver: m.Driver,
109 Config: m.Config,
110 Creator: userId,
111 Updater: userId,
112 CreateAt: now,
113 UpdateAt: now,
114 }
115 } else {
116 info.Config = m.Config
117 info.Updater = userId
118 info.UpdateAt = now
119 }
120 return i.store.Save(ctx, info)
121}
122
123var (
124 _ IMonitorStatisticsCache = (*imlMonitorStatisticsCacheService)(nil)

Callers

nothing calls this directly

Calls 2

SaveMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected