Urania v0.1.0 Urania

Efficient and elegant data access for Elixir.

It’s a port of a Clojure library named Urania.

A brief explanation blatantly stolen from https://funcool.github.io/urania/latest/ ensues:

Oftentimes, your business logic relies on remote data that you need to fetch from different sources: databases, caches, web services, or third party APIs, and you can’t mess things up. Urania helps you to keep your business logic clear of low-level details while performing efficiently:

  • batch multiple requests to the same data source

  • request data from multiple data sources concurrently

  • cache previous requests

Having all this gives you the ability to access remote data sources in a concise and consistent way, while the library handles batching and overlapping requests to multiple data sources behind the scenes.

Summary

Functions

Groups a list of muses and returns a new muse that will evaluate to a list of all the muses’ results

Runs a Urania muse and returns a Pinky promise of { result, data_source_cache_map }

Returns a new muse that will have a function applied to its value, assuming the function will return another muse

Returns a new muse that will have a function applied to its value

Runs a Urania muse and returns a Pinky promise of the result, discarding the cache

Runs a Urania muse and extracts it from the promise. It blocks until the run is completed

Groups a list of muses and returns a new muse that will evaluate to a list of all the muses’ results

Constructs a muse that will evaluate to a predefined value

Functions

collect(muses)

Groups a list of muses and returns a new muse that will evaluate to a list of all the muses’ results.

Examples

iex> Urania.collect([Urania.value(3), Urania.value(5)]) |> Urania.run!
{:ok, [3, 5]}
comp(f, g)
execute(ast_node)

Runs a Urania muse and returns a Pinky promise of { result, data_source_cache_map }.

Examples

iex> Urania.value(3) |> Urania.execute |> Pinky.extract
{:ok, {3, %{}}}
execute(ast_node, opts)
flat_map(muses, f)

Returns a new muse that will have a function applied to its value, assuming the function will return another muse.

Examples

iex> Urania.value(3) |> Urania.flat_map(fn x -> Urania.value(x + 1) end) |> Urania.run!
{:ok, 4}
identity(x)
inject_into(env, node)
is_data_source(x)
map(muses, f)

Returns a new muse that will have a function applied to its value.

Examples

iex> Urania.value(3) |> Urania.map(fn x -> x + 1 end) |> Urania.run!
{:ok, 4}
resource_name(res)
run(ast)

Runs a Urania muse and returns a Pinky promise of the result, discarding the cache.

Examples

iex> Urania.value(3) |> Urania.run |> Pinky.extract
{:ok, 3}
run(ast, opts)
run!(ast)

Runs a Urania muse and extracts it from the promise. It blocks until the run is completed.

Examples

iex> Urania.value(3) |> Urania.run!
{:ok, 3}
run!(ast, opts)
traverse(muses, f)

Groups a list of muses and returns a new muse that will evaluate to a list of all the muses’ results.

Examples

iex> [Urania.value(3), Urania.value(5)]
...> |> Urania.traverse(fn x -> Urania.value(x + 1) end)
...> |> Urania.run!
{:ok, [4, 6]}
value(v)

Constructs a muse that will evaluate to a predefined value.

Examples

iex> Urania.run!(Urania.value(3))
{:ok, 3}