-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add redis password authentication support, closes #82
- Loading branch information
1 parent
14ec5da
commit ba1a91c
Showing
11 changed files
with
157 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,16 @@ | ||
"""API Events.""" | ||
|
||
# Project | ||
from hyperglass.util import check_redis | ||
from hyperglass.exceptions import HyperglassError | ||
from hyperglass.cache import AsyncCache | ||
from hyperglass.configuration import REDIS_CONFIG, params | ||
|
||
|
||
async def _check_redis(): | ||
"""Ensure Redis is running before starting server. | ||
Raises: | ||
HyperglassError: Raised if Redis is not running. | ||
Returns: | ||
{bool} -- True if Redis is running. | ||
""" | ||
try: | ||
await check_redis(db=params.cache.database, config=REDIS_CONFIG) | ||
except RuntimeError as e: | ||
raise HyperglassError(str(e), level="danger") from None | ||
|
||
async def check_redis() -> bool: | ||
"""Ensure Redis is running before starting server.""" | ||
cache = AsyncCache(db=params.cache.database, **REDIS_CONFIG) | ||
await cache.test() | ||
return True | ||
|
||
|
||
on_startup = (_check_redis,) | ||
on_startup = (check_redis,) | ||
on_shutdown = () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.