sqs-browse: remove assumption regarding table keys
Table keys are now retrieved from describe
This commit is contained in:
parent
3428bd2a8a
commit
5a69e6c954
47 changed files with 150 additions and 98 deletions
|
|
@ -4,6 +4,8 @@ import (
|
|||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/aws/aws-sdk-go-v2/config"
|
||||
"github.com/aws/aws-sdk-go-v2/service/dynamodb"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
|
|
@ -15,7 +17,6 @@ import (
|
|||
"github.com/lmika/awstools/internal/dynamo-browse/services/tables"
|
||||
"github.com/lmika/awstools/internal/dynamo-browse/ui"
|
||||
"github.com/lmika/gopkgs/cli"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -49,8 +50,8 @@ func main() {
|
|||
|
||||
commandController := commandctrl.NewCommandController(map[string]uimodels.Operation{
|
||||
"scan": tableReadController.Scan(),
|
||||
"rw": tableWriteController.ToggleReadWrite(),
|
||||
"dup": tableWriteController.Duplicate(),
|
||||
"rw": tableWriteController.ToggleReadWrite(),
|
||||
"dup": tableWriteController.Duplicate(),
|
||||
})
|
||||
|
||||
uiModel := ui.NewModel(uiDispatcher, commandController, tableReadController, tableWriteController)
|
||||
|
|
@ -77,4 +78,3 @@ type msgLoopback struct {
|
|||
func (m *msgLoopback) Send(msg tea.Msg) {
|
||||
m.program.Send(msg)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@ import (
|
|||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/aws/aws-sdk-go-v2/config"
|
||||
"github.com/aws/aws-sdk-go-v2/service/sqs"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
|
|
@ -17,8 +20,6 @@ import (
|
|||
"github.com/lmika/awstools/internal/sqs-browse/ui"
|
||||
"github.com/lmika/events"
|
||||
"github.com/lmika/gopkgs/cli"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -39,7 +40,7 @@ func main() {
|
|||
if err != nil {
|
||||
cli.Fatalf("cannot create workspace file: %v", err)
|
||||
}
|
||||
workspaceFile.Close() // We just need the filename
|
||||
workspaceFile.Close() // We just need the filename
|
||||
|
||||
msgStore, err := stormstore.NewStore(workspaceFile.Name())
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -3,15 +3,16 @@ package main
|
|||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
"github.com/aws/aws-sdk-go-v2/config"
|
||||
"github.com/aws/aws-sdk-go-v2/service/sqs"
|
||||
"github.com/aws/aws-sdk-go-v2/service/sqs/types"
|
||||
"github.com/pkg/errors"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/lmika/gopkgs/cli"
|
||||
)
|
||||
|
|
@ -44,9 +45,9 @@ func main() {
|
|||
msgCount := 0
|
||||
for {
|
||||
out, err := client.ReceiveMessage(ctx, &sqs.ReceiveMessageInput{
|
||||
QueueUrl: aws.String(*flagQueue),
|
||||
QueueUrl: aws.String(*flagQueue),
|
||||
MaxNumberOfMessages: 10,
|
||||
WaitTimeSeconds: 1,
|
||||
WaitTimeSeconds: 1,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("error receiving messages: %v", err)
|
||||
|
|
@ -59,7 +60,7 @@ func main() {
|
|||
for _, msg := range out.Messages {
|
||||
if err := handleMessage(ctx, outDir, msg); err == nil {
|
||||
messagesToDelete = append(messagesToDelete, types.DeleteMessageBatchRequestEntry{
|
||||
Id: msg.MessageId,
|
||||
Id: msg.MessageId,
|
||||
ReceiptHandle: msg.ReceiptHandle,
|
||||
})
|
||||
msgCount += 1
|
||||
|
|
@ -74,7 +75,7 @@ func main() {
|
|||
|
||||
if _, err := client.DeleteMessageBatch(ctx, &sqs.DeleteMessageBatchInput{
|
||||
QueueUrl: aws.String(*flagQueue),
|
||||
Entries: messagesToDelete,
|
||||
Entries: messagesToDelete,
|
||||
}); err != nil {
|
||||
log.Printf("error deleting messages from queue: %v", err)
|
||||
break
|
||||
|
|
@ -85,7 +86,7 @@ func main() {
|
|||
}
|
||||
|
||||
func handleMessage(ctx context.Context, outDir string, msg types.Message) error {
|
||||
outFile := filepath.Join(outDir, aws.ToString(msg.MessageId) + ".json")
|
||||
outFile := filepath.Join(outDir, aws.ToString(msg.MessageId)+".json")
|
||||
msgBody := aws.ToString(msg.Body)
|
||||
|
||||
log.Printf("%v -> %v", aws.ToString(msg.MessageId), outFile)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue