Yes, I agree with you, maybe App is not the suitable for this, and actually the Start and Stop is empty for my config App, I just use this as a extension point to define some resources, initialize them and then save in the registry, then in some other modules, I just want to reference it by a name, not define all needed information multiple places. for example,
{
"apps": {
"config": {
"database": {
"go-redis": {
"dbs": [
{
"id": "default",
"client_options": {
"db": 0,
"addr": "127.0.0.1:6379",
"password": "",
"max_retries": 1,
"dial_timeout": "5s",
"read_timeout": "5s",
"pool_size": 10,
// ...
},
"codec_options": {
"use_redis_cache": true,
"use_local_cache": true,
"local_cache_max_items": 5000,
"local_cache_expiration": "30s"
}
}
]
}
}
}
}
}
then for example, in a ratelimit Module, I just want reference it by name “default”, like this,
{
// ...
"routes": [
"match": [
// ...
],
"handle": [
{
"handler": "ratelimit",
"limiter_name": "default",
"duration": "1m",
"limit": "20000",
"request_extractor": {
"use_path": true,
"use_arguments": [
"channel"
]
}
}
// ...
]
]
// ...
}
Here I don’t want to define the connection parameters repeatedly,but just reference it by this "limiter_name: "default"
, because I might define different ratelimit in multiple places, it will make the config too verbose.
I didn’t find any other way to solve it, if there is, pls let me know.