Skip to content

Commit e8eac9b

Browse files
committed
chore: remove all backward compatibility for v1.0
Removed all backward compatibility code for clean v1.0 release: - Removed deprecated start/1,2,3 functions - Removed backward compatibility guard clause in ProcessSupervisor - Updated all documentation to reflect new API - Updated remaining test files to use new options format Breaking Changes: - start/1,2,3 functions removed (use start_session/1,2) - start_session/2 no longer accepts module as second argument (use start_session(id, module: Mod) instead) All 148 tests pass.
1 parent 17f967e commit e8eac9b

File tree

5 files changed

+38
-82
lines changed

5 files changed

+38
-82
lines changed

lib/phoenix/session_process.ex

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ defmodule Phoenix.SessionProcess do
113113
## API Overview
114114
115115
### Session Management
116-
- `start/1`, `start/2`, `start/3` - Start session processes
116+
- `start_session/1`, `start_session/2` - Start session processes
117117
- `started?/1` - Check if session exists
118118
- `terminate/1` - Stop session process
119119
- `find_session/1` - Find session by ID
@@ -274,45 +274,6 @@ defmodule Phoenix.SessionProcess do
274274
@spec start_session(binary(), keyword()) :: {:ok, pid()} | {:error, term()}
275275
defdelegate start_session(session_id, opts), to: Phoenix.SessionProcess.ProcessSupervisor
276276

277-
@doc """
278-
Deprecated: Use `start_session/1` instead.
279-
280-
This function is kept for backward compatibility but will be removed in a future version.
281-
"""
282-
@deprecated "Use start_session/1 instead"
283-
@spec start(binary()) :: {:ok, pid()} | {:error, term()}
284-
def start(session_id), do: start_session(session_id)
285-
286-
@doc """
287-
Deprecated: Use `start_session/2` with options instead.
288-
289-
## Migration
290-
291-
# Old
292-
start(session_id, MyModule)
293-
294-
# New
295-
start_session(session_id, module: MyModule)
296-
"""
297-
@deprecated "Use start_session/2 with module: option instead"
298-
@spec start(binary(), atom()) :: {:ok, pid()} | {:error, term()}
299-
def start(session_id, module), do: start_session(session_id, module: module)
300-
301-
@doc """
302-
Deprecated: Use `start_session/2` with options instead.
303-
304-
## Migration
305-
306-
# Old
307-
start(session_id, MyModule, args)
308-
309-
# New
310-
start_session(session_id, module: MyModule, args: args)
311-
"""
312-
@deprecated "Use start_session/2 with module: and args: options instead"
313-
@spec start(binary(), atom(), any()) :: {:ok, pid()} | {:error, term()}
314-
def start(session_id, module, arg), do: start_session(session_id, module: module, args: arg)
315-
316277
@doc """
317278
Checks if a session process is currently running.
318279

lib/phoenix/session_process/process_superviser.ex

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ defmodule Phoenix.SessionProcess.ProcessSupervisor do
2929
This module provides the main internal API for session process management:
3030
3131
### Session Lifecycle
32-
- `start_session/1-3` - Start new session processes
32+
- `start_session/1-2` - Start new session processes
3333
- `terminate_session/1` - Terminate specific session
3434
- `session_process_started?/1` - Check if session exists
3535
- `session_process_pid/1` - Get process PID for session ID
@@ -215,11 +215,6 @@ defmodule Phoenix.SessionProcess.ProcessSupervisor do
215215
start_session_with_module(session_id, module, args)
216216
end
217217

218-
# Backward compatibility for old 2-arity call with module atom
219-
def start_session(session_id, module) when is_atom(module) do
220-
start_session_with_module(session_id, module)
221-
end
222-
223218
@doc """
224219
Checks if a session process has been started for the given session ID.
225220

test/phoenix/session_process/dispatch_test.exs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ defmodule Phoenix.SessionProcess.DispatchTest do
5151

5252
setup do
5353
session_id = "test_session_#{:rand.uniform(1_000_000)}"
54-
{:ok, _pid} = SessionProcess.start_session(session_id, TestSessionProcess)
54+
{:ok, _pid} = SessionProcess.start_session(session_id, module: TestSessionProcess)
5555

