Comments (3)
This is also a problem for the redix_sentinel lib - where the mix config looks like:
config :my_app, :sentinel_config,
sentinels: [
[host: "10.200.X.X", port: 26379],
[host: "10.200.X.X", port: 26379],
[host: "10.200.X.X", port: 26379]
],
role: "master",
group: "misc"
@bitwalker if you could provide some guidance on how a config like this is supposed to look in .conf
format, I could take a crack at implementing a write_datatype
function.
from conform.
@vasspilka - for what it's worth, I solved my problem with transforms.
I changed my schema to look like this:
...
"my_app.blocklist_redis.sentinels": [
commented: false,
datatype: [list: :ip],
doc: "Sentinel host:port combinations",
hidden: false,
to: "my_app.blocklist_redis.sentinels"
],
"my_app.blocklist_redis.role": [
commented: false,
datatype: :binary,
doc: "Sentinel role",
hidden: false,
to: "my_app.blocklist_redis.role"
],
"my_app.blocklist_redis.group": [
commented: false,
datatype: :binary,
doc: "Sentinel group",
hidden: false,
to: "my_app.blocklist_redis.group"
],
...
and then added a transform like this:
transforms: [
"my_app.sentinel_config": fn pid ->
# Helper function to convert a list of :ip types into a list of [host: x.x.x.x, port: xxxx] tuples
# (I haven't quite figured out how to use "import" yet :) )
ip_reducer = fn val ->
Enum.reduce(val, [], fn {host, port}, acc ->
[[host: host, port: String.to_integer(port)] | acc]
end)
end
redis_config =
pid
|> Conform.Conf.find("my_app.sentinel_config.$")
|> Enum.reduce(Keyword.new, fn {[_, _, _, key], val}, acc ->
cond do
is_nil(val) -> acc
is_list(val) -> Keyword.put_new(acc, List.to_atom(key), ip_reducer.(val))
true -> Keyword.put_new(acc, List.to_atom(key), val)
end
end)
Conform.Conf.remove(pid, "my_app.sentinel_config.$")
redis_config
end
],
from conform.
Yes, that's what I ended up doing as well :) . I am closing this issue in favor of Transforms https://hexdocs.pm/conform/getting-started.html#content Sadly they are not well documented but that is another issue, I could great a PR with better docs for Transforms, Types @bitwalker is there interest for this?
from conform.
Related Issues (20)
- Elixir 1.5.0 - erlang error: {:badrecord, :elixir_erl} HOT 9
- Conform fails to parse schema for umbrella app during release generation HOT 3
- Schema not found message with multiple level schema extends HOT 2
- Failing to parse binary HOT 3
- Does conform work without release? HOT 3
- UndefinedFunctionError - module Conform.Conf is not available HOT 8
- Failed to parse .conf! from autogenerated .conf file with very simple schema HOT 2
- pre_configure.sh missing - mix release fails with distillery v1.4.1
- Release fails on start because of blank SYS_CONFIG_PATH in 00_conform_pre_configure.sh HOT 1
- Environment variables should override .conf values HOT 2
- Is it possible to set vm.args variables like the cookie HOT 1
- Empty lists in .conf file
- No support for types such as tuples. HOT 2
- release with distillery in :prod env not working HOT 1
- app not starting when configured using conform HOT 1
- Troubles getting started HOT 6
- `default: []` not working in umbrella release
- An issue with conform.new
- undeprecate conform HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from conform.