refact: to use go-dbw CreateItems, DeleteItems (#4974)

* refact: to use go-dbw CreateItems, DeleteItems

Latest version of go-dbw updated the signature of
CreateItems(...) and DeleteItems(...) on a happy
note this latest version of go-dbw actually does
batch inserts and updates for this functions.

* all: regenerate protos with new protoc-gen-go version
This commit is contained in:
Jim authored and GitHub committed 2024-08-01 11:18:53 -04:00
1 parent b24f6dcee8
commit 28b465e4b8
167 files changed
+2254 -2248

No files matched your search

@@ -74,8 +74,8 @@ func (r *Repository) AddSetMembers(ctx context.Context, projectId string, setId
return hosts, nil
}
func (r *Repository) newMembers(ctx context.Context, setId string, hostIds []string) ([]any, error) {
var members []any
func (r *Repository) newMembers(ctx context.Context, setId string, hostIds []string) ([]*HostSetMember, error) {
var members []*HostSetMember
for _, id := range hostIds {
var m *HostSetMember
m, err := NewHostSetMember(ctx, setId, id)
@@ -87,7 +87,7 @@ func (r *Repository) newMembers(ctx context.Context, setId string, hostIds []str
return members, nil
}
func createMembers(ctx context.Context, w db.Writer, members []any) ([]*oplog.Message, error) {
func createMembers(ctx context.Context, w db.Writer, members []*HostSetMember) ([]*oplog.Message, error) {
var msgs []*oplog.Message
if err := w.CreateItems(ctx, members, db.NewOplogMsgs(&msgs)); err != nil {
return nil, errors.Wrap(ctx, err, "static.createMembers")
@@ -214,7 +214,7 @@ func (r *Repository) DeleteSetMembers(ctx context.Context, projectId string, set
return len(hostIds), nil
}
func deleteMembers(ctx context.Context, w db.Writer, members []any) ([]*oplog.Message, error) {
func deleteMembers(ctx context.Context, w db.Writer, members []*HostSetMember) ([]*oplog.Message, error) {
const op = "static.deleteMembers"
var msgs []*oplog.Message
rowsDeleted, err := w.DeleteItems(ctx, members, db.NewOplogMsgs(&msgs))
@@ -261,7 +261,7 @@ func (r *Repository) SetSetMembers(ctx context.Context, projectId string, setId
if err != nil {
return nil, db.NoRowsAffected, errors.Wrap(ctx, err, op)
}
var deletions, additions []any
var deletions, additions []*HostSetMember
for _, c := range changes {
m, err := NewHostSetMember(ctx, setId, c.HostId)
if err != nil {
+7 -7
View File
@@ -3,7 +3,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.33.0
// protoc-gen-go v1.34.2
// protoc (unknown)
// source: controller/storage/host/static/store/v1/static.proto
@@ -620,7 +620,7 @@ func file_controller_storage_host_static_store_v1_static_proto_rawDescGZIP() []b
}
var file_controller_storage_host_static_store_v1_static_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
var file_controller_storage_host_static_store_v1_static_proto_goTypes = []interface{}{
var file_controller_storage_host_static_store_v1_static_proto_goTypes = []any{
(*HostCatalog)(nil), // 0: controller.storage.host.static.store.v1.HostCatalog
(*Host)(nil), // 1: controller.storage.host.static.store.v1.Host
(*HostSet)(nil), // 2: controller.storage.host.static.store.v1.HostSet
@@ -648,7 +648,7 @@ func file_controller_storage_host_static_store_v1_static_proto_init() {
return
}
if !protoimpl.UnsafeEnabled {
file_controller_storage_host_static_store_v1_static_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_host_static_store_v1_static_proto_msgTypes[0].Exporter = func(v any, i int) any {
switch v := v.(*HostCatalog); i {
case 0:
return &v.state
@@ -660,7 +660,7 @@ func file_controller_storage_host_static_store_v1_static_proto_init() {
return nil
}
}
file_controller_storage_host_static_store_v1_static_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_host_static_store_v1_static_proto_msgTypes[1].Exporter = func(v any, i int) any {
switch v := v.(*Host); i {
case 0:
return &v.state
@@ -672,7 +672,7 @@ func file_controller_storage_host_static_store_v1_static_proto_init() {
return nil
}
}
file_controller_storage_host_static_store_v1_static_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_host_static_store_v1_static_proto_msgTypes[2].Exporter = func(v any, i int) any {
switch v := v.(*HostSet); i {
case 0:
return &v.state
@@ -684,7 +684,7 @@ func file_controller_storage_host_static_store_v1_static_proto_init() {
return nil
}
}
file_controller_storage_host_static_store_v1_static_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_host_static_store_v1_static_proto_msgTypes[3].Exporter = func(v any, i int) any {
switch v := v.(*HostSetMember); i {
case 0:
return &v.state
@@ -696,7 +696,7 @@ func file_controller_storage_host_static_store_v1_static_proto_init() {
return nil
}
}
file_controller_storage_host_static_store_v1_static_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_host_static_store_v1_static_proto_msgTypes[4].Exporter = func(v any, i int) any {
switch v := v.(*UnimplementedSetFields); i {
case 0:
return &v.state