chvanikoff / apns4ex

APNS for Elixir
MIT License
70 stars 23 forks source link

Allow dynamic connections to APNS #21

Closed adrienmo closed 8 years ago

adrienmo commented 8 years ago

rationale :

APNs configurations are not available when starting the elixir project, but are instead saved in a database (e.g. MySQL). We want to be able to dynamically create a connections when the configurations become available. Furthermore we can add a new application configuration on the fly.

solution :

chvanikoff commented 8 years ago

Good catch, well done! But please check my comment before I can merge it

adrienmo commented 8 years ago

pool_conf has not been accidentally removed, it is passed directly as init parameter of the worker

you can see the variable pool_conf being passed instead of simply the name :

Indeed, if the configuration is dynamic, there is no global variable to read it from ! The only call to the pool global config is made in the APNS module

chvanikoff commented 8 years ago

Yes, I see now, sorry for my inadvertence. Thank you, I'll merge it. New release is on the way.

adrienmo commented 8 years ago

Thank you !

Maybe the documentation should be updated with the following code example:

[
    {:Certificate, certder, :not_encrypted},
    {key_type, keyder, :not_encrypted}
] = :public_key.pem_decode(cert)

pool_conf = [
    env: :prod,
    pool_size: 10,
    pool_max_overflow: 5,
    cert: certder,
    key: {key_type, keyder}
]

APNS.connect_pool(:pool_name, pool_conf)