sqs-browse: added notion of workspaces in sqs-browse
Also added a tool to generate test tables
This commit is contained in:
parent
cecdbafabb
commit
30dbc4eefe
16 changed files with 239 additions and 60 deletions
|
|
@ -1,31 +0,0 @@
|
|||
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),
|
||||
}
|
||||
}
|
||||
30
internal/sqs-browse/providers/stormstore/memstore.go
Normal file
30
internal/sqs-browse/providers/stormstore/memstore.go
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
package stormstore
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/asdine/storm"
|
||||
"github.com/lmika/awstools/internal/sqs-browse/models"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type Store struct {
|
||||
db *storm.DB
|
||||
}
|
||||
|
||||
// TODO: should probably be a workspace provider
|
||||
func NewStore(filename string) (*Store, error) {
|
||||
db, err := storm.Open(filename)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "cannot open store %v", filename)
|
||||
}
|
||||
|
||||
return &Store{db: db}, nil
|
||||
}
|
||||
|
||||
func (s *Store) Close() {
|
||||
s.db.Close()
|
||||
}
|
||||
|
||||
func (s *Store) Save(ctx context.Context, msg *models.Message) error {
|
||||
return s.db.Save(msg)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue