Skip to content

Commit

Permalink
[TT-13139] call createStreamManager in Init method to create a stream…
Browse files Browse the repository at this point in the history
… manager for background jobs.
  • Loading branch information
buraksezer committed Sep 30, 2024
1 parent d6e2369 commit a82a23a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions gateway/mw_streaming.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ func (sm *StreamManager) initStreams(r *http.Request, config *StreamsConfig) {

for streamID, streamConfig := range config.Streams {
if streamMap, ok := streamConfig.(map[string]interface{}); ok {
httpPaths := GetHTTPPaths(streamMap)
if r == nil && len(httpPaths) > 0 {
// If r is nil that means a default stream manager is being created for background jobs.
// If httpPaths is not an empty slice, we do not need any background job for this stream.
continue
}
err := sm.createStream(streamID, streamMap)
if err != nil {
sm.mw.Logger().WithError(err).Errorf("Error creating stream %s", streamID)
Expand Down Expand Up @@ -150,6 +156,7 @@ func (s *StreamingMiddleware) Init() {
s.ctx, s.cancel = context.WithCancel(context.Background())
s.router = mux.NewRouter()

s.createStreamManager(nil) // create a default stream manager here for background jobs.
s.registerHandlers(s.getStreamsConfig(nil))
}

Expand Down

0 comments on commit a82a23a

Please sign in to comment.