View Source Tyyppi.Stats (tyyppi v0.12.3)

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

@type 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.

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

Types information cache

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

@spec rehash!() :: :ok

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.

Link to this function

start_link(types \\ %{}, meta \\ [])

View Source
@spec start_link(types :: info(), 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.

@spec type((... -> any()) | atom() | Tyyppi.T.ast() | Tyyppi.T.raw()) ::
  Tyyppi.T.t(wrapped)
when wrapped: term()

Retrieves the type information for the type given.

@spec types() :: info()

Retrieves all the types information currently available in the system.