sqs-browse: remove assumption regarding table keys

Table keys are now retrieved from describe
This commit is contained in:
Leon Mika 2022-03-25 08:17:52 +11:00
parent 3428bd2a8a
commit 5a69e6c954
47 changed files with 150 additions and 98 deletions

View file

@ -2,6 +2,7 @@ package controllers
import (
"context"
"github.com/lmika/awstools/internal/common/ui/uimodels"
"github.com/lmika/awstools/internal/sqs-browse/models"
"github.com/lmika/awstools/internal/sqs-browse/services/messages"

View file

@ -3,9 +3,9 @@ package models
import "time"
type Message struct {
ID uint64 `storm:"id,increment"`
ExtID string `storm:"unique"`
Queue string `storm:"index"`
ID uint64 `storm:"id,increment"`
ExtID string `storm:"unique"`
Queue string `storm:"index"`
Received time.Time
Data string
}

View file

@ -2,13 +2,14 @@ package sqs
import (
"context"
"log"
"time"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/sqs"
"github.com/aws/aws-sdk-go-v2/service/sqs/types"
"github.com/lmika/awstools/internal/sqs-browse/models"
"github.com/pkg/errors"
"log"
"time"
)
type Provider struct {
@ -23,7 +24,7 @@ func (p *Provider) SendMessage(ctx context.Context, msg models.Message, queue st
// TEMP :: queue URL
out, err := p.client.SendMessage(ctx, &sqs.SendMessageInput{
QueueUrl: aws.String(queue),
QueueUrl: aws.String(queue),
MessageBody: aws.String(msg.Data),
})
if err != nil {

View file

@ -2,6 +2,7 @@ package stormstore
import (
"context"
"github.com/asdine/storm"
"github.com/lmika/awstools/internal/sqs-browse/models"
"github.com/pkg/errors"

View file

@ -2,9 +2,10 @@ package messages
import (
"context"
"github.com/lmika/awstools/internal/sqs-browse/models"
)
type MessageSender interface {
SendMessage(ctx context.Context, msg models.Message, queue string) (string, error)
}
}

View file

@ -2,6 +2,7 @@ package messages
import (
"context"
"github.com/lmika/awstools/internal/sqs-browse/models"
"github.com/pkg/errors"
)

View file

@ -2,6 +2,7 @@ package pollmessage
import (
"context"
"github.com/lmika/awstools/internal/sqs-browse/models"
)
@ -11,4 +12,4 @@ type MessageStore interface {
type MessagePoller interface {
PollForNewMessages(ctx context.Context, queue string) ([]*models.Message, error)
}
}

View file

@ -2,9 +2,10 @@ package pollmessage
import (
"context"
"log"
"github.com/lmika/events"
"github.com/pkg/errors"
"log"
)
type Service struct {

View file

@ -2,4 +2,4 @@ package ui
import "github.com/lmika/awstools/internal/sqs-browse/models"
type NewMessagesEvent []*models.Message
type NewMessagesEvent []*models.Message

View file

@ -4,6 +4,9 @@ import (
"bytes"
"context"
"encoding/json"
"log"
"strings"
table "github.com/calyptia/go-bubble-table"
"github.com/charmbracelet/bubbles/textinput"
"github.com/charmbracelet/bubbles/viewport"
@ -14,19 +17,17 @@ import (
"github.com/lmika/awstools/internal/common/ui/uimodels"
"github.com/lmika/awstools/internal/sqs-browse/controllers"
"github.com/lmika/awstools/internal/sqs-browse/models"
"log"
"strings"
)
var (
activeHeaderStyle = lipgloss.NewStyle().
Bold(true).
Foreground(lipgloss.Color("#ffffff")).
Background(lipgloss.Color("#eac610"))
Bold(true).
Foreground(lipgloss.Color("#ffffff")).
Background(lipgloss.Color("#eac610"))
inactiveHeaderStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#000000")).
Background(lipgloss.Color("#d1d1d1"))
Foreground(lipgloss.Color("#000000")).
Background(lipgloss.Color("#d1d1d1"))
)
type uiModel struct {
@ -52,12 +53,12 @@ func NewModel(dispatcher *dispatcher.Dispatcher, msgSendingHandlers *controllers
textInput := textinput.New()
model := uiModel{
table: tbl,
tableRows: rows,
message: "",
textInput: textInput,
table: tbl,
tableRows: rows,
message: "",
textInput: textInput,
msgSendingHandlers: msgSendingHandlers,
dispatcher: dispatcher,
dispatcher: dispatcher,
}
return model

View file

@ -2,10 +2,11 @@ package ui
import (
"fmt"
"github.com/lmika/awstools/internal/sqs-browse/models"
table "github.com/calyptia/go-bubble-table"
"io"
"strings"
table "github.com/calyptia/go-bubble-table"
"github.com/lmika/awstools/internal/sqs-browse/models"
)
type messageTableRow models.Message