dynamo-browse/internal/sqs-browse/providers/memstore/memstore.go
Leon Mika 5d1f4c78f4 sqs-browse: new tool
Started working on a new tool to poll and browse an SQS queue.  This is built using a TUI framework
2022-03-23 08:58:42 +11:00

32 lines
499 B
Go

package memstore
import (
"context"
"github.com/lmika/awstools/internal/sqs-browse/models"
"sync"
)
type Store struct {
messages []models.Message
mtx *sync.Mutex
currSeqNo uint64
}
func (s *Store) Save(ctx context.Context, msg *models.Message) error {
s.mtx.Lock()
defer s.mtx.Unlock()
s.currSeqNo++
msg.ID = s.currSeqNo
s.messages = append(s.messages, *msg)
return nil
}
func NewStore() *Store {
return &Store{
messages: make([]models.Message, 0),
mtx: new(sync.Mutex),
}
}