From 118c426824db6beedfa220eee0fced1326d629b6 Mon Sep 17 00:00:00 2001 From: Maxime Besson Date: Fri, 27 Sep 2024 10:06:25 +0200 Subject: [PATCH] Make broker dependencies optional --- .../lib/Lemonldap/NG/Common/MessageBroker/MQTT.pm | 4 +++- .../lib/Lemonldap/NG/Common/MessageBroker/Pg.pm | 2 +- .../lib/Lemonldap/NG/Common/MessageBroker/Redis.pm | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/MessageBroker/MQTT.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/MessageBroker/MQTT.pm index 0416d4df55..83754a72a2 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/MessageBroker/MQTT.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/MessageBroker/MQTT.pm @@ -1,12 +1,14 @@ package Lemonldap::NG::Common::MessageBroker::MQTT; use strict; -use Net::MQTT::Simple; our $VERSION = '2.20.0'; sub new { my ( $class, $conf, $logger ) = @_; + + require Net::MQTT::Simple; + my $args = $conf->{messageBrokerOptions}; $args //= {}; $args->{server} ||= 'localhost:1883'; diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/MessageBroker/Pg.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/MessageBroker/Pg.pm index e15e9d0f47..dcd21f7f64 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/MessageBroker/Pg.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/MessageBroker/Pg.pm @@ -1,13 +1,13 @@ package Lemonldap::NG::Common::MessageBroker::Pg; use strict; -use DBI; use JSON; our $VERSION = '2.20.0'; sub new { my ( $class, $conf, $logger ) = @_; + require DBI; my $args = $conf->{messageBrokerOptions}; unless ($args and $args->{dbiChain} diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/MessageBroker/Redis.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/MessageBroker/Redis.pm index e444395b72..4a2b53fdc5 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/MessageBroker/Redis.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/MessageBroker/Redis.pm @@ -1,13 +1,13 @@ package Lemonldap::NG::Common::MessageBroker::Redis; use strict; -use Redis; use JSON; our $VERSION = '2.20.0'; sub new { my ( $class, $conf, $logger ) = @_; + require Redis; my $self = bless { logger => $logger }, $class; my $args = $conf->{messageBrokerOptions} // {}; -- GitLab