View Source MishkaInstaller.Event.Event (Mishka installer v0.1.0)

The MishkaInstaller.Event.Event module is the core of events, which comprises pre-prepared strategies for the implementation and management of plugins introduced to the system around various events. These implementation and management strategies are included in the Event module.

Use cases information

The fundamental criteria of the same system serve as the basis for the specification of these strategies, which are aimed at common systems. Therefore, you are not permitted to utilize this module if you believe that your technique is different.

In addition, it is important to remember that the other part of this module is connected to the queries that are required to be made to the Erlang runtime database, which is known as Mnesia.

Using this functionality, you will be able to store the information that is associated with each plugin in it.

Note that all storages are based on the name of an event. See MishkaInstaller.Event.Hook module.


Security considerations

It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.

This module is a read-only in-memory storage optimized for the fastest possible read times not for write strategies.

Note:

When you are writing, you should always make an effort to be more careful because you might get reconditioned during times of high traffic. When it comes to reading and running all plugins, this problem only occurs when a module is being created and destroyed during the compilation process.

Summary

Functions

To delete a plugin from Mnesia database by id or name.

To drop all plugins from Mnesia database.

To get all plugins information from Mnesia database.

To get a plugin information from Mnesia database by id.

To get all plugins or one plugin information from Mnesia database.

To get all the events defined in the Mnesia database (Only unique items are returned).

To get all plugins ids from Mnesia database.

If you want to store a plugin for a particular event, this function is a predefined strategy that you can use. Additionally, it performs a check on the integrity of the plugin module and gathers other information that is necessary while it is being stored in Mnesia.

This function restarts all events, For more information please see restart/2.

A pre-made strategy for restarting a plugin is what this method is clearly named. Keep in mind that you'll need to register and start this plugin ahead of time.

This function starts all events, For more information please see start/2.

A pre-made strategy for starting a plugin is what this method is clearly named. Keep in mind that you'll need to register this plugin ahead of time.

This function stops all events, For more information please see stop/2.

A pre-made strategy for stopping a plugin is what this method is clearly named. Keep in mind that you'll need to register and start this plugin ahead of time.

To check is a plugin unique or not in Mnesia database.

This function is exactly like unique/2 function, except that its output is a Boolean.

This function stops all unregisters, For more information please see unregister/2.

This function removes the plugin from the database and kills all processes associated to it, in addition to doing the exact same thing as the stop/2 function.

To Add or edit a plugin information from Mnesia database.

To edit a specific field/fields of a plugin from the Mnesia database.

Types

@type builder_entry() :: {:root, struct() | map(), :edit} | struct() | map()
@type error_return() ::
  {:error, [%{action: atom(), field: atom(), message: String.t()}]}
@type okey_return() :: {:ok, struct() | map() | module() | [any()]}
@type status() :: :registered | :started | :stopped | :restarted | :held
@type t() :: %MishkaInstaller.Event.Event{
  depends: [String.t()],
  event: String.t(),
  extension: atom(),
  extra: [map()],
  id: MishkaDeveloperTools.Helper.UUID.t() | nil,
  inserted_at: DateTime.t() | nil,
  name: module(),
  priority: integer(),
  status: status(),
  updated_at: DateTime.t() | nil
}

Functions

Link to this function

builder(attrs, error \\ false)

View Source
@spec delete(atom(), String.t() | module()) :: error_return() | okey_return()

To delete a plugin from Mnesia database by id or name.

Security considerations

It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.

Example:

delete(:name, TestApp.User.Auth)

delete(:id, "c63aea42-209a-40fb-b5c6-a0d28ee7e25b")
@spec drop() :: {:ok, :atomic} | {:error, any(), charlist()}

To drop all plugins from Mnesia database.

Security considerations

It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.

Example:

drop()
@spec get() :: [map() | struct()]

To get all plugins information from Mnesia database.

Security considerations

It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.

Example:

get()
@spec get(String.t()) :: map() | struct() | nil

To get a plugin information from Mnesia database by id.

Security considerations

It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.

Example:

get("c63aea42-209a-40fb-b5c6-a0d28ee7e25b")
@spec get(:name | :event | :extension, module() | String.t()) ::
  [map() | struct()] | map() | struct() | nil

To get all plugins or one plugin information from Mnesia database.

Security considerations

It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.

Example:

# All plugins of an event
get(:event, "after_login")

# All plugins of an extension
get(:extension, :mishka_developer_tools)

# Get a plugin
get(:name, TestApp.User.Auth)
Link to this function

group_events(key \\ [:event])

View Source
@spec group_events([atom()]) :: error_return() | okey_return()

To get all the events defined in the Mnesia database (Only unique items are returned).

Security considerations

It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.

Example:

group_events()
@spec ids() :: [String.t()]

To get all plugins ids from Mnesia database.

Security considerations

It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.

Example:

ids()
Link to this function

register(name, event, initial)

View Source
@spec register(module(), String.t(), map()) :: error_return() | okey_return()

If you want to store a plugin for a particular event, this function is a predefined strategy that you can use. Additionally, it performs a check on the integrity of the plugin module and gathers other information that is necessary while it is being stored in Mnesia.

Inputs for this function include the name of the plugin, the name of the event, and some fundamental information. Checking the struct of this module is one way to add the initial event to the modules.

See: %MishkaInstaller.Event.Event{}

Security considerations

It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.

This module is a read-only in-memory storage optimized for the fastest possible read times not for write strategies.

It is not appropriate for the user to have any direct influence on this function because it is intended for the use of the programmer. It should be brought to your attention that this particular function, which incorporates the Write activity, should often be utilized only once at the beginning of the project.

Example:

