Packages
journey
0.10.44
0.10.58
0.10.57
0.10.56
0.10.55
0.10.54
0.10.53
0.10.52
0.10.51
0.10.50
0.10.49
0.10.48
0.10.47
0.10.46
0.10.45
0.10.44
0.10.43
0.10.41
0.10.40
0.10.39
0.10.38
0.10.37
0.10.36
0.10.35
0.10.34
0.10.33
0.10.32
0.10.31
0.10.30
0.10.29
0.10.28
0.10.27
0.10.26
0.10.25
0.10.24
0.10.23
0.10.22
0.0.9
retired
0.0.8
0.0.7
0.0.6
0.0.5
0.0.3
0.0.2
Journey is a library for defining and running durable workflows with persistence, reliability, and scalability.
Current section
Files
Jump to
Current section
Files
lib/journey/helpers/random.ex
defmodule Journey.Helpers.Random do
@moduledoc false
@digits "1234567890"
@uppercase "ABDEGHJLMRTVXYZ"
@lowercase String.downcase(@uppercase)
def digits(), do: @digits
def uppercase(), do: @uppercase
def lowercase(), do: @lowercase
def any_char_or_digit(), do: digits() <> uppercase() <> lowercase()
def random_string(length \\ 12, dictionary \\ any_char_or_digit()) when is_number(length) and is_binary(dictionary) do
Nanoid.generate(length, dictionary)
end
def random_string_w_time(length \\ 12, dictionary \\ any_char_or_digit())
when is_number(length) and is_binary(dictionary) do
random_string(length, dictionary) <> "#{System.system_time(:microsecond)}"
end
def object_id(prefix) when is_binary(prefix) do
String.upcase(prefix) <> random_string(20, digits() <> uppercase())
end
end