Skip to content

Commit

Permalink
fix: re-add exported symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
hperl committed Nov 8, 2023
1 parent 58bd38f commit 9986c62
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
15 changes: 10 additions & 5 deletions courier/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ type MessageStatus int
const (
MessageStatusQueued MessageStatus = iota + 1
MessageStatusSent
_
MessageStatusProcessing
MessageStatusAbandoned
)

const (
messageStatusQueuedText = "queued"
messageStatusSentText = "sent"
messageStatusAbandonedText = "abandoned"
messageStatusQueuedText = "queued"
messageStatusSentText = "sent"
messageStatusProcessingText = "processing"
messageStatusAbandonedText = "abandoned"
)

func ToMessageStatus(str string) (MessageStatus, error) {
Expand All @@ -40,6 +41,8 @@ func ToMessageStatus(str string) (MessageStatus, error) {
return MessageStatusQueued, nil
case s.AddCase(MessageStatusSent.String()):
return MessageStatusSent, nil
case s.AddCase(MessageStatusProcessing.String()):
return MessageStatusProcessing, nil
case s.AddCase(MessageStatusAbandoned.String()):
return MessageStatusAbandoned, nil
default:
Expand All @@ -53,6 +56,8 @@ func (ms MessageStatus) String() string {
return messageStatusQueuedText
case MessageStatusSent:
return messageStatusSentText
case MessageStatusProcessing:
return messageStatusProcessingText
case MessageStatusAbandoned:
return messageStatusAbandonedText
default:
Expand All @@ -62,7 +67,7 @@ func (ms MessageStatus) String() string {

func (ms MessageStatus) IsValid() error {
switch ms {
case MessageStatusQueued, MessageStatusSent, MessageStatusAbandoned:
case MessageStatusQueued, MessageStatusSent, MessageStatusProcessing, MessageStatusAbandoned:
return nil
default:
return errors.WithStack(herodot.ErrBadRequest.WithReason("Message status is not valid"))
Expand Down
7 changes: 4 additions & 3 deletions courier/message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ func TestMessageStatusValidity(t *testing.T) {
func TestToMessageStatus(t *testing.T) {
t.Run("case=should return corresponding MessageStatus for given str", func(t *testing.T) {
for str, exp := range map[string]courier.MessageStatus{
"queued": courier.MessageStatusQueued,
"sent": courier.MessageStatusSent,
"abandoned": courier.MessageStatusAbandoned,
"queued": courier.MessageStatusQueued,
"sent": courier.MessageStatusSent,
"processing": courier.MessageStatusProcessing,
"abandoned": courier.MessageStatusAbandoned,
} {
result, err := courier.ToMessageStatus(str)
require.NoError(t, err)
Expand Down
3 changes: 3 additions & 0 deletions courier/persistence.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ package courier

import (
"context"
"errors"

"github.com/gofrs/uuid"

"github.com/ory/x/pagination/keysetpagination"
)

var ErrQueueEmpty = errors.New("queue is empty")

type (
Persister interface {
AddMessage(context.Context, *Message) error
Expand Down

0 comments on commit 9986c62

Please sign in to comment.