dynamo-browse/internal/sqs-browse/providers/stormstore/memstore.go

32 lines
574 B
Go
Raw Normal View History

package stormstore
import (
"context"
"github.com/asdine/storm"
2022-07-28 11:36:16 +00:00
"github.com/lmika/audax/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)
}