event_type.go 822 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package borealis
  2. import (
  3. "fmt"
  4. )
  5. type EventType uint16
  6. func GetEventType(payload interface{}) EventType {
  7. switch payload.(type) {
  8. case GrantAccess:
  9. return EventTypeGrantAccess
  10. case RegisterID:
  11. return EventTypeRegisterID
  12. case RevokeAccess:
  13. return EventTypeRevokeAccess
  14. case SendEmail:
  15. return EventTypeSendEmail
  16. case VerifyEmail:
  17. return EventTypeVerifyEmail
  18. default:
  19. return EventTypeUnknown
  20. }
  21. }
  22. func (type_ EventType) String() string {
  23. switch type_ {
  24. case EventTypeGrantAccess:
  25. return "GrantAccess"
  26. case EventTypeRegisterID:
  27. return "RegisterID"
  28. case EventTypeRevokeAccess:
  29. return "RevokeAccess"
  30. case EventTypeSendEmail:
  31. return "SendEmail"
  32. case EventTypeVerifyEmail:
  33. return "VerifyEmail"
  34. case EventTypeUnknown:
  35. return "Unknown"
  36. }
  37. return fmt.Sprintf("Unknown(%d)", int(type_))
  38. }