Passing Parameter Class From Service Runner

Hii, i am new user using nameko for microservices my apps, but i got problem how to passing parameter from service runner?? for example service A def X has param type, how to passing that param from service runner.

import eventlet
from nameko.rpc import rpc
from nameko.runners import ServiceRunner


eventlet.monkey_patch()

class ServiceA
    name = "service_a"
    @rpc
    def x(self, type):
        print('this type', type)
        return "A"


class ServiceB
    name = "service_b"
    @rpc
    def x(self):
        return "B"

runner = ServiceRunner(config={"AMQP_URI":"pyamqp://quest:quest@192.168.1.42"})
//passing param
runner.add_service(ServiceA)
runner.add_service(ServiceB)

runner.start()

Hi @kankburhan

I’m not entirely sure what are you after, but there is a Config dependency that you can use as described here: https://nameko.readthedocs.io/en/stable/built_in_dependency_providers.html#config

Also worth remembering environment variable substitution is also supported within config: https://nameko.readthedocs.io/en/stable/cli.html#environment-variable-substitution

Hii @Jakub_Borys i thanks for your reply, i can get my config with this code

Preformatted text`lass ServiceA
name = “service_a”
config = Config()

@rpc
def x(self, type):
    self.config.get('param')
    print('this type', type)
    return "A"

but i want get before @rpc like this:

Preformatted text`lass ServiceA
name = “service_a”
config = Config()
//get config this line

@rpc
def x(self, type):

This functionality (global config) is available in a pre-release version (v3) of Nameko. You can install it with pip install --pre nameko

Find usage example here