whatyouhide/xandra

How to start Xandra as child process?

Closed this issue · 1 comments

I am trying to use Xandra for my Phoenix project for which I am connecting to Cassandra like

{:ok, conn} = Xandra.start_link([
nodes: ["localhost:9042"]
])
Every time I am suppose to run a query I need to start_link, Is there a way I can provide all connection details in config file and it runs once the app is started?

Like below

config :xandra, Xandra,
  pool_size: 10,
  nodes: ["localhost:9042"],
  authentication: {Xandra.Authenticator.Password, [username: "", password: ""]}

Thanks

You need to manually read that from the app env.

# in config/config.exs
config :my_app, :my_xandra,
  nodes: ...

# in lib/my_app/application.ex
children = [
  # ...,
  {Xandra, Application.fetch_env!(:my_app, :my_xandra)}
]

Closing this as there's no issue here with Xandra per se. Thanks for the question! 💟