Wei-Yu Chen | ad55cb8 | 2022-02-15 20:07:01 +0800 | [diff] [blame] | 1 | # SPDX-FileCopyrightText: 2020 The Magma Authors. |
| 2 | # SPDX-FileCopyrightText: 2022 Open Networking Foundation <support@opennetworking.org> |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
Wei-Yu Chen | 49950b9 | 2021-11-08 19:19:18 +0800 | [diff] [blame] | 5 | |
Wei-Yu Chen | 49950b9 | 2021-11-08 19:19:18 +0800 | [diff] [blame] | 6 | import redis |
| 7 | from configuration.service_configs import get_service_config_value |
| 8 | |
| 9 | |
| 10 | def get_default_client(): |
| 11 | """ |
| 12 | Return a default redis client using the configured port in redis.yml |
| 13 | """ |
| 14 | redis_port = get_service_config_value('redis', 'port', 6379) |
| 15 | redis_addr = get_service_config_value('redis', 'bind', 'localhost') |
| 16 | return redis.Redis(host=redis_addr, port=redis_port) |