Krptkn.Api (Кропоткин Framework v0.1.0) View Source

This "API" allows to save meta information about Krptkn's state and exposes functions so phoenix can get the information and display it.

Link to this section Summary

Functions

Adds one to a count.

Adds a piece of metadata detected to be dangerous.

Adds a file type to the list.

Adds a URL to the last visited URLs list.

Adds a piece of metadata and increments the count of metadata. There is no need to call Krptkn.Api.add(:metadata) if you call this method.

Adds a response type to the list.

Returns a specification to start this module under a supervisor.

Gets the count of an element.

Returns history of counts of elements. The interval is one second.

Returns the dangerous metadata we have saved until now.

Deletes all data saved on this module (URLs and the database remain intact).

State of the API module. This is all the information being saved.

Returns the last URLs that we have visited.

Returns the memory state. To see the structure of the data, this is where it comes from: :erlang.memory

Returns the metadata we have saved until now.

Returns the list of processes.

Adds a process to the list.

Returns the scheduler state. To see the structure of the data, this is how it is saved: :scheduler.utilization(:scheduler.sample_all())

Link to this section Functions

Specs

add(:url | :danger | :metadata | :fmetadata) :: any()

Adds one to a count.

Returns :ok.

Examples

iex> Krptkn.Api.add(:metadata)
:ok
Link to this function

add_dangerous_metadata(metadata)

View Source

Adds a piece of metadata detected to be dangerous.

Returns :ok.

Examples

iex> Krptkn.Api.add_dangerous_metadata(%{...})
:ok
Link to this function

add_file_type(file_type)

View Source

Adds a file type to the list.

Returns :ok.

Examples

iex> Krptkn.Api.add_file_type(file_type)
:ok

Adds a URL to the last visited URLs list.

Returns :ok.

Examples

iex> Krptkn.Api.add_last_url("https://stallman.org/")
:ok

Adds a piece of metadata and increments the count of metadata. There is no need to call Krptkn.Api.add(:metadata) if you call this method.

Returns :ok.

Examples

iex> Krptkn.Api.add_metadata(%{...})
:ok
Link to this function

add_response_type(response_type)

View Source

Adds a response type to the list.

Returns :ok.

Examples

iex> Krptkn.Api.add_response_type(response_type)
:ok

Returns a specification to start this module under a supervisor.

See Supervisor.

Specs

count(:url | :danger | :metadata | :fmetadata) :: any()

Gets the count of an element.

Returns a number.

Examples

iex> Krptkn.Api.count(:metadata)
132

Specs

count_history(:url | :danger | :metadata | :fmetadata) :: any()

Returns history of counts of elements. The interval is one second.

Returns :ok.

Examples

iex> Krptkn.Api.count_history(:metadata)
[123, 145, 167, 178]

Returns the dangerous metadata we have saved until now.

Returns list of maps.

Examples

iex> Krptkn.Api.dangerous_metadata()
[
  %{...},
  %{...},
  %{...}
]

Deletes all data saved on this module (URLs and the database remain intact).

Returns :ok.

Examples

iex> Krptkn.Api.delete_all()
:ok

State of the API module. This is all the information being saved.

Returns the last URLs that we have visited.

Returns a list of strings.

Examples

iex> Krptkn.Api.last_urls()
[
  "https://hexdocs.pm/elixir/GenServer.html",
  "https://hexdocs.pm/elixir/Kernel.SpecialForms.html",
  "https://hexdocs.pm/elixir/Atom.html",
]

Returns the memory state. To see the structure of the data, this is where it comes from: :erlang.memory

Returns the metadata we have saved until now.

Returns list of maps.

Examples

iex> Krptkn.Api.metadata()
[
  %{...},
  %{...},
  %{...}
]

Returns the list of processes.

Returns a list of maps.

Examples

iex> Krptkn.Api.processes()
[
  %{...},
  %{...},
  %{...}
]
Link to this function

register_process(module, name, pid)

View Source

Adds a process to the list.

Returns :ok.

Examples

iex> Krptkn.Api.register_process(__MODULE__, name, self())
:ok

Returns the scheduler state. To see the structure of the data, this is how it is saved: :scheduler.utilization(:scheduler.sample_all())

Specs

start_link([]) :: :ignore | {:error, any()} | {:ok, pid()}