@@ -429,6 +429,28 @@ defmodule Application do
429429 @ type value :: term
430430 @ type state :: term
431431 @ type start_type :: :normal | { :takeover , node } | { :failover , node }
432+
433+ @ typedoc """
434+ Specifies the type of the application:
435+
436+ * `:permanent` - if `app` terminates, all other applications and the entire
437+ node are also terminated.
438+
439+ * `:transient` - if `app` terminates with `:normal` reason, it is reported
440+ but no other applications are terminated. If a transient application
441+ terminates abnormally, all other applications and the entire node are
442+ also terminated.
443+
444+ * `:temporary` - if `app` terminates, it is reported but no other
445+ applications are terminated (the default).
446+
447+ Note that it is always possible to stop an application explicitly by calling
448+ `stop/1`. Regardless of the type of the application, no other applications will
449+ be affected.
450+
451+ Note also that the `:transient` type is of little practical use, since when a
452+ supervision tree terminates, the reason is set to `:shutdown`, not `:normal`.
453+ """
432454 @ type restart_type :: :permanent | :transient | :temporary
433455
434456 @ doc """
@@ -823,30 +845,16 @@ defmodule Application do
823845 end
824846
825847 @ doc """
826- Ensures the given `app` is started.
848+ Ensures the given `app` is started with `t:restart_type/0` .
827849
828850 Same as `start/2` but returns `:ok` if the application was already
829851 started.
830-
831- ## Options
832-
833- * `:type` - if the application should be started in `:permanent`,
834- `:temporary`, or `:transient`. See `start/2` for more information.
835-
836852 """
837- @ spec ensure_started ( app , type: restart_type ( ) ) :: :ok | { :error , term }
838- def ensure_started ( app , opts \\ [ ] )
839-
840- def ensure_started ( app , type ) when is_atom ( app ) and is_atom ( type ) do
841- # TODO: Deprecate me on Elixir v1.19
853+ @ spec ensure_started ( app , restart_type ( ) ) :: :ok | { :error , term }
854+ def ensure_started ( app , type \\ :temporary ) when is_atom ( app ) and is_atom ( type ) do
842855 :application . ensure_started ( app , type )
843856 end
844857
845- def ensure_started ( app , opts ) when is_atom ( app ) and is_list ( opts ) do
846- opts = Keyword . validate! ( opts , type: :temporary )
847- :application . ensure_started ( app , opts [ :type ] )
848- end
849-
850858 @ doc """
851859 Ensures the given `app` is loaded.
852860
@@ -866,21 +874,25 @@ defmodule Application do
866874 @ doc """
867875 Ensures the given `app` or `apps` and their child applications are started.
868876
877+ The second argument is either the `t:restart_type/1` (for consistency with
878+ `start/2`) or a keyword list.
879+
869880 ## Options
870881
871882 * `:type` - if the application should be started in `:permanent`,
872- `:temporary`, or `:transient`. See `start/2 ` for more information.
883+ `:temporary`, or `:transient`. See `t:restart_type/1 ` for more information.
873884
874885 * `:mode` - (since v1.15.0) if the applications should be started serially
875886 or concurrently. This option requires Erlang/OTP 26+.
876887
877888 """
878889 @ spec ensure_all_started ( app | [ app ] , type: restart_type ( ) , mode: :serial | :concurrent ) ::
879890 { :ok , [ app ] } | { :error , term }
880- def ensure_all_started ( app_or_apps , opts \\ [ ] )
891+ @ spec ensure_all_started ( app | [ app ] , restart_type ( ) ) ::
892+ { :ok , [ app ] } | { :error , term }
893+ def ensure_all_started ( app_or_apps , type_or_opts \\ [ ] )
881894
882895 def ensure_all_started ( app , type ) when is_atom ( type ) do
883- # TODO: Deprecate me on Elixir v1.19
884896 ensure_all_started ( app , type: type )
885897 end
886898
@@ -907,7 +919,7 @@ defmodule Application do
907919 end
908920
909921 @ doc """
910- Starts the given `app`.
922+ Starts the given `app` with `t:restart_type/0` .
911923
912924 If the `app` is not loaded, the application will first be loaded using `load/1`.
913925 Any included application, defined in the `:included_applications` key of the
@@ -919,42 +931,12 @@ defmodule Application do
919931
920932 In case you want to automatically load **and start** all of `app`'s dependencies,
921933 see `ensure_all_started/2`.
922-
923- ## Options
924-
925- * `:type` - specifies the type of the application:
926-
927- * `:permanent` - if `app` terminates, all other applications and the entire
928- node are also terminated.
929-
930- * `:transient` - if `app` terminates with `:normal` reason, it is reported
931- but no other applications are terminated. If a transient application
932- terminates abnormally, all other applications and the entire node are
933- also terminated.
934-
935- * `:temporary` - if `app` terminates, it is reported but no other
936- applications are terminated (the default).
937-
938- Note that it is always possible to stop an application explicitly by calling
939- `stop/1`. Regardless of the type of the application, no other applications will
940- be affected.
941-
942- Note also that the `:transient` type is of little practical use, since when a
943- supervision tree terminates, the reason is set to `:shutdown`, not `:normal`.
944934 """
945- @ spec start ( app , type: restart_type ( ) ) :: :ok | { :error , term }
946- def start ( app , opts \\ [ ] )
947-
948- def start ( app , type ) when is_atom ( app ) and is_atom ( type ) do
949- # TODO: Deprecate me on Elixir v1.19
935+ @ spec start ( app , restart_type ( ) ) :: :ok | { :error , term }
936+ def start ( app , type \\ :temporary ) when is_atom ( app ) and is_atom ( type ) do
950937 :application . start ( app , type )
951938 end
952939
953- def start ( app , opts ) when is_atom ( app ) and is_list ( opts ) do
954- opts = Keyword . validate! ( opts , type: :temporary )
955- :application . start ( app , opts [ :type ] )
956- end
957-
958940 @ doc """
959941 Stops the given `app`.
960942
0 commit comments