So I am using an Erlang application in my Elixir app. The Erlang docs say to either “set it up in the environment” or “use a .config” file.
I have installed the app by putting it in my mix file as a dependency and then added it to my application function.
What is the proper way to do this? Can I somehow use my config.exs? Should I do something in my mix.exs or should I just execute the eralng commmand application:set_env somewhere before I use it?
This is what I’m trying to configure.
# Fuse — A Circuit Breaker implementation for Erlang
This application implements a so-called circuit-breaker for Erlang.
[![Build Status](https://travis-ci.org/jlouis/fuse.png?branch=master)](https://travis-ci.org/jlouis/fuse)
*NOTE*: If you need to access FUSE (Filesystem in Userspace) then this is not the project you want. An Erlang implementation can be found in the *fuserl* project, https://code.google.com/p/fuserl/ or https://github.com/tonyrog/fuserl gives the pointers.
The current code status is that we have extensive test cases and test frameworks written around the code, but it has not been used in production systems yet. If you use the system in production, I would very much like to hear about it. Especially if you encountered any problems while doing so.
### Alternative implementations:
I know of a couple of alternative circuit breaker implementations for Erlang:
* *breaky* - https://github.com/mmzeeman/breaky - Breaky is implemented as an FSM in front of the protected service. This is another implementation model in which the breaker also controls service restarts once they fail. As such, it implements a slightly different pattern than *fuse*. In breaky, you have a process which can fail and you have a restart policy for that process. *breaky* will then handle the automatic restart policy and do circuit breaking handling for you. It is used in systems like Zotonic to handle cascading errors there.
* *circuit_breaker* - https://github.com/klarna/circuit_breaker - Klarna's battle-tested circuit breaker application. The pattern here is much closer to what fuse provides. However, the main difference is that in circuit_breaker, there can be different thresholds for different error types. This means you can be more specific as to what kind of error you have and how you plan on handling it. This tool also has the advantage of 8 years of battle-testing in production at Klarna. It may fit your use case if you can tolerate spawning a function per call to the circuit breaker application.
# Changelog
This file has been truncated. show original
1 Like
alco
June 8, 2016, 1:31pm
2
The contents of your config.exs
is used to populate the application environment for any OTP applications mentioned in it. You can add the following code there
config :fuse, stats_plugin: :fuse_stats_folsom
6 Likes
perfect so its gonna basically call
application:set_env(x,y,z) for any config :x, y: :z it finds?
1 Like
alco
June 8, 2016, 7:21pm
4
Pretty much, yes. You can also do
config :foo, [
key1: value1,
key2: value2,
...
]
which is equivalent to
Application.put_env(:foo, :key1, value1)
Application.put_env(:foo, :key2, value2)
...
4 Likes