Skip to content

Commit 9217d77

Browse files
committed
fixed listOperations types
1 parent b32f0d9 commit 9217d77

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

operation/client.go

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@ type (
2424
operationServiceClient Ydb_Operation_V1.OperationServiceClient
2525
}
2626
// Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
27+
listOperationsWithNextToken[PT metadata.Constraint[T], T metadata.TypesConstraint] struct {
28+
listOperations[PT, T]
29+
NextToken string
30+
}
31+
// Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
2732
listOperations[PT metadata.Constraint[T], T metadata.TypesConstraint] struct {
28-
NextToken string
2933
Operations []*typedOperation[PT, T]
3034
}
3135
operation struct {
@@ -87,9 +91,9 @@ func get(
8791

8892
func list[PT metadata.Constraint[T], T metadata.TypesConstraint](
8993
ctx context.Context, client Ydb_Operation_V1.OperationServiceClient, request *Ydb_Operations.ListOperationsRequest,
90-
) (*listOperations[PT, T], error) {
94+
) (*listOperationsWithNextToken[PT, T], error) {
9195
operations, err := retry.RetryWithResult(ctx, func(ctx context.Context) (
92-
operations *listOperations[PT, T], _ error,
96+
operations *listOperationsWithNextToken[PT, T], _ error,
9397
) {
9498
response, err := client.ListOperations(conn.WithoutWrapping(ctx), request)
9599
if err != nil {
@@ -103,9 +107,11 @@ func list[PT metadata.Constraint[T], T metadata.TypesConstraint](
103107
))
104108
}
105109

106-
operations = &listOperations[PT, T]{
107-
NextToken: response.GetNextPageToken(),
108-
Operations: make([]*typedOperation[PT, T], 0, len(response.GetOperations())),
110+
operations = &listOperationsWithNextToken[PT, T]{
111+
listOperations: listOperations[PT, T]{
112+
Operations: make([]*typedOperation[PT, T], 0, len(response.GetOperations())),
113+
},
114+
NextToken: response.GetNextPageToken(),
109115
}
110116

111117
for _, op := range response.GetOperations() {
@@ -231,7 +237,7 @@ func (c *Client) ListBuildIndex(ctx context.Context) (
231237
return nil, xerrors.WithStackTrace(err)
232238
}
233239

234-
return operations, nil
240+
return &operations.listOperations, nil
235241
}
236242

237243
// ListImportFromS3 returns list of import from s3 operations
@@ -253,7 +259,7 @@ func (c *Client) ListImportFromS3(ctx context.Context) (
253259
return nil, xerrors.WithStackTrace(err)
254260
}
255261

256-
return operations, nil
262+
return &operations.listOperations, nil
257263
}
258264

259265
// ListExportToS3 returns list of export to s3 operations
@@ -275,7 +281,7 @@ func (c *Client) ListExportToS3(ctx context.Context) (
275281
return nil, xerrors.WithStackTrace(err)
276282
}
277283

278-
return operations, nil
284+
return &operations.listOperations, nil
279285
}
280286

281287
// ListExportToYT returns list of export to YT operations
@@ -297,14 +303,14 @@ func (c *Client) ListExportToYT(ctx context.Context) (
297303
return nil, xerrors.WithStackTrace(err)
298304
}
299305

300-
return operations, nil
306+
return &operations.listOperations, nil
301307
}
302308

303309
// ListExecuteQuery returns list of query executions
304310
//
305311
// Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
306312
func (c *Client) ListExecuteQuery(ctx context.Context, opts ...options.List) (
307-
*listOperations[*metadata.ExecuteQuery, metadata.ExecuteQuery], error,
313+
*listOperationsWithNextToken[*metadata.ExecuteQuery, metadata.ExecuteQuery], error,
308314
) {
309315
request := &options.ListOperationsRequest{
310316
ListOperationsRequest: Ydb_Operations.ListOperationsRequest{

0 commit comments

Comments
 (0)