Skip to content

Commit 10d84c9

Browse files
committed
ignore: mix format.
1 parent a52a353 commit 10d84c9

File tree

2 files changed

+32
-24
lines changed

2 files changed

+32
-24
lines changed

packages/sync-service/lib/electric/shapes/api.ex

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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

packages/sync-service/lib/electric/shapes/api/sse_state.ex

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ defmodule Electric.Shapes.Api.SseState do
1212
]
1313

1414
@type t() :: %__MODULE__{
15-
mode: :receive | :emit | :done,
16-
request: Api.Request.t(),
17-
stream: Enumerable.t() | nil,
18-
since_offset: LogOffset.t(),
19-
last_message_time: pos_integer(),
20-
keepalive_ref: reference()
21-
}
15+
mode: :receive | :emit | :done,
16+
request: Api.Request.t(),
17+
stream: Enumerable.t() | nil,
18+
since_offset: LogOffset.t(),
19+
last_message_time: pos_integer(),
20+
keepalive_ref: reference()
21+
}
2222
end

0 commit comments

Comments
 (0)