5656
on_exit(fn ->
5757
if SessionProcess.started?(session_id) do
@@ -137,7 +137,7 @@ defmodule Phoenix.SessionProcess.DispatchTest do
137137

138138
test "dispatch validates action type is binary" do
139139
session_id = "validate_session_#{:rand.uniform(1_000_000)}"
140-
{:ok, _pid} = SessionProcess.start_session(session_id, TestSessionProcess)
140+
{:ok, _pid} = SessionProcess.start_session(session_id, module: TestSessionProcess)
141141

142142
assert_raise ArgumentError, ~r/Action type must be a binary string/, fn ->
143143
SessionProcess.dispatch(session_id, :atom_type)
@@ -148,7 +148,7 @@ defmodule Phoenix.SessionProcess.DispatchTest do
148148

149149
test "dispatch validates meta is a keyword list" do
150150
session_id = "validate_meta_#{:rand.uniform(1_000_000)}"
151-
{:ok, _pid} = SessionProcess.start_session(session_id, TestSessionProcess)
151+
{:ok, _pid} = SessionProcess.start_session(session_id, module: TestSessionProcess)
152152

153153
assert_raise ArgumentError, ~r/Action meta must be a keyword list/, fn ->
154154
SessionProcess.dispatch(session_id, "test", nil, %{async: true})

test/phoenix/session_process/reducer_integration_test.exs

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
210210

211211
setup do
212212
session_id = "test_session_#{:rand.uniform(1_000_000)}"
213-
{:ok, pid} = SessionProcess.start_session(session_id, TestSessionProcess)
213+
{:ok, pid} = SessionProcess.start_session(session_id, module: TestSessionProcess)
214214

215215
on_exit(fn ->
216216
if Process.alive?(pid) do
@@ -427,7 +427,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
427427
session_id = "test_invalid_string_#{:rand.uniform(1_000_000)}"
428428

429429
{:error, {exception, _stacktrace}} =
430-
SessionProcess.start_session(session_id, InvalidStringSession)
430+
SessionProcess.start_session(session_id, module: InvalidStringSession)
431431

432432
assert %ArgumentError{} = exception
433433
assert exception.message =~ ~r/Invalid combined_reducers entry/
@@ -445,7 +445,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
445445
session_id = "test_invalid_int_#{:rand.uniform(1_000_000)}"
446446

447447
{:error, {exception, _stacktrace}} =
448-
SessionProcess.start_session(session_id, InvalidIntegerSession)
448+
SessionProcess.start_session(session_id, module: InvalidIntegerSession)
449449

450450
assert %ArgumentError{} = exception
451451
assert exception.message =~ ~r/Invalid combined_reducers entry/
@@ -463,7 +463,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
463463
session_id = "test_invalid_tuple_#{:rand.uniform(1_000_000)}"
464464

465465
{:error, {exception, _stacktrace}} =
466-
SessionProcess.start_session(session_id, InvalidTupleSession)
466+
SessionProcess.start_session(session_id, module: InvalidTupleSession)
467467

468468
assert %ArgumentError{} = exception
469469
assert exception.message =~ ~r/Invalid combined_reducers entry/
@@ -484,7 +484,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
484484
session_id = "test_dup_module_#{:rand.uniform(1_000_000)}"
485485

486486
{:error, {exception, _stacktrace}} =
487-
SessionProcess.start_session(session_id, DuplicateModuleSession)
487+
SessionProcess.start_session(session_id, module: DuplicateModuleSession)
488488

489489
assert %ArgumentError{} = exception
490490
assert exception.message =~ ~r/Duplicate reducer name: :users/
@@ -505,7 +505,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
505505
session_id = "test_dup_name_#{:rand.uniform(1_000_000)}"
506506

507507
{:error, {exception, _stacktrace}} =
508-
SessionProcess.start_session(session_id, DuplicateNameSession)
508+
SessionProcess.start_session(session_id, module: DuplicateNameSession)
509509

510510
assert %ArgumentError{} = exception
511511
assert exception.message =~ ~r/Duplicate reducer name: :users/
@@ -528,7 +528,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
528528
session_id = "test_non_reducer_#{:rand.uniform(1_000_000)}"
529529

530530
{:error, {exception, _stacktrace}} =
531-
SessionProcess.start_session(session_id, NonReducerSession)
531+
SessionProcess.start_session(session_id, module: NonReducerSession)
532532

533533
assert %ArgumentError{} = exception
534534
assert exception.message =~ ~r/not a reducer module/
@@ -546,7 +546,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
546546
session_id = "test_nonexistent_#{:rand.uniform(1_000_000)}"
547547

548548
{:error, {exception, _stacktrace}} =
549-
SessionProcess.start_session(session_id, NonExistentModuleSession)
549+
SessionProcess.start_session(session_id, module: NonExistentModuleSession)
550550

551551
assert %ArgumentError{} = exception
552552
assert exception.message =~ ~r/Could not load reducer module/
@@ -564,7 +564,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
564564
end
565565

566566
session_id = "test_empty_#{:rand.uniform(1_000_000)}"
567-
{:ok, _pid} = SessionProcess.start_session(session_id, EmptyListSession)
567+
{:ok, _pid} = SessionProcess.start_session(session_id, module: EmptyListSession)
568568

569569
state = SessionProcess.get_state(session_id)
570570
assert state.count == 0
@@ -593,7 +593,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
593593
end
594594

595595
session_id = "mixed_format_#{:rand.uniform(1_000_000)}"
596-
{:ok, _pid} = SessionProcess.start_session(session_id, MixedFormatSession)
596+
{:ok, _pid} = SessionProcess.start_session(session_id, module: MixedFormatSession)
597597

598598
state = SessionProcess.get_state(session_id)
599599

@@ -644,7 +644,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
644644
end
645645

646646
session_id = "default_prefix_#{:rand.uniform(1_000_000)}"
647-
{:ok, _pid} = SessionProcess.start_session(session_id, DefaultPrefixSession)
647+
{:ok, _pid} = SessionProcess.start_session(session_id, module: DefaultPrefixSession)
648648

649649
state = SessionProcess.get_state(session_id)
650650
assert state.inventory == %{stock: 100}
@@ -670,7 +670,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
670670
end
671671

672672
session_id = "no_init_#{:rand.uniform(1_000_000)}"
673-
{:ok, _pid} = SessionProcess.start_session(session_id, NoInitStateSession)
673+
{:ok, _pid} = SessionProcess.start_session(session_id, module: NoInitStateSession)
674674

675675
state = SessionProcess.get_state(session_id)
676676
# Should be %{} because NotificationsReducer has no init_state/0
@@ -700,7 +700,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
700700
end
701701

702702
session_id = "mixed_init_#{:rand.uniform(1_000_000)}"
703-
{:ok, _pid} = SessionProcess.start_session(session_id, MixedInitSession)
703+
{:ok, _pid} = SessionProcess.start_session(session_id, module: MixedInitSession)
704704

705705
state = SessionProcess.get_state(session_id)
706706
assert state.users == %{users: [], fetch_count: 0, search_query: nil}
@@ -725,7 +725,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
725725
end
726726

727727
session_id = "map_format_#{:rand.uniform(1_000_000)}"
728-
{:ok, _pid} = SessionProcess.start_session(session_id, MapFormatSession)
728+
{:ok, _pid} = SessionProcess.start_session(session_id, module: MapFormatSession)
729729

730730
state = SessionProcess.get_state(session_id)
731731
assert state.users == %{users: [], fetch_count: 0, search_query: nil}
@@ -757,7 +757,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
757757
end
758758

759759
session_id = "custom_prefix_#{:rand.uniform(1_000_000)}"
760-
{:ok, _pid} = SessionProcess.start_session(session_id, CustomPrefixSession)
760+
{:ok, _pid} = SessionProcess.start_session(session_id, module: CustomPrefixSession)
761761

762762
state = SessionProcess.get_state(session_id)
763763
assert state.shipping == %{address: nil, cost: 0}
@@ -785,7 +785,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
785785
end
786786

787787
session_id = "same_prefix_#{:rand.uniform(1_000_000)}"
788-
{:ok, _pid} = SessionProcess.start_session(session_id, SamePrefixSession)
788+
{:ok, _pid} = SessionProcess.start_session(session_id, module: SamePrefixSession)
789789

790790
state = SessionProcess.get_state(session_id)
791791
assert state.primary_users == %{users: [], fetch_count: 0, search_query: nil}
@@ -814,7 +814,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
814814
end
815815

816816
session_id = "special_chars_#{:rand.uniform(1_000_000)}"
817-
{:ok, _pid} = SessionProcess.start_session(session_id, SpecialCharsSession)
817+
{:ok, _pid} = SessionProcess.start_session(session_id, module: SpecialCharsSession)
818818

819819
state = SessionProcess.get_state(session_id)
820820
assert state.special_chars_test == %{data: "test"}
@@ -841,7 +841,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
841841
end
842842

843843
session_id = "underscore_hyphen_#{:rand.uniform(1_000_000)}"
844-
{:ok, _pid} = SessionProcess.start_session(session_id, UnderscoreHyphenSession)
844+
{:ok, _pid} = SessionProcess.start_session(session_id, module: UnderscoreHyphenSession)
845845

846846
state = SessionProcess.get_state(session_id)
847847
assert Map.has_key?(state, :user_profile)
@@ -875,7 +875,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
875875
end
876876

877877
session_id = "stress_test_#{:rand.uniform(1_000_000)}"
878-
{:ok, _pid} = SessionProcess.start_session(session_id, StressTestSession)
878+
{:ok, _pid} = SessionProcess.start_session(session_id, module: StressTestSession)
879879

880880
state = SessionProcess.get_state(session_id)
881881

@@ -922,7 +922,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
922922
end
923923

924924
session_id = "prefix_meta_#{:rand.uniform(1_000_000)}"
925-
{:ok, pid} = SessionProcess.start_session(session_id, PrefixMetadataSession)
925+
{:ok, pid} = SessionProcess.start_session(session_id, module: PrefixMetadataSession)
926926

927927
# Access internal state to verify prefix storage
928928
internal_state = :sys.get_state(pid)
@@ -951,7 +951,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
951951

952952
session_id = "same_prefix_diff_#{:rand.uniform(1_000_000)}"
953953
# Should not raise - same prefix with different names is valid
954-
{:ok, _pid} = SessionProcess.start_session(session_id, SamePrefixDiffModulesSession)
954+
{:ok, _pid} = SessionProcess.start_session(session_id, module: SamePrefixDiffModulesSession)
955955

956956
state = SessionProcess.get_state(session_id)
957957
assert Map.has_key?(state, :users)
@@ -973,7 +973,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
973973
end
974974

975975
session_id = "throttle_debounce_list_#{:rand.uniform(1_000_000)}"
976-
{:ok, _pid} = SessionProcess.start_session(session_id, ThrottleDebounceListSession)
976+
{:ok, _pid} = SessionProcess.start_session(session_id, module: ThrottleDebounceListSession)
977977

978978
# Test throttle still works
979979
SessionProcess.dispatch(session_id, "fetch-users")
@@ -1012,7 +1012,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
10121012
end
10131013

10141014
session_id = "subscription_list_#{:rand.uniform(1_000_000)}"
1015-
{:ok, _pid} = SessionProcess.start_session(session_id, SubscriptionListSession)
1015+
{:ok, _pid} = SessionProcess.start_session(session_id, module: SubscriptionListSession)
10161016

10171017
{:ok, _sub_id} =
10181018
SessionProcess.subscribe(
@@ -1036,7 +1036,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
10361036
alias Phoenix.SessionProcess.Action
10371037

10381038
session_id = "routing_explicit_#{:rand.uniform(1_000_000)}"
1039-
{:ok, _pid} = SessionProcess.start_session(session_id, TestSessionProcess)
1039+
{:ok, _pid} = SessionProcess.start_session(session_id, module: TestSessionProcess)
10401040

10411041
# Dispatch with explicit reducer targeting - only UserReducer should get it
10421042
SessionProcess.dispatch(session_id, "add-user", "Alice", reducers: [:users])
@@ -1061,7 +1061,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
10611061

10621062
test "routes action to multiple specified reducers" do
10631063
session_id = "routing_multi_#{:rand.uniform(1_000_000)}"
1064-
{:ok, _pid} = SessionProcess.start_session(session_id, TestSessionProcess)
1064+
{:ok, _pid} = SessionProcess.start_session(session_id, module: TestSessionProcess)
10651065

10661066
# Dispatch to both UserReducer and CartReducer
10671067
SessionProcess.dispatch(session_id, "add-user", "Bob", reducers: [:users, :cart])
@@ -1078,7 +1078,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
10781078

10791079
test "no routing metadata calls all reducers" do
10801080
session_id = "routing_all_#{:rand.uniform(1_000_000)}"
1081-
{:ok, _pid} = SessionProcess.start_session(session_id, TestSessionProcess)
1081+
{:ok, _pid} = SessionProcess.start_session(session_id, module: TestSessionProcess)
10821082

10831083
# Dispatch without routing metadata - goes to all reducers
10841084
SessionProcess.dispatch(session_id, "add-user", "Charlie")
@@ -1108,7 +1108,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
11081108
end
11091109

11101110
session_id = "routing_prefix_#{:rand.uniform(1_000_000)}"
1111-
{:ok, _pid} = SessionProcess.start_session(session_id, PrefixRoutingSession)
1111+
{:ok, _pid} = SessionProcess.start_session(session_id, module: PrefixRoutingSession)
11121112

11131113
# Dispatch "user.fetch-users" - should route to UserReducer only
11141114
SessionProcess.dispatch(session_id, "user.fetch-users")
@@ -1129,7 +1129,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
11291129

11301130
test "explicit prefix filter overrides inferred prefix" do
11311131
session_id = "routing_explicit_prefix_#{:rand.uniform(1_000_000)}"
1132-
{:ok, _pid} = SessionProcess.start_session(session_id, TestSessionProcess)
1132+
{:ok, _pid} = SessionProcess.start_session(session_id, module: TestSessionProcess)
11331133

11341134
# Even though action type is "cart.add", explicitly route to users reducer
11351135
SessionProcess.dispatch(
@@ -1151,7 +1151,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
11511151

11521152
test "action without dot notation goes to all reducers" do
11531153
session_id = "routing_no_prefix_#{:rand.uniform(1_000_000)}"
1154-
{:ok, _pid} = SessionProcess.start_session(session_id, TestSessionProcess)
1154+
{:ok, _pid} = SessionProcess.start_session(session_id, module: TestSessionProcess)
11551155

11561156
# Action type has no dot, so no prefix to route by - goes to all
11571157
SessionProcess.dispatch(session_id, "add-user", "Dave")
@@ -1176,7 +1176,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
11761176
end
11771177

11781178
session_id = "routing_custom_prefix_#{:rand.uniform(1_000_000)}"
1179-
{:ok, _pid} = SessionProcess.start_session(session_id, CustomPrefixSession)
1179+
{:ok, _pid} = SessionProcess.start_session(session_id, module: CustomPrefixSession)
11801180

11811181
# Action with "ship.calculate-shipping" should route to ShippingReducer
11821182
# After prefix stripping, becomes "calculate-shipping" which matches the handler
@@ -1207,7 +1207,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
12071207
end
12081208

12091209
session_id = "routing_performance_#{:rand.uniform(1_000_000)}"
1210-
{:ok, _pid} = SessionProcess.start_session(session_id, CountingSession)
1210+
{:ok, _pid} = SessionProcess.start_session(session_id, module: CountingSession)
12111211

12121212
# Dispatch to only users
12131213
SessionProcess.dispatch(session_id, "test-action", nil, reducers: [:users])
@@ -1256,7 +1256,7 @@ defmodule Phoenix.SessionProcess.ReducerIntegrationTest do
12561256
end
12571257

12581258
session_id = "routing_many_#{:rand.uniform(1_000_000)}"
1259-
{:ok, _pid} = SessionProcess.start_session(session_id, ManyReducersSession)
1259+
{:ok, _pid} = SessionProcess.start_session(session_id, module: ManyReducersSession)
12601260

12611261
# Dispatch with "user." prefix - should only call user1 and user2
12621262
SessionProcess.dispatch(session_id, "user.action")

test/phoenix/session_process/telemetry_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ defmodule Phoenix.SessionProcess.TelemetryTest do
2929
assert {:ok, pid} =
3030
SessionProcess.start_session(
3131
session_id,
32-
Phoenix.SessionProcess.DefaultSessionProcess
32+
module: Phoenix.SessionProcess.DefaultSessionProcess
3333
)
3434

3535
assert_receive {:telemetry_event, [:phoenix, :session_process, :start], measurements, meta}

0 commit comments

Comments
 (0)