init_consul.py 1.19 KB
Newer Older
崔为之's avatar
崔为之 committed
1 2 3 4 5 6 7 8 9
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
# @Version     : Python 3.11.4
# @Software    : Sublime Text 4
# @Author      : StudentCWZ
# @Email       : StudentCWZ@outlook.com
# @Date        : 2023/11/21 10:01
# @File        : init_consul.py
崔为之's avatar
崔为之 committed
10
# @Description : Initializes the FlaskConsulService for a Flask application.
崔为之's avatar
崔为之 committed
11 12
"""

崔为之's avatar
崔为之 committed
13
# Import built-in modules
崔为之's avatar
崔为之 committed
14 15
from flask import Flask

崔为之's avatar
崔为之 committed
16
# Import custom modules
崔为之's avatar
崔为之 committed
17 18 19 20
from application.libs import FlaskConsulService


def init_consul(app: Flask) -> None:
崔为之's avatar
崔为之 committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
    """
    Initialize the Consul service.

    This function creates an instance of the FlaskConsulService class, passing
    the Flask application instance as an argument. This sets up the Consul
    service for the Flask application.

    Consul is a service networking solution to automate network configurations,
    discover services, and enable secure connectivity across any cloud or runtime.

    Args:
        app (Flask): The Flask application instance.

    Returns:
        None
    """
    # Initialize the FlaskConsulService with the Flask application instance.
    # The FlaskConsulService constructor is responsible for setting up
    # the Consul service for the Flask application.
崔为之's avatar
崔为之 committed
40
    FlaskConsulService(app)