entities.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package backwards_invocation
  2. type RequestEvent string
  3. const (
  4. REQUEST_EVENT_RESPONSE RequestEvent = "response"
  5. REQUEST_EVENT_ERROR RequestEvent = "error"
  6. REQUEST_EVENT_END RequestEvent = "end"
  7. )
  8. type BackwardsInvocationResponseEvent struct {
  9. BackwardsRequestId string `json:"backwards_request_id"`
  10. Event RequestEvent `json:"event"`
  11. Message string `json:"message"`
  12. Data map[string]any `json:"data"`
  13. }
  14. func NewResponseEvent(request_id string, message string, data map[string]any) *BackwardsInvocationResponseEvent {
  15. return &BackwardsInvocationResponseEvent{
  16. BackwardsRequestId: request_id,
  17. Event: REQUEST_EVENT_RESPONSE,
  18. Message: message,
  19. Data: data,
  20. }
  21. }
  22. func NewErrorEvent(request_id string, message string) *BackwardsInvocationResponseEvent {
  23. return &BackwardsInvocationResponseEvent{
  24. BackwardsRequestId: request_id,
  25. Event: REQUEST_EVENT_ERROR,
  26. Message: message,
  27. Data: nil,
  28. }
  29. }
  30. func NewEndEvent(request_id string) *BackwardsInvocationResponseEvent {
  31. return &BackwardsInvocationResponseEvent{
  32. BackwardsRequestId: request_id,
  33. Event: REQUEST_EVENT_END,
  34. Message: "",
  35. Data: nil,
  36. }
  37. }