From 2af827ee6da793ee3024ab646f39dd56f93a14e6 Mon Sep 17 00:00:00 2001 From: Tom Date: Thu, 9 Dec 2021 22:40:16 +0000 Subject: [PATCH] Rabbitmq: fetch server url from env, default to localhost * user can set RABBITMQ_MGMT_URL, USER & PASS to setup rabbitmq managment api location & credentials. --- src/RabbitMQ.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/RabbitMQ.php b/src/RabbitMQ.php index 80585a5..a3983f7 100644 --- a/src/RabbitMQ.php +++ b/src/RabbitMQ.php @@ -8,10 +8,14 @@ trait RabbitMQ { static private function getRabbitMqClient() { + $base_url = getenv("RABBITMQ_MGMT_URL") ?: "http://localhost:15672"; + $user = getenv("RABBITMQ_USER") ?: "guest"; + $password = getenv("RABBITMQ_PASS") ?: "guest"; + return new Client([ - "base_uri" => "http://127.0.0.1:15672", + "base_uri" => $base_url, "headers" => ["Content-Type" => "application/json"], - "auth" => ["guest", "guest"] + "auth" => [$user, $password] ]); }