Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 1.0.6 #39

Merged
merged 11 commits into from
May 26, 2022
Prev Previous commit
Next Next commit
feat: only load redis when needed, fixes #23
  • Loading branch information
msimerson committed May 26, 2022
commit 9be6b50c46101a121178e1bc55d4748bfee82d57
15 changes: 12 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ const ipaddr = require('ipaddr.js');
exports.register = function () {
this.inherits('haraka-plugin-redis');

this.register_hook('init_master', 'init_redis_plugin');
this.register_hook('init_child', 'init_redis_plugin');

this.load_limit_ini();
let needs_redis = 0

if (this.cfg.concurrency.enabled) {
this.register_hook('connect_init', 'conn_concur_incr');
Expand All @@ -32,29 +30,40 @@ exports.register = function () {
}

if (this.cfg.rate_conn.enabled) {
needs_redis++
this.register_hook('connect_init', 'rate_conn_incr');
this.register_hook('connect', 'rate_conn_enforce');
}
if (this.cfg.rate_rcpt_host.enabled) {
needs_redis++
this.register_hook('connect', 'rate_rcpt_host_enforce');
this.register_hook('rcpt', 'rate_rcpt_host_incr');
}
if (this.cfg.rate_rcpt_sender.enabled) {
needs_redis++
this.register_hook('rcpt', 'rate_rcpt_sender');
}
if (this.cfg.rate_rcpt_null.enabled) {
needs_redis++
this.register_hook('rcpt', 'rate_rcpt_null');
}
if (this.cfg.rate_rcpt.enabled) {
needs_redis++
this.register_hook('rcpt', 'rate_rcpt');
}

if (this.cfg.outbound.enabled) {
needs_redis++
this.register_hook('send_email', 'outbound_increment');
this.register_hook('delivered', 'outbound_decrement');
this.register_hook('deferred', 'outbound_decrement');
this.register_hook('bounce', 'outbound_decrement');
}

if (needs_redis) {
this.register_hook('init_master', 'init_redis_plugin');
this.register_hook('init_child', 'init_redis_plugin');
}
}

exports.load_limit_ini = function () {
Expand Down