Skip to content

Singleton

Create singleton instance with default values

from config.spring import create_config_client


c = create_config_client(app_name="simpleweb000")
d = create_config_client(app_name="simpleweb000")

print(id(c))
print(id(d))

Create singleton instance with custom values

from config.spring import create_config_client


c = create_config_client(
    address='http://localhost:8888/configuration',
    app_name='myC-app',
    branch="development"
)
d = create_config_client(
    address='http://localhost:8888/configuration',
    app_name='myD-app',
    branch="development"
)

print(id(c))
print(id(d))

Singleton instance with decorator

from config.spring import config_client
from config.core import singleton


@singleton
@config_client(app_name="simpleweb000")
def my_test(config=None):
    print(config)
    return config

c = my_test()
d = my_test()
print(id(c))
print(id(d))