Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api,ui): enable websocket for all #5249

Merged
merged 6 commits into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion engine/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ type API struct {
SharedStorage objectstore.Driver
StartupTime time.Time
Maintenance bool
eventsBroker *eventsBroker
websocketBroker *websocketBroker
Cache cache.Store
Metrics struct {
Expand Down
11 changes: 0 additions & 11 deletions engine/api/api_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@ func (api *API) InitRouter() {
r := api.Router

log.Info(api.Router.Background, "Initializing Events broker")
// Initialize event broker
api.eventsBroker = &eventsBroker{
router: api.Router,
cache: api.Cache,
clients: make(map[string]*eventsBrokerSubscribe),
dbFunc: api.DBConnectionFactory.GetDBMap,
messages: make(chan sdk.Event),
}
api.eventsBroker.Init(r.Background, api.PanicDump())

api.websocketBroker = &websocketBroker{
router: api.Router,
cache: api.Cache,
Expand Down Expand Up @@ -415,7 +405,6 @@ func (api *API) InitRouter() {
r.Handle("/workflow/hook/model/{model}", ScopeNone(), r.GET(api.getWorkflowHookModelHandler), r.POST(api.postWorkflowHookModelHandler, NeedAdmin(true)), r.PUT(api.putWorkflowHookModelHandler, NeedAdmin(true)))

// SSE
r.Handle("/events", ScopeNone(), r.GET(api.eventsBroker.ServeHTTP))
r.Handle("/ws", ScopeNone(), r.GET(api.websocketBroker.ServeHTTP))

// Feature
Expand Down
318 changes: 0 additions & 318 deletions engine/api/events.go

This file was deleted.

12 changes: 0 additions & 12 deletions engine/api/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ var (
onceMetrics sync.Once
Errors *stats.Int64Measure
Hits *stats.Int64Measure
SSEClients *stats.Int64Measure
SSEEvents *stats.Int64Measure
WebSocketClients *stats.Int64Measure
WebSocketEvents *stats.Int64Measure
ServerRequestCount *stats.Int64Measure
Expand Down Expand Up @@ -122,16 +120,6 @@ func (r *Router) recoverWrap(h http.HandlerFunc) http.HandlerFunc {
err = sdk.ErrUnknownError
}

// the SSE handler can panic, and it's the way gorilla/mux works :(
if strings.HasPrefix(req.URL.String(), "/events") {
msg := fmt.Sprintf("%v", err)
for _, s := range handledEventErrors {
if strings.Contains(msg, s) {
return
}
}
}

log.Error(context.TODO(), "[PANIC_RECOVERY] Panic occurred on %s:%s, recover %s", req.Method, req.URL.String(), err)
trace := make([]byte, 4096)
count := runtime.Stack(trace, true)
Expand Down
Loading