Packages

Typed distributed messaging for Gleam on the BEAM.

Retired package: Deprecated - The project needs to be redesigned around a much smaller and clearer core.

Current section

Files

Jump to
distribute src distribute@settings.erl
Raw

src/distribute@settings.erl

-module(distribute@settings).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/distribute/settings.gleam").
-export([set_allow_atom_creation/1, is_allow_atom_creation/0, set_use_crypto_ids/1, is_use_crypto_ids/0, set_max_message_size/1, get_max_message_size/0]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
-file("src/distribute/settings.gleam", 32).
?DOC(
" Enable or disable dynamic atom creation from untrusted input.\n"
" \n"
" When disabled (default), functions that would create atoms from\n"
" external data will fail safely instead. This prevents atom table\n"
" exhaustion attacks.\n"
).
-spec set_allow_atom_creation(boolean()) -> nil.
set_allow_atom_creation(Allow) ->
_ = settings_ffi:set_allow_atom_creation(Allow),
nil.
-file("src/distribute/settings.gleam", 38).
?DOC(" Check if dynamic atom creation is currently allowed.\n").
-spec is_allow_atom_creation() -> boolean().
is_allow_atom_creation() ->
settings_ffi:get_allow_atom_creation().
-file("src/distribute/settings.gleam", 46).
?DOC(
" Enable or disable cryptographic identifiers for registry names.\n"
" \n"
" When enabled, registry names are hashed using a secure algorithm\n"
" to prevent name collision attacks.\n"
).
-spec set_use_crypto_ids(boolean()) -> nil.
set_use_crypto_ids(Use_crypto) ->
_ = settings_ffi:set_use_crypto_ids(Use_crypto),
nil.
-file("src/distribute/settings.gleam", 52).
?DOC(" Check if cryptographic identifiers are currently enabled.\n").
-spec is_use_crypto_ids() -> boolean().
is_use_crypto_ids() ->
settings_ffi:get_use_crypto_ids().
-file("src/distribute/settings.gleam", 81).
?DOC(
" Set the maximum allowed message size in bytes.\n"
"\n"
" Messages larger than this limit will be rejected by `messaging.send_binary`\n"
" and `groups.broadcast_binary`. This prevents memory exhaustion attacks\n"
" from malicious or misconfigured peers.\n"
"\n"
" ## Parameters\n"
"\n"
" - `size`: Maximum message size in bytes. Must be >= 0.\n"
" Use 0 to disable size checking (not recommended for production).\n"
"\n"
" ## Default\n"
"\n"
" The default is 10MB (10,485,760 bytes), which is suitable for most\n"
" use cases. Increase if you need to send larger payloads.\n"
"\n"
" ## Example\n"
"\n"
" ```gleam\n"
" // Allow messages up to 50MB\n"
" settings.set_max_message_size(50 * 1024 * 1024)\n"
"\n"
" // Restore default\n"
" settings.set_max_message_size(settings.default_max_message_size)\n"
" ```\n"
).
-spec set_max_message_size(integer()) -> nil.
set_max_message_size(Size) ->
_ = settings_ffi:set_max_message_size(Size),
nil.
-file("src/distribute/settings.gleam", 89).
?DOC(
" Get the current maximum allowed message size in bytes.\n"
"\n"
" Returns the configured limit, or 10MB if not explicitly set.\n"
).
-spec get_max_message_size() -> integer().
get_max_message_size() ->
settings_ffi:get_max_message_size().