@@ -40,68 +40,6 @@ func newSQS(client sdkclient.SQS, queue string) *SQS {
4040 return & SQS {client : client , queue : queue }
4141}
4242
43- // func (s *SQS) Store(ctx context.Context, storedBatch Batch) error {
44- // var jsonLogs []json.RawMessage
45- // if err := json.Unmarshal(storedBatch.Data, &jsonLogs); err != nil {
46- // return fmt.Errorf("unmarshal: %w", err)
47- // }
48-
49- // var (
50- // entries []types.SendMessageBatchRequestEntry
51- // currentChunk []json.RawMessage
52- // batchID int
53- // messageSize = 2 // '[' and ']'
54- // batchSize int
55- // )
56-
57- // for _, jsonLog := range jsonLogs {
58- // if len(jsonLog) > maxSizePerSQSMessage {
59- // slog.WarnContext(ctx, "log size exceeds SQS message limit, dropping", slog.Int("size", len(jsonLog)))
60- // continue
61- // }
62-
63- // logSize := len(jsonLog)
64- // if len(currentChunk) > 0 {
65- // logSize++ // ',' separator
66- // }
67-
68- // if messageSize+logSize > maxSizePerSQSMessage {
69- // entry, err := s.buildEntry(batchID, currentChunk, storedBatch.StorageTag)
70- // if err != nil {
71- // return err
72- // }
73-
74- // if len(entries) >= maxMessagePerBatch || batchSize+messageSize > maxSizePerSQSBatch {
75- // if err := s.sendBatch(ctx, entries); err != nil {
76- // return err
77- // }
78- // entries = entries[:0]
79- // batchSize = 0
80- // }
81-
82- // entries = append(entries, entry)
83- // batchSize += messageSize
84- // batchID++
85- // currentChunk = currentChunk[:0]
86- // messageSize = 2
87- // logSize = len(jsonLog)
88- // }
89-
90- // currentChunk = append(currentChunk, jsonLog)
91- // messageSize += logSize
92- // }
93-
94- // if len(currentChunk) > 0 {
95- // entry, err := s.buildEntry(batchID, currentChunk, storedBatch.StorageTag)
96- // if err != nil {
97- // return err
98- // }
99- // entries = append(entries, entry)
100- // }
101-
102- // return s.sendBatch(ctx, entries)
103- // }
104-
10543func (s * SQS ) Store (ctx context.Context , storedBatch Batch ) error {
10644 var logs []json.RawMessage
10745 if err := json .Unmarshal (storedBatch .Data , & logs ); err != nil {
@@ -159,13 +97,12 @@ func (s *SQS) send(ctx context.Context, entries []types.SendMessageBatchRequestE
15997 if len (out .Failed ) > 0 {
16098 for _ , e := range out .Failed {
16199 slog .DebugContext (ctx , "failed to send SQS message" ,
162- slog .String ("id" , aws .ToString (e .Id )),
163100 slog .String ("code" , aws .ToString (e .Code )),
164101 slog .String ("message" , aws .ToString (e .Message )),
165102 slog .Bool ("sender_fault" , e .SenderFault ),
166103 )
167104 }
168- return fmt .Errorf ("%d/%d messages failed to send " , len (out .Failed ), len (out .Failed )+ len (out .Successful ))
105+ return fmt .Errorf ("failed to send %d/%d messages" , len (out .Failed ), len (out .Failed )+ len (out .Successful ))
169106 }
170107
171108 return nil
0 commit comments