tyyppi v0.2.0 Tyyppi.Stats View Source

Process caching the loaded types information.

Whether your application often uses the types information, it makes sense to cache it in a process state, because gathering it takes some time. In such a case your application should start this process in the application’s supervision tree, and call Tyyppi.Stats.rehash!/0 every time when the new module is compiled in the runtime.

Link to this section Summary

Types

Function to be called upon rehashing. When arity is 0, the full new state would be passed, for arity 1, added and removed types would be passed, for arity 2, added, removed, and full state would be passed.

Types information cache

Functions

Returns a specification to start this module under a supervisor.

Rehashes the types information currently available in the system. This function should be called after the application has created a module in runtime for this module information to appear in the cache.

Starts the cache process. The optional parameter might contain any payload that will be stored in the process’ state.

Retrieves the type information for the type given.

Retrieves all the types information currently available in the system.

Link to this section Types

Specs

callback() ::
  (info() -> any())
  | (info(), info() -> any())
  | (info(), info(), info() -> any())

Function to be called upon rehashing. When arity is 0, the full new state would be passed, for arity 1, added and removed types would be passed, for arity 2, added, removed, and full state would be passed.

Specs

info() :: %{required((... -> any())) => Tyyppi.T.t()}

Types information cache

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Specs

rehash!() :: :ok | {:error, :not_started}

Rehashes the types information currently available in the system. This function should be called after the application has created a module in runtime for this module information to appear in the cache.

Specs

start_link(meta :: keyword()) :: GenServer.on_start()

Starts the cache process. The optional parameter might contain any payload that will be stored in the process’ state.

If a payload has callback :: (-> :ok) parameter, this function will be called every time the types information gets rehashed.

Specs

type(
  (... -> any())
  | atom()
  | Tyyppi.T.ast()
  | Tyyppi.T.raw()
  | {module(), atom(), list() | nil | non_neg_integer()}
) :: Tyyppi.T.t()

Retrieves the type information for the type given.

Specs

types() :: info()

Retrieves all the types information currently available in the system.