View Source bcrypt_pool (bcrypt v1.2.2)

Implementation of gen_server behaviour.

Link to this section Summary

Functions

Asynchronously check if Pid in #state:requests queue or not.
Generate a random text salt.
Generate a random text salt. Rounds defines the complexity of the hashing, increasing the cost as 2^log_rounds.
Hash the specified password and the salt.
Is at least one bcrypt worker currently available for work?
Creates a gen_server process as part of a supervision tree.

Link to this section Types

-type state() :: #state{size :: 0, busy :: 0, requests :: queue:queue(), ports :: queue:queue()}.

Link to this section Functions

-spec available(Pid) -> Result when Pid :: pid(), Result :: ok.
Asynchronously check if Pid in #state:requests queue or not.
-spec gen_salt() -> Result when Result :: {ok, Salt}, Salt :: [byte()].
Generate a random text salt.
-spec gen_salt(Rounds) -> Result when Rounds :: bcrypt:rounds(), Result :: {ok, Salt}, Salt :: [byte()].
Generate a random text salt. Rounds defines the complexity of the hashing, increasing the cost as 2^log_rounds.
Hash the specified password and the salt.
-spec is_worker_available() -> Result when Result :: boolean().
Is at least one bcrypt worker currently available for work?
-spec start_link() -> Result
              when
                  Result :: {ok, Pid} | ignore | {error, Error},
                  Pid :: pid(),
                  Error :: {already_started, Pid} | term().
Creates a gen_server process as part of a supervision tree.