@@ -608,13 +608,15 @@ defmodule Electric.Shapes.Api do
608608 % {
609609 keepalive_ref: keepalive_ref ,
610610 last_message_time: last_message_time ,
611- request: % {
612- api: % {
613- keepalive_interval: keepalive_interval ,
614- } = api ,
615- handle: shape_handle ,
616- new_changes_ref: ref
617- } = request ,
611+ request:
612+ % {
613+ api:
614+ % {
615+ keepalive_interval: keepalive_interval
616+ } = api ,
617+ handle: shape_handle ,
618+ new_changes_ref: ref
619+ } = request ,
618620 since_offset: since_offset
619621 } = state
620622
@@ -642,15 +644,19 @@ defmodule Electric.Shapes.Api do
642644 encoded_stream = encode_log ( updated_request , message_stream )
643645
644646 current_time = System . monotonic_time ( :millisecond )
645- new_keepalive_ref = Process . send_after ( self ( ) , { :sse_keepalive , ref } , keepalive_interval )
646647
647- { [ ] , % { state |
648- mode: :emit ,
649- stream: encoded_stream ,
650- since_offset: end_offset ,
651- last_message_time: current_time ,
652- keepalive_ref: new_keepalive_ref
653- } }
648+ new_keepalive_ref =
649+ Process . send_after ( self ( ) , { :sse_keepalive , ref } , keepalive_interval )
650+
651+ { [ ] ,
652+ % {
653+ state
654+ | mode: :emit ,
655+ stream: encoded_stream ,
656+ since_offset: end_offset ,
657+ last_message_time: current_time ,
658+ keepalive_ref: new_keepalive_ref
659+ } }
654660
655661 { :error , _error } ->
656662 { [ ] , state }
@@ -667,9 +673,11 @@ defmodule Electric.Shapes.Api do
667673 time_since_last_message = current_time - last_message_time
668674
669675 if time_since_last_message >= keepalive_interval do
670- new_keepalive_ref = Process . send_after ( self ( ) , { :sse_keepalive , ref } , keepalive_interval )
676+ new_keepalive_ref =
677+ Process . send_after ( self ( ) , { :sse_keepalive , ref } , keepalive_interval )
671678
672- { [ ": keep-alive\n \n " ] , % { state | last_message_time: current_time , keepalive_ref: new_keepalive_ref } }
679+ { [ ": keep-alive\n \n " ] ,
680+ % { state | last_message_time: current_time , keepalive_ref: new_keepalive_ref } }
673681 else
674682 # Not time to send a keep-alive yet, schedule for the remaining time
675683 remaining_time = keepalive_interval - time_since_last_message
0 commit comments