@@ -156,39 +156,25 @@ func (s *streamManager) getSubscriptions(ctx context.Context) (subs []*subscript
156156 return subs , nil
157157}
158158
159- func (s * streamManager ) getSubscription (ctx context.Context , subID string ) (sub * subscription , err error ) {
159+ func (s * streamManager ) getSubscription (ctx context.Context , subID string , okNotFound bool ) (sub * subscription , err error ) {
160160 res , err := s .client .R ().
161161 SetContext (ctx ).
162162 SetResult (& sub ).
163163 Get (fmt .Sprintf ("/subscriptions/%s" , subID ))
164164 if err != nil || ! res .IsSuccess () {
165+ if okNotFound && res .StatusCode () == 404 {
166+ return nil , nil
167+ }
165168 return nil , ffresty .WrapRestErr (ctx , res , err , coremsgs .MsgFabconnectRESTErr )
166169 }
167170 return sub , nil
168171}
169172
170- func (s * streamManager ) checkSubscriptionExistence (ctx context.Context , subID string ) (found bool , err error ) {
171- sub := & subscription {}
172- res , err := s .client .R ().
173- SetContext (ctx ).
174- SetResult (& sub ).
175- Get (fmt .Sprintf ("/subscriptions/%s" , subID ))
176-
177- if err != nil || ! res .IsSuccess () {
178- if res .StatusCode () == 404 {
179- return false , nil
180- }
181- return false , ffresty .WrapRestErr (ctx , res , err , coremsgs .MsgFabconnectRESTErr )
182- }
183-
184- return true , nil
185- }
186-
187- func (s * streamManager ) getSubscriptionName (ctx context.Context , subID string ) (string , error ) {
173+ func (s * streamManager ) getSubscriptionName (ctx context.Context , subID string , okNotFound bool ) (string , error ) {
188174 if cachedValue := s .cache .GetString ("sub:" + subID ); cachedValue != "" {
189175 return cachedValue , nil
190176 }
191- sub , err := s .getSubscription (ctx , subID )
177+ sub , err := s .getSubscription (ctx , subID , okNotFound )
192178 if err != nil {
193179 return "" , err
194180 }
0 commit comments