View Source MishkaInstaller.Installer.DepChangesProtector (Mishka Installer v0.0.4)

This module serializes how to get and install a library and add it to your system. Based on the structure of MishkaInstaller, this module should not be called independently.

  • The reason for the indirect call is to make the queue and also to run the processes in the background.
  • For this purpose, two workers have been created for this module, which can handle the update operation and add a library.

below-you-can-see-the-graph-of-connecting-this-module-to-another-module

Below you can see the graph of connecting this module to another module.


+---------------------------------------+
|                                       |
|                                       <-----------------------------------+
| MishkaInstaller.Installer.DepHandler  |                                   |
|                                       |       +---------------------------+------+
|                                       |       |                                  |
+-------------------+-----------------^-+       |                                  |
                    |                 |         |  MishkaInstaller.DepCompileJob   |
                    |                 |         |                                  <-----------+
                    |                 |         |                                  |           |
                    |                 |         +----------------------------------+           |
                    |                 |                                                        |
                    |                 |         +----------------------------------+           |
                    |                 |         |                                  |           |
                    |                 |         |                                  |           |
                    |                 |         |  MishkaInstaller.DepUpdateJob    |           |
                    |                 +---------+                                  |           |
                    |                           |                                  |           |
                    |                           +-^--------------------------------+           |
                    |                             |                                            |
+-------------------v---------------------------+ |  +-----------------------------------------+
|                                               | |  |                                         |
|                                               | |  |                                         |
| MishkaInstaller.Installer.DepChangesProtector +-+  | MishkaInstaller.Installer.Live.DepGetter|
|                                               |    |                                         |
|                                               |    |                                         |
+---------------------+-------------------------+    +-----------------------------------------+
                      |
                      |
  +-------------------v-----------------------+
  |                                           |
  | MishkaInstaller.Installer.RunTimeSourcing |
  |                                           |
  +-------------------------------------------+

As you can see in the graph above, most of the requests, except the update request, pass through the path of the MishkaInstaller.DepCompileJob module and call some functions of the MishkaInstaller.Installer.DepHandler module. After completing the operation process, this module finally serializes the queued requests and broadcasts the output by means of Pubsub.

  • Warning: Direct use of this module causes conflict in long operations and causes you to receive an error, or the system is completely down.
  • Warning: The update operation is connected to the worker of the MishkaInstaller.DepUpdateJob module.
  • Warning: this section should be limited to the super admin user because it is directly related to the core of the system.
  • Warning: User should always be notified to get backup.
  • Warning: Do not send timeout request to Genserver of this module.
  • Warning: This module must be supervised in the Application.ex file and loaded at runtime.
  • Warning: this module has a direct relationship with the extension.json file, so it checks this file every few seconds and fixes it if it is not created or has a problem.
  • Warning: If you put Pubsub in your configuration settings and the value is not nil, this module will automatically send a timeout several times until your Pubsub process goes live.
  • Warning: at the time of starting Genserver, this module also starts MishkaInstaller.DepUpdateJob.ets/0 runtime database.
  • Warning: All possible errors are stored in the database introduced in the configuration, and you can access it with the functions of the MishkaInstaller.Activity module.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

This function is actually an action function and aggregator. You call this GenServer.cast function with three inputs {:deps, app, type}, which executes with a very small timeout. Warning: It is highly recommended not to call this function directly and use the worker (MishkaInstaller.DepCompileJob) to compile. Finally, this function calls the MishkaInstaller.Installer.RunTimeSourcing.do_deps_compile/2 function with the help of Task.Supervisor.async_nolink/2. It is worth mentioning that you can view and monitor the output by subscribing to this module.

This function checks if any process is running or not. if true means no job is being done, if false means there is a job is being done.

This function helps the programmer to join the channel of this module(MishkaInstaller.Installer.DepChangesProtector) and receive the output as a broadcast in the form of {status, :dep_changes_protector, answer, app}. It uses Phoenix.PubSub.subscribe/2.

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

deps(app, type \\ :port)

View Source
@spec deps(String.t(), atom()) :: :ok

This function is actually an action function and aggregator. You call this GenServer.cast function with three inputs {:deps, app, type}, which executes with a very small timeout. Warning: It is highly recommended not to call this function directly and use the worker (MishkaInstaller.DepCompileJob) to compile. Finally, this function calls the MishkaInstaller.Installer.RunTimeSourcing.do_deps_compile/2 function with the help of Task.Supervisor.async_nolink/2. It is worth mentioning that you can view and monitor the output by subscribing to this module.

examples

Examples

MishkaInstaller.Installer.DepChangesProtector.deps(app_name, output_type)
@spec get() :: map()
Link to this function

is_dependency_compiling?()

View Source
@spec is_dependency_compiling?() :: boolean()

This function checks if any process is running or not. if true means no job is being done, if false means there is a job is being done.

examples

Examples

MishkaInstaller.Installer.DepChangesProtector.is_dependency_compiling?()
@spec subscribe() :: :ok | {:error, {:already_registered, pid()}}

This function helps the programmer to join the channel of this module(MishkaInstaller.Installer.DepChangesProtector) and receive the output as a broadcast in the form of {status, :dep_changes_protector, answer, app}. It uses Phoenix.PubSub.subscribe/2.

examples

Examples

# Subscribe to `MishkaInstaller.Installer.DepChangesProtector` module
MishkaInstaller.Installer.DepChangesProtector.subscribe()

# Getting the answer as Pubsub for examples in LiveView
@impl Phoenix.LiveView
def handle_info({status, :dep_changes_protector, answer, app}, socket) do
  {:noreply, socket}
end