Raises a DB state change event based on the db name, admininterface, new state, reason and local system time. If the event manager doesn't have a listener for this event, ignores.
(ctx context.Context, dbName string, state string, reason string, adminInterface *string)
| 180 | // Raises a DB state change event based on the db name, admininterface, new state, reason and local system time. |
| 181 | // If the event manager doesn't have a listener for this event, ignores. |
| 182 | func (em *EventManager) RaiseDBStateChangeEvent(ctx context.Context, dbName string, state string, reason string, adminInterface *string) error { |
| 183 | |
| 184 | if !em.activeEventTypes[DBStateChange] { |
| 185 | return nil |
| 186 | } |
| 187 | |
| 188 | adminInterfaceStr := "" |
| 189 | if adminInterface != nil { |
| 190 | adminInterfaceStr = *adminInterface |
| 191 | } |
| 192 | |
| 193 | body := make(Body, 5) |
| 194 | body["dbname"] = dbName |
| 195 | body["admininterface"] = adminInterfaceStr |
| 196 | body["state"] = state |
| 197 | body["reason"] = reason |
| 198 | body["localtime"] = time.Now().Format(base.ISO8601Format) |
| 199 | |
| 200 | event := &DBStateChangeEvent{ |
| 201 | Doc: body, |
| 202 | } |
| 203 | |
| 204 | return em.raiseEvent(ctx, event) |
| 205 | } |