Skip to content

Commit defe086

Browse files
committed
fix linter warnings
1 parent 31cfafc commit defe086

File tree

6 files changed

+32
-20
lines changed

6 files changed

+32
-20
lines changed

examples/topic/topicreader/topic_reader_transaction.go

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func CommitMessagesToTransaction(ctx context.Context, db *ydb.Driver, reader *to
1919
if err != nil {
2020
return err
2121
}
22-
id := batch.Messages[0].MessageGroupID
22+
id := batch.Messages[0].MessageGroupID //nolint:staticcheck
2323

2424
batchResult, err := processBatch(batch.Context(), batch)
2525
if err != nil {
@@ -30,8 +30,12 @@ func CommitMessagesToTransaction(ctx context.Context, db *ydb.Driver, reader *to
3030
$last = SELECT MAX(val) FROM table WHERE id=$id;
3131
UPSERT INTO t (id, val) VALUES($id, COALESCE($last, 0) + $value)
3232
`, query.WithParameters(
33-
ydb.ParamsBuilder().Param("$id").Text(id).Param("$value").Int64(int64(batchResult)).Build(),
33+
ydb.ParamsBuilder().
34+
Param("$id").Text(id).
35+
Param("$value").Int64(int64(batchResult)).
36+
Build(),
3437
))
38+
3539
return err
3640
})
3741
if err != nil {
@@ -51,7 +55,7 @@ func PopWithTransaction(ctx context.Context, db *ydb.Driver, reader *topicreader
5155
if err != nil {
5256
return err
5357
}
54-
id := batch.Messages[0].MessageGroupID
58+
id := batch.Messages[0].MessageGroupID //nolint:staticcheck
5559

5660
batchResult, err := processBatch(batch.Context(), batch)
5761
if err != nil {
@@ -62,10 +66,13 @@ func PopWithTransaction(ctx context.Context, db *ydb.Driver, reader *topicreader
6266
$last = SELECT MAX(val) FROM table WHERE id=$id;
6367
UPSERT INTO t (id, val) VALUES($id, COALESCE($last, 0) + $value)
6468
`, query.WithParameters(
65-
ydb.ParamsBuilder().Param("$id").Text(id).Param("$value").Int64(int64(batchResult)).Build(),
69+
ydb.ParamsBuilder().
70+
Param("$id").Text(id).
71+
Param("$value").Int64(int64(batchResult)).
72+
Build(),
6673
))
6774
if err != nil {
68-
return nil
75+
return err
6976
}
7077

7178
return nil
@@ -99,7 +106,7 @@ func PopWithTransactionRecreateReader(
99106
if err != nil {
100107
return err
101108
}
102-
id := batch.Messages[0].MessageGroupID
109+
id := batch.Messages[0].MessageGroupID //nolint:staticcheck
103110

104111
batchResult, err := processBatch(batch.Context(), batch)
105112
if err != nil {
@@ -109,11 +116,15 @@ func PopWithTransactionRecreateReader(
109116
_, err = tx.Execute(ctx, `
110117
$last = SELECT MAX(val) FROM table WHERE id=$id;
111118
UPSERT INTO t (id, val) VALUES($id, COALESCE($last, 0) + $value)
112-
`, query.WithParameters(
113-
ydb.ParamsBuilder().Param("$id").Text(id).Param("$value").Int64(int64(batchResult)).Build(),
114-
))
119+
`,
120+
query.WithParameters(
121+
ydb.ParamsBuilder().
122+
Param("$id").Text(id).
123+
Param("$value").Int64(int64(batchResult)).
124+
Build(),
125+
))
115126
if err != nil {
116-
return nil
127+
return err
117128
}
118129

119130
if err = tx.CommitTx(ctx); err != nil {

examples/topic/topicreader/topicreader_advanced.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func ReadMessagesWithCustomBatching(ctx context.Context, db *ydb.Driver) {
1616

1717
for {
1818
batch, _ := reader.ReadMessagesBatch(ctx)
19-
processBatch(batch.Context(), batch)
19+
_, _ = processBatch(batch.Context(), batch)
2020
_ = reader.Commit(batch.Context(), batch)
2121
}
2222
}
@@ -58,7 +58,7 @@ func ProcessMessagesWithSyncCommit(ctx context.Context, db *ydb.Driver) {
5858

5959
for {
6060
batch, _ := reader.ReadMessagesBatch(ctx)
61-
processBatch(batch.Context(), batch)
61+
_, _ = processBatch(batch.Context(), batch)
6262
_ = reader.Commit(ctx, batch) // will wait response about commit from server
6363
}
6464
}
@@ -86,7 +86,7 @@ func OwnReadProgressStorage(ctx context.Context, db *ydb.Driver) {
8686
for {
8787
batch, _ := reader.ReadMessagesBatch(ctx)
8888

89-
processBatch(batch.Context(), batch)
89+
_, _ = processBatch(batch.Context(), batch)
9090
_ = externalSystemCommit(
9191
batch.Context(),
9292
batch.Topic(),

examples/topic/topicreader/topicreader_handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (h *TopicEventsHandler) OnReadMessages(
4848
log.Printf("Receive message: %v/%v/%v", mess.Topic(), mess.PartitionID(), mess.SeqNo)
4949
}
5050

51-
processBatch(ctx, event.Batch)
51+
_, _ = processBatch(ctx, event.Batch)
5252

5353
return nil
5454
}

examples/topic/topicreader/topicreader_show.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func PartitionStopHandled(ctx context.Context, reader *topicreader.Reader) {
1515
}
1616

1717
batchContext := batch.Context() // batch.Context() will cancel when partition revoke by server or connection broke
18-
processBatch(batchContext, batch)
18+
_, _ = processBatch(batchContext, batch)
1919
}
2020

2121
// PartitionGracefulStopHandled is example of sdk handle server signal about graceful stop partition
@@ -24,7 +24,7 @@ func PartitionGracefulStopHandled(ctx context.Context, db *ydb.Driver) {
2424

2525
for {
2626
batch, _ := reader.ReadMessagesBatch(ctx) // <- if partition soft stop batch can be less, then 1000
27-
processBatch(batch.Context(), batch)
27+
_, _ = processBatch(batch.Context(), batch)
2828
_ = reader.Commit(batch.Context(), batch)
2929
}
3030
}

examples/topic/topicreader/topicreader_simple.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import (
55
"fmt"
66
"io"
77

8+
firestore "google.golang.org/genproto/firestore/bundle"
9+
810
"github.com/ydb-platform/ydb-go-sdk/v3/topic/topicreader"
911
"github.com/ydb-platform/ydb-go-sdk/v3/topic/topicsugar"
10-
firestore "google.golang.org/genproto/firestore/bundle"
1112
)
1213

1314
// PrintMessageContent is simple example for easy start read messages
@@ -25,7 +26,7 @@ func PrintMessageContent(ctx context.Context, reader *topicreader.Reader) {
2526
func ReadMessagesByBatch(ctx context.Context, reader *topicreader.Reader) {
2627
for {
2728
batch, _ := reader.ReadMessagesBatch(ctx)
28-
processBatch(batch.Context(), batch)
29+
_, _ = processBatch(batch.Context(), batch)
2930
_ = reader.Commit(batch.Context(), batch)
3031
}
3132
}

examples/topic/topicreader/topicreader_trace.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func ExplicitPartitionStartStopHandler(ctx context.Context, db *ydb.Driver) {
7373
for {
7474
batch, _ := reader.ReadMessagesBatch(readContext)
7575

76-
processBatch(batch.Context(), batch)
76+
_, _ = processBatch(batch.Context(), batch)
7777
_ = externalSystemCommit(
7878
batch.Context(),
7979
batch.Topic(),
@@ -145,7 +145,7 @@ func PartitionStartStopHandlerAndOwnReadProgressStorage(ctx context.Context, db
145145
for {
146146
batch, _ := r.ReadMessagesBatch(readContext)
147147

148-
processBatch(batch.Context(), batch)
148+
_, _ = processBatch(batch.Context(), batch)
149149
_ = externalSystemCommit(batch.Context(), batch.Topic(), batch.PartitionID(), getEndOffset(batch))
150150
}
151151
}

0 commit comments

Comments
 (0)