From 02b83abac9c86fe523d25cedec85c766f215aafd Mon Sep 17 00:00:00 2001 From: Ruslan Gainutdinov Date: Thu, 31 Aug 2017 00:23:14 +0300 Subject: [PATCH] v. 0.8 Added ability to configure Redis password by REDIS_PASSWORD env variable --- README.md | 15 ++++++--------- pom.xml | 2 +- .../com/wizecore/metrics/PersistenceUtil.java | 4 ++++ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 28807cd..2a39c37 100644 --- a/README.md +++ b/README.md @@ -45,22 +45,19 @@ Maven repository is created using [jitpack.io](https://jitpack.io/) [![](https:/ com.wizecore persistent-metrics - 0.7 + 0.8 ``` -## Configuring Redis +## Configuring By default it uses locally installed Redis (default port, i.e. 6379) -To configure redis use following environment variables: +To configure use following environment variables: * REDIS_CONF - Redisson JSON [config](https://github.com/redisson/redisson/wiki/2.-Configuration#221-jsonyaml-file-based-configuration) file. Takes precedence. - * REDIS_ADDR - host:port for single server. - -## Configuring prefix - -By default all metrics is put in redis using prefix "metrics.". -To configure different prefix use METRIC_PREFIX environment variable (dot at the end is added automatically). + * REDIS_ADDR - host:port for single server. Have no effect if REDIS_CONF is defined. + * METRIC_PREFIX - Prefix for all values stored. Default is "metrics.". Dot at the end is added automatically. + * REDIS_PASSWORD - Password for single server. Have no effect if REDIS_CONF is defined. ## License diff --git a/pom.xml b/pom.xml index 83629c7..f8dc092 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.wizecore persistent-metrics jar - 0.7 + 0.8 persistent-metrics http://github.com/wizecore/persistent-metrics diff --git a/src/main/java/com/wizecore/metrics/PersistenceUtil.java b/src/main/java/com/wizecore/metrics/PersistenceUtil.java index c96ff73..c9fe36a 100644 --- a/src/main/java/com/wizecore/metrics/PersistenceUtil.java +++ b/src/main/java/com/wizecore/metrics/PersistenceUtil.java @@ -64,6 +64,10 @@ protected static void init() { redisAddr = System.getenv("REDIS_ADDR"); } + if (redisPassword == null) { + redisPassword = System.getenv("REDIS_PASSWORD"); + } + if (metricPrefix == null) { metricPrefix = System.getenv("METRIC_PREFIX"); }