| 1 | package sessioncatalog |
| 2 | |
| 3 | // DiscoveryEvent correlates admission with actual iterator dispatch. Root is |
| 4 | // a process-local number, not a hash of a private path; failure is a category, |
| 5 | // never a filesystem/database error string that could include content. |
| 6 | type DiscoveryEvent struct { |
| 7 | Root uint64 |
| 8 | Sequence uint64 |
| 9 | Phase string |
| 10 | Origin string |
| 11 | Failure string |
| 12 | } |
| 13 | |
| 14 | func (c *Catalog) observeDiscovery(target DirectoryTarget, phase, origin, failure string) { |
| 15 | if c.opts.OnDiscovery == nil { |
| 16 | return |
| 17 | } |
| 18 | key := queuePathKey(target.Path) |
| 19 | id, exists := c.discoveryIDs.Load(key) |
| 20 | if !exists { |
| 21 | id, _ = c.discoveryIDs.LoadOrStore(key, c.discoverySeq.Add(1)) |
| 22 | } |
| 23 | c.opts.OnDiscovery(DiscoveryEvent{Root: id.(uint64), Sequence: target.mutationSeq, Phase: phase, Origin: origin, Failure: failure}) |
| 24 | } |
| 25 |