SetModelRefreshCallback registers a callback that is invoked when startup or periodic model refresh detects changes. Only one callback is supported; subsequent calls replace the previous callback.
(cb ModelRefreshCallback)
| 50 | // periodic model refresh detects changes. Only one callback is supported; |
| 51 | // subsequent calls replace the previous callback. |
| 52 | func SetModelRefreshCallback(cb ModelRefreshCallback) { |
| 53 | refreshCallbackMu.Lock() |
| 54 | refreshCallback = cb |
| 55 | var pending []string |
| 56 | if cb != nil && len(pendingRefreshChanges) > 0 { |
| 57 | pending = append([]string(nil), pendingRefreshChanges...) |
| 58 | pendingRefreshChanges = nil |
| 59 | } |
| 60 | refreshCallbackMu.Unlock() |
| 61 | |
| 62 | if cb != nil && len(pending) > 0 { |
| 63 | cb(pending) |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | func init() { |
| 68 | // Load embedded data as fallback on startup. |
no outgoing calls
no test coverage detected