@@ -51,7 +51,7 @@ defmodule Phoenix.SessionProcess do
5151 session_id = conn.assigns.session_id
5252
5353 # Start session process
54- {:ok, _pid} = Phoenix.SessionProcess.start (session_id)
54+ {:ok, _pid} = Phoenix.SessionProcess.start_session (session_id)
5555
5656 # Store data
5757 Phoenix.SessionProcess.cast(session_id, {:put, :user_id, 123})
@@ -224,11 +224,20 @@ defmodule Phoenix.SessionProcess do
224224
225225 ## Examples
226226
227- {:ok, pid} = Phoenix.SessionProcess.start ("user_123")
228- {:error, {:already_started, pid}} = Phoenix.SessionProcess.start ("user_123")
227+ {:ok, pid} = Phoenix.SessionProcess.start_session ("user_123")
228+ {:error, {:already_started, pid}} = Phoenix.SessionProcess.start_session ("user_123")
229229 """
230+ @ spec start_session ( binary ( ) ) :: { :ok , pid ( ) } | { :error , term ( ) }
231+ defdelegate start_session ( session_id ) , to: Phoenix.SessionProcess.ProcessSupervisor
232+
233+ @ doc """
234+ Deprecated: Use `start_session/1` instead.
235+
236+ This function is kept for backward compatibility but will be removed in a future version.
237+ """
238+ @ deprecated "Use start_session/1 instead"
230239 @ spec start ( binary ( ) ) :: { :ok , pid ( ) } | { :error , term ( ) }
231- defdelegate start ( session_id ) , to: Phoenix.SessionProcess.ProcessSupervisor , as: : start_session
240+ def start ( session_id ) , do: start_session ( session_id )
232241
233242 @ doc """
234243 Starts a session process using a custom module.
@@ -248,19 +257,26 @@ defmodule Phoenix.SessionProcess do
248257
249258 ## Examples
250259
251- {:ok, pid} = Phoenix.SessionProcess.start ("user_123", MyApp.CustomSessionProcess)
260+ {:ok, pid} = Phoenix.SessionProcess.start_session ("user_123", MyApp.CustomSessionProcess)
252261
253- iex> result = Phoenix.SessionProcess.start ("valid_session", Phoenix.SessionProcess.DefaultSessionProcess)
262+ iex> result = Phoenix.SessionProcess.start_session ("valid_session", Phoenix.SessionProcess.DefaultSessionProcess)
254263 iex> match?({:ok, _pid}, result) or match?({:error, {:already_started, _pid}}, result)
255264 true
256265
257- iex> Phoenix.SessionProcess.start ("invalid@session", Phoenix.SessionProcess.DefaultSessionProcess)
266+ iex> Phoenix.SessionProcess.start_session ("invalid@session", Phoenix.SessionProcess.DefaultSessionProcess)
258267 {:error, {:invalid_session_id, "invalid@session"}}
259268 """
269+ @ spec start_session ( binary ( ) , atom ( ) ) :: { :ok , pid ( ) } | { :error , term ( ) }
270+ defdelegate start_session ( session_id , module ) , to: Phoenix.SessionProcess.ProcessSupervisor
271+
272+ @ doc """
273+ Deprecated: Use `start_session/2` instead.
274+
275+ This function is kept for backward compatibility but will be removed in a future version.
276+ """
277+ @ deprecated "Use start_session/2 instead"
260278 @ spec start ( binary ( ) , atom ( ) ) :: { :ok , pid ( ) } | { :error , term ( ) }
261- defdelegate start ( session_id , module ) ,
262- to: Phoenix.SessionProcess.ProcessSupervisor ,
263- as: :start_session
279+ def start ( session_id , module ) , do: start_session ( session_id , module )
264280
265281 @ doc """
266282 Starts a session process with a custom module and initialization arguments.
@@ -282,23 +298,30 @@ defmodule Phoenix.SessionProcess do
282298 ## Examples
283299
284300 # With map argument
285- {:ok, pid} = Phoenix.SessionProcess.start ("user_123", MyApp.SessionProcess, %{user_id: 123})
301+ {:ok, pid} = Phoenix.SessionProcess.start_session ("user_123", MyApp.SessionProcess, %{user_id: 123})
286302
287303 # With keyword list
288- {:ok, pid} = Phoenix.SessionProcess.start ("user_456", MyApp.SessionProcess, [debug: true])
304+ {:ok, pid} = Phoenix.SessionProcess.start_session ("user_456", MyApp.SessionProcess, [debug: true])
289305
290- iex> result = Phoenix.SessionProcess.start ("valid_session_with_args", Phoenix.SessionProcess.DefaultSessionProcess, %{user_id: 123})
306+ iex> result = Phoenix.SessionProcess.start_session ("valid_session_with_args", Phoenix.SessionProcess.DefaultSessionProcess, %{user_id: 123})
291307 iex> match?({:ok, _pid}, result) or match?({:error, {:already_started, _pid}}, result)
292308 true
293309
294- iex> result = Phoenix.SessionProcess.start ("valid_session_with_list", Phoenix.SessionProcess.DefaultSessionProcess, [debug: true])
310+ iex> result = Phoenix.SessionProcess.start_session ("valid_session_with_list", Phoenix.SessionProcess.DefaultSessionProcess, [debug: true])
295311 iex> match?({:ok, _pid}, result) or match?({:error, {:already_started, _pid}}, result)
296312 true
297313 """
314+ @ spec start_session ( binary ( ) , atom ( ) , any ( ) ) :: { :ok , pid ( ) } | { :error , term ( ) }
315+ defdelegate start_session ( session_id , module , arg ) , to: Phoenix.SessionProcess.ProcessSupervisor
316+
317+ @ doc """
318+ Deprecated: Use `start_session/3` instead.
319+
320+ This function is kept for backward compatibility but will be removed in a future version.
321+ """
322+ @ deprecated "Use start_session/3 instead"
298323 @ spec start ( binary ( ) , atom ( ) , any ( ) ) :: { :ok , pid ( ) } | { :error , term ( ) }
299- defdelegate start ( session_id , module , arg ) ,
300- to: Phoenix.SessionProcess.ProcessSupervisor ,
301- as: :start_session
324+ def start ( session_id , module , arg ) , do: start_session ( session_id , module , arg )
302325
303326 @ doc """
304327 Checks if a session process is currently running.
@@ -312,7 +335,7 @@ defmodule Phoenix.SessionProcess do
312335
313336 ## Examples
314337
315- {:ok, _pid} = Phoenix.SessionProcess.start ("user_123")
338+ {:ok, _pid} = Phoenix.SessionProcess.start_session ("user_123")
316339 true = Phoenix.SessionProcess.started?("user_123")
317340 false = Phoenix.SessionProcess.started?("nonexistent")
318341 """
@@ -336,7 +359,7 @@ defmodule Phoenix.SessionProcess do
336359
337360 ## Examples
338361
339- {:ok, _pid} = Phoenix.SessionProcess.start ("user_123")
362+ {:ok, _pid} = Phoenix.SessionProcess.start_session ("user_123")
340363 :ok = Phoenix.SessionProcess.terminate("user_123")
341364 {:error, :not_found} = Phoenix.SessionProcess.terminate("user_123")
342365 """
@@ -361,7 +384,7 @@ defmodule Phoenix.SessionProcess do
361384
362385 ## Examples
363386
364- {:ok, _pid} = Phoenix.SessionProcess.start ("user_123")
387+ {:ok, _pid} = Phoenix.SessionProcess.start_session ("user_123")
365388
366389 # Keep session alive
367390 :ok = Phoenix.SessionProcess.touch("user_123")
@@ -396,7 +419,7 @@ defmodule Phoenix.SessionProcess do
396419
397420 ## Examples
398421
399- {:ok, _pid} = Phoenix.SessionProcess.start ("user_123")
422+ {:ok, _pid} = Phoenix.SessionProcess.start_session ("user_123")
400423 {:ok, state} = Phoenix.SessionProcess.call("user_123", :get_state)
401424 {:ok, :pong} = Phoenix.SessionProcess.call("user_123", :ping, 5_000)
402425 """
@@ -421,7 +444,7 @@ defmodule Phoenix.SessionProcess do
421444
422445 ## Examples
423446
424- {:ok, _pid} = Phoenix.SessionProcess.start ("user_123")
447+ {:ok, _pid} = Phoenix.SessionProcess.start_session ("user_123")
425448 :ok = Phoenix.SessionProcess.cast("user_123", {:put, :user_id, 123})
426449 :ok = Phoenix.SessionProcess.cast("user_123", {:delete, :old_key})
427450 """
0 commit comments