Thank you @whatyouhide for the solution but I am still getting few errors with this approach.
dev.exs
config :my_app, :xandra,
nodes: System.get_env("CASSANDRA_HOST"),
authentication: {Xandra.Authenticator.Password,
[
username: System.get_env("CASSANDRA_USER"),
password: System.get_env("CASSANDRA_PASSWORD")
]
},
pool: DBConnection.Poolboy,
pool_size: 10
application.exs
children = [
# Start the Ecto repository
supervisor(MyApp.Repo, []),
# Start the endpoint when the application starts
supervisor(MyApp.Web.Endpoint, []),
worker(Cachex, [:app_cache, []]),
worker(MyApp.Scheduler, []),
{Xandra, Application.fetch_env!(:my_app, :xandra)}
]
Stacktrace
(Mix) Could not start application my_app: MyApp.Application.start(:normal, []) returned an error: shutdown: failed to start child: Xandra
** (EXIT) an exception was raised:
** (ArgumentError) multi-node use requires Xandra.Cluster instead of Xandra
(xandra) lib/xandra.ex:1027: Xandra.parse_nodes_option/1
(xandra) lib/xandra.ex:1010: Xandra.convert_nodes_options_to_address_and_port/1
(xandra) lib/xandra.ex:336: Xandra.start_link/1
(stdlib) supervisor.erl:379: :supervisor.do_start_child_i/3
(stdlib) supervisor.erl:365: :supervisor.do_start_child/2
(stdlib) supervisor.erl:349: anonymous fn/3 in :supervisor.start_children/2
(stdlib) supervisor.erl:1157: :supervisor.children_map/4
(stdlib) supervisor.erl:315: :supervisor.init_children/2
(stdlib) gen_server.erl:374: :gen_server.init_it/2
(stdlib) gen_server.erl:342: :gen_server.init_it/6
(stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
49: :proc_lib.init_p_do_apply/3
Then I changed the info in application.exs
to
children = [
# Start the Ecto repository
supervisor(MyApp.Repo, []),
# Start the endpoint when the application starts
supervisor(MyApp.Web.Endpoint, []),
worker(Cachex, [:app_cache, []]),
worker(MyApp.Scheduler, []),
{Xandra.Cluster, Application.fetch_env!(:my_app, :xandra)}
]
I got new exception
Could not start application my_app: MyApp.Application.start(:normal, []) returned an error: shutdown: failed to start child: Xandra.Cluster
** (EXIT) an exception was raised:
** (Protocol.UndefinedError) protocol Enumerable not implemented for "localhost:9042". This protocol is implemented for: Ecto.Adapters.SQL.Stream, Postgrex.Stream, Xandra.PageStream, Xandra.Page, DBConnection.Stream, DBConnection.PrepareStream, Timex.Interval, HashSet, Range, Map, Function, List, Stream, Date.Range, HashDict, GenEvent.Stream, MapSet, File.Stream, IO.Stream
(elixir) /Users/sahilpaudel/.kiex/builds/elixir-git/lib/elixir/lib/enum.ex:1: Enumerable.impl_for!/1
(elixir) /Users/sahilpaudel/.kiex/builds/elixir-git/lib/elixir/lib/enum.ex:141: Enumerable.reduce/3
(elixir) lib/enum.ex:3015: Enum.map/2
(xandra) lib/xandra/cluster.ex:204: Xandra.Cluster.start_link/1
(stdlib) supervisor.erl:379: :supervisor.do_start_child_i/3
(stdlib) supervisor.erl:365: :supervisor.do_start_child/2
(stdlib) supervisor.erl:349: anonymous fn/3 in :supervisor.start_children/2
(stdlib) supervisor.erl:1157: :supervisor.children_map/4
(stdlib) supervisor.erl:315: :supervisor.init_children/2
(stdlib) gen_server.erl:374: :gen_server.init_it/2
(stdlib) gen_server.erl:342: :gen_server.init_it/6
(stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
My env file
export CASSANDRA_HOST=localhost:9042
export CASSANDRA_USER=
export CASSANDRA_PASSWORD=
Thanks.