florinpatrascu / bolt_sips

Neo4j driver for Elixir
Apache License 2.0
256 stars 49 forks source link

Starting Manually #25

Closed rawkode closed 7 years ago

rawkode commented 7 years ago

Hi,

You specify:

2. Ensure bolt_sips is started before your application:

def application do
  [applications: [:bolt_sips]]
end

This makes it impossible to provide configuration at runtime, using :weave.

I've tried adding runtime: false to stop BoltSips automatically starting up and instead manually starting it in my application module callback, with

supervisor(Bolt.Sips, [Application.get_env(:bolt_sips, Bolt)])

but this causes everything to "hang"

florinpatrascu commented 7 years ago

Hi,

I could resurrect the code I used before, that would let the user start the app before the user's, and pass a custom configuration.

Your problem, if I understand correctly, is that you want to configure bolt_sips using :wave? Didn't hear about :wave till now, sorry. I'll try to find the time and look into this, unless you already have a PR? :)

Florin

rawkode commented 7 years ago

I think I have a version working. I'll PR it when I've done more testing :+1:

florinpatrascu commented 7 years ago

Awesome! Thank you!!

rawkode commented 7 years ago

OK, I thought I had this; but unfortunately I don't. Help appreciated :+1:

florinpatrascu commented 7 years ago

Hi David - can you please check v0.3.1? Now, you can do something like this:

 def application do
    # Specify extra applications you'll use from Erlang/Elixir
    [ extra_applications: [:logger], mod: 
      {Bolt.Sips.Application, [url: 'localhost', pool_size: 15]}
    ]
  end

Please let me know if this version can be used with weave.

HTH

rawkode commented 7 years ago

Hi @florinpatrascu, nothing above 2.4.6 seems published to hex?

rawkode commented 7 years ago

Sorry, I see; it's a branch. I'll give it a try :+1:

rawkode commented 7 years ago

Hi @florinpatrascu,

OK; I've found the problem.

Firstly, I need to stop :bolt_sips starting automatically, as it needs configured before launch.

For this, I added app: :false to the deps and that seems great.

I then add worker(Bolt.Sips, [Application.get_env(:bolt_sips, Bolt)]) to my application supervisor and things begin to break.

It turns out, once my app adds the worker and calls start_link on Bolt.Sips, the following call blocks indefinitely:

ConCache.start_link([], name: :bolt_sips_cache)

Removing ConCache altogether gets it working for me.

rawkode commented 7 years ago

From what I can tell, this is a micro-optimisation anyway, with no real value. Perhaps we could remove it? Or is there something I'm missing?

florinpatrascu commented 7 years ago

David, np - can you please give me an example of how you would like to use :bolt_sips, with :weave? I am sure I am too missing something. This branch, 0.3.1 respectively, is allowing you to start Bolt.Sips from your app and also to specify configuration variables that will override your config/${MIX_ENV}.exs files. In this branch, :bolt_sips will not start automatically anymore. I thought that's what you wanted?!

florinpatrascu commented 7 years ago

also, you said before:

Firstly, I need to stop :bolt_sips starting automatically, as it needs configured before launch.

this is what 0.3.1 does, to start with

florinpatrascu commented 7 years ago

and if you don't mind, how can I replicate this:

[...] the following call blocks indefinitely: ConCache.start_link([], name: :bolt_sips_cache)

many thanks, for your patience!

rawkode commented 7 years ago

You're right, 0.3.1 does fix this; awesome!

I know that environment variables can be injected too, but for delivering secrets, it's best to use other means: which is what I am using :weave for.

I'll put together a small application that demos my issue.

Thanks for your help

florinpatrascu commented 7 years ago

niceee!!! Glad it helps!!! 🍻

rawkode commented 7 years ago

0.3.1 works as needed. Thanks :+1:

florinpatrascu commented 7 years ago

Awesome. Tonight, I'll publish the new version on hex.pm Thank you, for your feedback!

florinpatrascu commented 7 years ago

Package published to https://hex.pm/packages/bolt_sips/0.3.1