@@ -98,14 +98,17 @@ func (s *Server) OnBoot() Action {
9898 pluginTimeoutCtx , cancel := context .WithTimeout (context .Background (), s .PluginTimeout )
9999 defer cancel ()
100100 // Run the OnBooting hooks.
101- _ , err := s .PluginRegistry .Run (
101+ result , err := s .PluginRegistry .Run (
102102 pluginTimeoutCtx ,
103103 map [string ]any {"status" : fmt .Sprint (s .Status )},
104104 v1 .HookName_HOOK_NAME_ON_BOOTING )
105105 if err != nil {
106106 s .Logger .Error ().Err (err ).Msg ("Failed to run OnBooting hook" )
107107 span .RecordError (err )
108108 }
109+ if result != nil {
110+ _ = s .PluginRegistry .ActRegistry .RunAll (result )
111+ }
109112 span .AddEvent ("Ran the OnBooting hooks" )
110113
111114 // Set the server status to running.
@@ -117,14 +120,17 @@ func (s *Server) OnBoot() Action {
117120 pluginTimeoutCtx , cancel = context .WithTimeout (context .Background (), s .PluginTimeout )
118121 defer cancel ()
119122
120- _ , err = s .PluginRegistry .Run (
123+ result , err = s .PluginRegistry .Run (
121124 pluginTimeoutCtx ,
122125 map [string ]any {"status" : fmt .Sprint (s .Status )},
123126 v1 .HookName_HOOK_NAME_ON_BOOTED )
124127 if err != nil {
125128 s .Logger .Error ().Err (err ).Msg ("Failed to run OnBooted hook" )
126129 span .RecordError (err )
127130 }
131+ if result != nil {
132+ _ = s .PluginRegistry .ActRegistry .RunAll (result )
133+ }
128134 span .AddEvent ("Ran the OnBooted hooks" )
129135
130136 s .Logger .Debug ().Msg ("GatewayD booted" )
@@ -150,12 +156,15 @@ func (s *Server) OnOpen(conn *ConnWrapper) ([]byte, Action) {
150156 "remote" : RemoteAddr (conn .Conn ()),
151157 },
152158 }
153- _ , err := s .PluginRegistry .Run (
159+ result , err := s .PluginRegistry .Run (
154160 pluginTimeoutCtx , onOpeningData , v1 .HookName_HOOK_NAME_ON_OPENING )
155161 if err != nil {
156162 s .Logger .Error ().Err (err ).Msg ("Failed to run OnOpening hook" )
157163 span .RecordError (err )
158164 }
165+ if result != nil {
166+ _ = s .PluginRegistry .ActRegistry .RunAll (result )
167+ }
159168 span .AddEvent ("Ran the OnOpening hooks" )
160169
161170 // Attempt to retrieve the next proxy.
@@ -195,12 +204,15 @@ func (s *Server) OnOpen(conn *ConnWrapper) ([]byte, Action) {
195204 "remote" : RemoteAddr (conn .Conn ()),
196205 },
197206 }
198- _ , err = s .PluginRegistry .Run (
207+ result , err = s .PluginRegistry .Run (
199208 pluginTimeoutCtx , onOpenedData , v1 .HookName_HOOK_NAME_ON_OPENED )
200209 if err != nil {
201210 s .Logger .Error ().Err (err ).Msg ("Failed to run OnOpened hook" )
202211 span .RecordError (err )
203212 }
213+ if result != nil {
214+ _ = s .PluginRegistry .ActRegistry .RunAll (result )
215+ }
204216 span .AddEvent ("Ran the OnOpened hooks" )
205217
206218 metrics .ClientConnections .WithLabelValues (s .GroupName , proxy .GetBlockName ()).Inc ()
@@ -231,12 +243,15 @@ func (s *Server) OnClose(conn *ConnWrapper, err error) Action {
231243 if err != nil {
232244 data ["error" ] = err .Error ()
233245 }
234- _ , gatewaydErr := s .PluginRegistry .Run (
246+ result , gatewaydErr := s .PluginRegistry .Run (
235247 pluginTimeoutCtx , data , v1 .HookName_HOOK_NAME_ON_CLOSING )
236248 if gatewaydErr != nil {
237249 s .Logger .Error ().Err (gatewaydErr ).Msg ("Failed to run OnClosing hook" )
238250 span .RecordError (gatewaydErr )
239251 }
252+ if result != nil {
253+ _ = s .PluginRegistry .ActRegistry .RunAll (result )
254+ }
240255 span .AddEvent ("Ran the OnClosing hooks" )
241256
242257 // Shutdown the server if there are no more connections and the server is stopped.
@@ -291,12 +306,15 @@ func (s *Server) OnClose(conn *ConnWrapper, err error) Action {
291306 if err != nil {
292307 data ["error" ] = err .Error ()
293308 }
294- _ , gatewaydErr = s .PluginRegistry .Run (
309+ result , gatewaydErr = s .PluginRegistry .Run (
295310 pluginTimeoutCtx , data , v1 .HookName_HOOK_NAME_ON_CLOSED )
296311 if gatewaydErr != nil {
297312 s .Logger .Error ().Err (gatewaydErr ).Msg ("Failed to run OnClosed hook" )
298313 span .RecordError (gatewaydErr )
299314 }
315+ if result != nil {
316+ _ = s .PluginRegistry .ActRegistry .RunAll (result )
317+ }
300318 span .AddEvent ("Ran the OnClosed hooks" )
301319
302320 metrics .ClientConnections .WithLabelValues (s .GroupName , proxy .GetBlockName ()).Dec ()
@@ -320,12 +338,15 @@ func (s *Server) OnTraffic(conn *ConnWrapper, stopConnection chan struct{}) Acti
320338 "remote" : RemoteAddr (conn .Conn ()),
321339 },
322340 }
323- _ , err := s .PluginRegistry .Run (
341+ result , err := s .PluginRegistry .Run (
324342 pluginTimeoutCtx , onTrafficData , v1 .HookName_HOOK_NAME_ON_TRAFFIC )
325343 if err != nil {
326344 s .Logger .Error ().Err (err ).Msg ("Failed to run OnTraffic hook" )
327345 span .RecordError (err )
328346 }
347+ if result != nil {
348+ _ = s .PluginRegistry .ActRegistry .RunAll (result )
349+ }
329350 span .AddEvent ("Ran the OnTraffic hooks" )
330351
331352 stack := NewStack ()
@@ -391,14 +412,17 @@ func (s *Server) OnShutdown() {
391412 pluginTimeoutCtx , cancel := context .WithTimeout (context .Background (), s .PluginTimeout )
392413 defer cancel ()
393414 // Run the OnShutdown hooks.
394- _ , err := s .PluginRegistry .Run (
415+ result , err := s .PluginRegistry .Run (
395416 pluginTimeoutCtx ,
396417 map [string ]any {"connections" : s .CountConnections ()},
397418 v1 .HookName_HOOK_NAME_ON_SHUTDOWN )
398419 if err != nil {
399420 s .Logger .Error ().Err (err ).Msg ("Failed to run OnShutdown hook" )
400421 span .RecordError (err )
401422 }
423+ if result != nil {
424+ _ = s .PluginRegistry .ActRegistry .RunAll (result )
425+ }
402426 span .AddEvent ("Ran the OnShutdown hooks" )
403427
404428 // Shutdown proxies.
@@ -424,14 +448,17 @@ func (s *Server) OnTick() (time.Duration, Action) {
424448 pluginTimeoutCtx , cancel := context .WithTimeout (context .Background (), s .PluginTimeout )
425449 defer cancel ()
426450 // Run the OnTick hooks.
427- _ , err := s .PluginRegistry .Run (
451+ result , err := s .PluginRegistry .Run (
428452 pluginTimeoutCtx ,
429453 map [string ]any {"connections" : s .CountConnections ()},
430454 v1 .HookName_HOOK_NAME_ON_TICK )
431455 if err != nil {
432456 s .Logger .Error ().Err (err ).Msg ("Failed to run OnTick hook" )
433457 span .RecordError (err )
434458 }
459+ if result != nil {
460+ _ = s .PluginRegistry .ActRegistry .RunAll (result )
461+ }
435462 span .AddEvent ("Ran the OnTick hooks" )
436463
437464 // TODO: Investigate whether to move schedulers here or not
@@ -474,6 +501,8 @@ func (s *Server) Run() *gerr.GatewayDError {
474501 span .AddEvent ("Ran the OnRun hooks" )
475502
476503 if result != nil {
504+ _ = s .PluginRegistry .ActRegistry .RunAll (result )
505+
477506 if errMsg , ok := result ["error" ].(string ); ok && errMsg != "" {
478507 s .Logger .Error ().Str ("error" , errMsg ).Msg ("Error in hook" )
479508 }
0 commit comments