sqs-browse: new tool
Started working on a new tool to poll and browse an SQS queue. This is built using a TUI framework
This commit is contained in:
parent
e070505490
commit
5d1f4c78f4
11 changed files with 413 additions and 0 deletions
31
internal/sqs-browse/providers/memstore/memstore.go
Normal file
31
internal/sqs-browse/providers/memstore/memstore.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
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),
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue