1
0

session.go 599 B

123456789101112131415161718192021222324252627282930
  1. package sessions
  2. import (
  3. "time"
  4. uuid "github.com/gofrs/uuid"
  5. )
  6. // EventCounts register how many handled/unhandled events have happened for
  7. // this session
  8. type EventCounts struct {
  9. Handled int `json:"handled"`
  10. Unhandled int `json:"unhandled"`
  11. }
  12. // Session represents a start time and a unique ID that identifies the session.
  13. type Session struct {
  14. StartedAt time.Time
  15. ID uuid.UUID
  16. EventCounts *EventCounts
  17. }
  18. func newSession() *Session {
  19. sessionID, _ := uuid.NewV4()
  20. return &Session{
  21. StartedAt: time.Now(),
  22. ID: sessionID,
  23. EventCounts: &EventCounts{},
  24. }
  25. }