register(TestApp.User.Auth, "after_login", %{priority: 2})

This function is only responsible for registering the plugin; it does not carry out any activities related to execution. Please refer to function start/2 in order to execute

@spec restart(boolean()) :: okey_return() | error_return()

This function restarts all events, For more information please see restart/2.

Link to this function

restart(atom, name, queue)

View Source
@spec restart(:name | :event, module() | String.t(), boolean()) ::
  error_return() | okey_return()

A pre-made strategy for restarting a plugin is what this method is clearly named. Keep in mind that you'll need to register and start this plugin ahead of time.

The requested Event will be compiled once more in the event that the plugin is able to restart properly. This is a heavy write activity

Use cases information

The start/2 function and this idea are often mistaken. Actually, this function does the same operations as the start function, but it re-examines the conditions. You can tailor your own function to meet the specific needs of your system, and there's already a plan in place. The MishkaInstaller.Event.Hook module decides on this potential.


Security considerations

It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.

This module is a read-only in-memory storage optimized for the fastest possible read times not for write strategies.

It is not appropriate for the user to have any direct influence on this function because it is intended for the use of the programmer. It should be brought to your attention that this particular function, which incorporates the Write activity, should often be utilized only once at the beginning of the project.

Compile path: MishkaInstaller.Event.ModuleStateCompiler.State.YourEvent.

Example:

# Restart a plugin
restart(:name, TestApp.User.Auth)

# Restart all plugins of an event
restart(:event, "after_login")
@spec start(boolean()) :: okey_return() | error_return()

This function starts all events, For more information please see start/2.

Link to this function

start(atom, name, queue)

View Source
@spec start(:name | :event, module() | String.t(), boolean()) ::
  error_return() | okey_return()

A pre-made strategy for starting a plugin is what this method is clearly named. Keep in mind that you'll need to register this plugin ahead of time.

The requested Event will be compiled once more in the event that the plugin is able to start properly. This is a heavy write activity

Security considerations

It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.

This module is a read-only in-memory storage optimized for the fastest possible read times not for write strategies.

It is not appropriate for the user to have any direct influence on this function because it is intended for the use of the programmer. It should be brought to your attention that this particular function, which incorporates the Write activity, should often be utilized only once at the beginning of the project.

Compile path: MishkaInstaller.Event.ModuleStateCompiler.State.YourEvent.

Example:

# Start a plugin
start(:name, TestApp.User.Auth)

# Start all plugins of an event
start(:event, "after_login")
@spec stop(boolean()) :: okey_return() | error_return()

This function stops all events, For more information please see stop/2.

@spec stop(:name | :event, module() | String.t(), boolean()) ::
  okey_return() | error_return()

A pre-made strategy for stopping a plugin is what this method is clearly named. Keep in mind that you'll need to register and start this plugin ahead of time.

The requested Event will be compiled once more in the event that the plugin is able to stop properly. This is a heavy write activity

Use cases information

Keep in mind that the only thing that happens when you stop a plugin is that its database status changes to stopped and it is removed from the list of compiled modules of the event in question. However, its modules, notably GenServer, will still be operational and will not be entirely removed from the system.


Security considerations

It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.

This module is a read-only in-memory storage optimized for the fastest possible read times not for write strategies.

It is not appropriate for the user to have any direct influence on this function because it is intended for the use of the programmer. It should be brought to your attention that this particular function, which incorporates the Write activity, should often be utilized only once at the beginning of the project.

Example:

# Stop a plugin
stop(:name, TestApp.User.Auth)

# Stop all plugins of an event
stop(:event, "after_login")

To check is a plugin unique or not in Mnesia database.

It returns :ok, or {:error, reason}. Note that if the requested plugin does not exist, it means it is unique, and if it is already in the database, it means it is not unique

Security considerations

It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.

Example:

unique(:name, TestApp.User.Auth)

This function is exactly like unique/2 function, except that its output is a Boolean.

Security considerations

It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.

Example:

unique?(:name, TestApp.User.Auth)
Link to this function

unregister(queue \\ true)

View Source
@spec unregister(boolean()) :: okey_return() | error_return()

This function stops all unregisters, For more information please see unregister/2.

Link to this function

unregister(atom, name, queue)

View Source
@spec unregister(:name | :event, module() | String.t(), boolean()) ::
  okey_return() | error_return()

This function removes the plugin from the database and kills all processes associated to it, in addition to doing the exact same thing as the stop/2 function.

The requested Event will be compiled once more in the event that the plugin is able to unregister properly. This is a heavy write activity

Security considerations

It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.

This module is a read-only in-memory storage optimized for the fastest possible read times not for write strategies.

It is not appropriate for the user to have any direct influence on this function because it is intended for the use of the programmer. It should be brought to your attention that this particular function, which incorporates the Write activity, should often be utilized only once at the beginning of the project.

Example:

# Unregister a plugin
unregister(:name, TestApp.User.Auth)

# Unregister all plugins of an event
unregister(:event, "after_login")
@spec write(builder_entry()) :: error_return() | okey_return()

To Add or edit a plugin information from Mnesia database.

Security considerations

It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.

Example:

write(%MishkaInstaller.Event.Event{name: TestApp.User.Auth, event: "after_login", extension: :test_app})
Link to this function

write(field, value, updated_to)

View Source
@spec write(atom(), String.t() | module(), map()) :: error_return() | okey_return()

To edit a specific field/fields of a plugin from the Mnesia database.

The first input can only be name and ID [:id, :name].

Security considerations

It is important to remember that all of the functionalities contained within this section must be implemented at the high access level, and they should not directly take any input from the user. Ensure that you include the required safety measures.

Example:

write(:name, TestApp.User.Auth, %{status: :started})