I try create a service for mongodb , but when I try get MONGO_URI using COnf, display method not found.
Hello!
It seems that your autocomplete feature of you IDE is pointing you to another type of Config.
I’ve created a small test service with nameko 2.14.0:
service.py
from nameko.dependency_providers import Config
from nameko.web.handlers import http
class Service:
name = "test_config"
config = Config()
@http("GET", "/")
def foo(self, request):
return f'Config Mongo url is {self.config.get("MONGODB_URI", "http://localhost:27017")}'
A config.yml
MONGODB_URI: "http://mongodb.com:27017"
And works as expected:
$ nameko run service --config config.yml
Try to run your service, it looks good. I don’t use pyright, but it seems to interfere with nameko’s config type on autocomplete.
Cheers!