Skip to content

Commit 2193f47

Browse files
committed
data retrive fix
Signed-off-by: sadath-12 <[email protected]>
1 parent 1c45f4e commit 2193f47

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

service/http/topic.go

+21-4
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,25 @@ type topicEventJSON struct {
6868
PubsubName string `json:"pubsubname"`
6969
}
7070

71+
type status string
72+
73+
const (
74+
// SubscriptionResponseStatusSuccess indicates that the subscription event was processed successfully.
75+
SubscriptionResponseStatusSuccess status = "SUCCESS"
76+
)
77+
78+
type BulkSubscribeResponseEntry struct {
79+
// The id of the bulk subscribe entry
80+
entryId string
81+
82+
// The response status of the bulk subscribe entry
83+
status status
84+
}
85+
86+
type BulkSubscribeResponse struct {
87+
statuses []BulkSubscribeResponseEntry
88+
}
89+
7190
func (s *Server) registerBaseHandler() {
7291
// register subscribe handler
7392
f := func(w http.ResponseWriter, r *http.Request) {
@@ -397,7 +416,7 @@ func (s *Server) AddBulkTopicEventHandler(sub *common.Subscription, fn common.Bu
397416
return
398417
}
399418

400-
entriesInterface, ok := ins["entries"].([]interface{})
419+
entriesInterface ,ok := ins["entries"].([]interface{})
401420
if !ok {
402421
// Handle the error or return an error response
403422
http.Error(w, "Entries format error", PubSubHandlerDropStatusCode)
@@ -411,8 +430,7 @@ func (s *Server) AddBulkTopicEventHandler(sub *common.Subscription, fn common.Bu
411430
http.Error(w, "Entry format error", PubSubHandlerDropStatusCode)
412431
return
413432
}
414-
415-
itemJSON, err := json.Marshal(itemMap)
433+
itemJSON, err := json.Marshal(itemMap["event"])
416434
if err != nil {
417435
http.Error(w, err.Error(), PubSubHandlerDropStatusCode)
418436
return
@@ -423,7 +441,6 @@ func (s *Server) AddBulkTopicEventHandler(sub *common.Subscription, fn common.Bu
423441
http.Error(w, err.Error(), PubSubHandlerDropStatusCode)
424442
return
425443
}
426-
427444
data, rawData := item.getData()
428445

429446
if item.PubsubName == "" {

service/internal/topicregistrar.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ func (m TopicRegistrar) AddBulkSubscription(sub *common.Subscription, fn common.
9090
Subscription: NewTopicSubscription(sub.PubsubName, sub.Topic),
9191
RouteHandlers: make(map[string]common.TopicEventHandler),
9292
DefaultHandler: nil,
93+
BulkRouteHandlers: make(map[string]common.BulkTopicEventHandler),
94+
DefaultBulkHandler: nil,
9395
}
9496
ts.Subscription.SetMetadata(sub.Metadata)
9597
m[key] = ts
@@ -105,12 +107,16 @@ func (m TopicRegistrar) AddBulkSubscription(sub *common.Subscription, fn common.
105107
if err := ts.Subscription.SetDefaultRoute(sub.Route); err != nil {
106108
return err
107109
}
108-
// ts.DefaultBulkHandler = fn
110+
ts.DefaultBulkHandler = func(ctx context.Context, e []common.BulkTopic) (retry bool, err error) {
111+
return false,nil
112+
}
109113
ts.DefaultHandler = func(ctx context.Context, e *common.TopicEvent) (retry bool, err error) {
110114
return false,nil
111115
}
112116
}
113-
// ts.BulkRouteHandlers[sub.Route] = fn
117+
ts.BulkRouteHandlers[sub.Route] = func(ctx context.Context, e []common.BulkTopic) (retry bool, err error) {
118+
return false,nil
119+
}
114120
ts.RouteHandlers[sub.Route] = func(ctx context.Context, e *common.TopicEvent) (retry bool, err error) {
115121
return false,nil
116122
}

0 commit comments

Comments
 (0)