coingaming / coney

Consumer server for RabbitMQ with message publishing functionality.
MIT License
42 stars 9 forks source link

Support passing options to the connection #10

Closed bdusauso closed 3 years ago

bdusauso commented 5 years ago

As I can see from RabbitConnection it's not possible to pass other options than url and timeout to the connection. In order to support, for example, SSL, it would be nice to pass these options directly to AMQP.Connection.open/2.

Moreover, instead of a hash I think it's more idiomatic to use a keyword, like this:

config :coney,
  adapter: Coney.RabbitConnection,
  pool_size: 1,
  settings: [
    url: "amqp://guest:guest@localhost",
    timeout: 1000,
   ssl_options: [
         cacertfile: "cacert.pem",
         certfile:   "cert.pem",
         keyfile:    "key.pem",
         verify: :verify_peer,
         fail_if_no_peer_cert: true,
         server_name_indication: :disable
       ]
  ],
  workers: [
    MyApplication.MyConsumer
  ]
# also you can define mapping like this and skip it in consumer module:
  workers: [
    [
      connection: [
        prefetch_count: 10,
        exchange:       {:direct, "my_exchange", durable: true},
        queue:          {"my_queue", durable: true},
        binding:        [routing_key: "routing_key"]
      ],
      worker: MyApplication.MyConsumer
    ]
  ]

What do you think ?

llxff commented 5 years ago

Hi, would be great to have this.

instead of a hash I think it's more idiomatic to use a keyword, like this:

I think would be better to leave map because of backward compatibility.

bdusauso commented 5 years ago

Hi, would be great to have this.

I will provide a PR as soon as possible.

instead of a hash I think it's more idiomatic to use a keyword, like this:

I think would be better to leave map because of backward compatibility.

Oh, I see. At the end it's just a matter of consistency and taste 😃

llxff commented 5 years ago

Awesome 👍

bdusauso commented 5 years ago

See PR #12