OwnCost returns only this session's direct cost: its own messages and item-level costs (e.g. compaction). It excludes sub-session costs. This is used for live event emissions where sub-sessions report their own costs separately.
()
| 985 | // This is used for live event emissions where sub-sessions report their |
| 986 | // own costs separately. |
| 987 | func (s *Session) OwnCost() float64 { |
| 988 | s.mu.RLock() |
| 989 | defer s.mu.RUnlock() |
| 990 | |
| 991 | var cost float64 |
| 992 | for _, item := range s.Messages { |
| 993 | if item.IsMessage() { |
| 994 | cost += item.Message.Message.Cost |
| 995 | } |
| 996 | cost += item.Cost |
| 997 | } |
| 998 | return cost |
| 999 | } |
| 1000 | |
| 1001 | // now returns the session's current time, falling back to time.Now for |
| 1002 | // sessions created without a clock (e.g. JSON deserialization). |