Skip to content

Commit

Permalink
Use utils.PBool instead of inline functions
Browse files Browse the repository at this point in the history
  • Loading branch information
radekg committed Dec 3, 2021
1 parent 3975377 commit 29825e7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 23 deletions.
26 changes: 8 additions & 18 deletions client/implementation/op_snapshots_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

"github.com/radekg/yugabyte-db-go-client/configs"
"github.com/radekg/yugabyte-db-go-client/utils"
"github.com/radekg/yugabyte-db-go-client/utils/ybdbid"
ybApi "github.com/radekg/yugabyte-db-go-proto/v2/yb/api"
)
Expand Down Expand Up @@ -79,15 +80,9 @@ func createSnapshotYCQL(c *defaultYBCliClient, opConfig *configs.OpSnapshotCreat
}

payload := &ybApi.CreateSnapshotRequestPB{
Tables: tableIdentifiers,
AddIndexes: func() *bool {
v := true // https://github.com/yugabyte/yugabyte-db/blob/d4d5688147734d1a36bbe58430f35ba4db2770f1/ent/src/yb/tools/yb-admin_cli_ent.cc#L119
return &v
}(),
TransactionAware: func() *bool {
v := true // https://github.com/yugabyte/yugabyte-db/blob/d4d5688147734d1a36bbe58430f35ba4db2770f1/ent/src/yb/tools/yb-admin_client_ent.cc#L247
return &v
}(),
Tables: tableIdentifiers,
AddIndexes: utils.PBool(true), // https://github.com/yugabyte/yugabyte-db/blob/d4d5688147734d1a36bbe58430f35ba4db2770f1/ent/src/yb/tools/yb-admin_cli_ent.cc#L119
TransactionAware: utils.PBool(true), // https://github.com/yugabyte/yugabyte-db/blob/d4d5688147734d1a36bbe58430f35ba4db2770f1/ent/src/yb/tools/yb-admin_client_ent.cc#L247
}

responsePayload := &ybApi.CreateSnapshotResponsePB{}
Expand Down Expand Up @@ -119,17 +114,12 @@ func createSnapshotYSQL(c *defaultYBCliClient, opConfig *configs.OpSnapshotCreat

payload := &ybApi.CreateSnapshotRequestPB{
Tables: tableIdentifiers,
AddIndexes: func() *bool {
v := false
return &v
}(),
// CreateSnapshot called from https://github.com/yugabyte/yugabyte-db/blob/d4d5688147734d1a36bbe58430f35ba4db2770f1/ent/src/yb/tools/yb-admin_client_ent.cc#L288
// CreateSnapshot called with add_indexes=false
// from https://github.com/yugabyte/yugabyte-db/blob/d4d5688147734d1a36bbe58430f35ba4db2770f1/ent/src/yb/tools/yb-admin_client_ent.cc#L288
// and always sets transaction aware to true:
// https://github.com/yugabyte/yugabyte-db/blob/d4d5688147734d1a36bbe58430f35ba4db2770f1/ent/src/yb/tools/yb-admin_client_ent.cc#L247
TransactionAware: func() *bool {
v := true
return &v
}(),
AddIndexes: utils.PBool(false),
TransactionAware: utils.PBool(true),
}

responsePayload := &ybApi.CreateSnapshotResponsePB{}
Expand Down
7 changes: 2 additions & 5 deletions client/implementation/op_snapshots_export.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@ func (c *defaultYBCliClient) SnapshotsExport(opConfig *configs.OpSnapshotExportC
}

payload := &ybApi.ListSnapshotsRequestPB{
PrepareForBackup: func() *bool {
v := true
return &v
}(),
SnapshotId: ybDbID.Bytes(),
PrepareForBackup: utils.PBool(true),
SnapshotId: ybDbID.Bytes(),
}
responsePayload := &ybApi.ListSnapshotsResponsePB{}
if err := c.connectedClient.Execute(payload, responsePayload); err != nil {
Expand Down

0 comments on commit 29825e7

Please sign in to comment.