Skip to content

Commit d345520

Browse files
committed
refactor: Move parsing into listStoreObjects func
Signed-off-by: suod-NithishKarthik <[email protected]>
1 parent 31be971 commit d345520

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

meshsync/handlers.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ func (h *Handler) ListenToRequests() {
8282
h.Log.Error(err)
8383
continue
8484
}
85-
8685
replySubject := payload.Reply
8786

8887
if !allInformersCacheSynced {
@@ -97,14 +96,10 @@ func (h *Handler) ListenToRequests() {
9796
continue
9897
}
9998

100-
h.Log.Info("Sending the current state of the informer store to ", replySubject)
10199
storeObjects := h.listStoreObjects()
102-
newList := make([]model.Object, 0)
103-
for _, obj := range storeObjects {
104-
newList = append(newList, model.ParseList(*obj.(*unstructured.Unstructured)))
105-
}
100+
splitSlices := splitIntoMultipleSlices(storeObjects, 5) // performance of NATS is bound to degrade if huge messages are sent
106101

107-
splitSlices := splitIntoMultipleSlices(newList, 5)
102+
h.Log.Info("Publishing the data from informer stores to the subject: ", replySubject)
108103
for _, val := range splitSlices {
109104
err = h.Broker.Publish(replySubject, &broker.Message{
110105
Object: val,
@@ -136,12 +131,16 @@ func (h *Handler) ListenToRequests() {
136131
}
137132
}
138133

139-
func (h *Handler) listStoreObjects() []interface{} {
134+
func (h *Handler) listStoreObjects() []model.Object {
140135
objects := make([]interface{}, 0)
141136
for _, v := range h.stores {
142137
objects = append(objects, v.List()...)
143138
}
144-
return objects
139+
parsedObjects := make([]model.Object, 0)
140+
for _, obj := range objects {
141+
parsedObjects = append(parsedObjects, model.ParseList(*obj.(*unstructured.Unstructured)))
142+
}
143+
return parsedObjects
145144
}
146145

147146
// TODO: move this to meshkit

0 commit comments

Comments
 (0)