Hi Guys!
I’m trying to figure out how to use the serviceRunner and I have a lot of questions. More than answers.
my first example code app.py
:
import eventlet
from nameko.rpc import rpc
from nameko.runners import ServiceRunner
eventlet.monkey_patch()
class ServiceA
name = "service_a"
@rpc
def x(self):
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"})
runner.add_service(ServiceA)
runner.add_service(ServiceB)
runner.start()
Im trying start service with nameko run --config test.yaml app
and got 4 connections from app.py
Connected to amqp://quest:**@192.168.1.42:5672//
Connected to amqp://quest:**@192.168.1.42:5672//
starting services: service_a, service_B
Connected to amqp://quest:**@192.168.1.42:5672//
Connected to amqp://quest:**@192.168.1.42:5672//
Ok, lets try reformat code. I remove serviceRunner
my srcond example code app.py
:
from nameko.rpc import rpc
class ServiceA
name = "service_a"
@rpc
def x(self):
return "A"
class ServiceB
name = "service_b"
@rpc
def x(self):
return "B"
And exec nameko run --config test.yaml app
again:
All okay, only two connections to RabbitMQ
starting services: service_a, service_B
Connected to amqp://quest:**@192.168.1.42:5672//
Connected to amqp://quest:**@192.168.1.42:5672//
Now the question. As far as I can see the ServiceA and SerivceB connects twice: from import and in serviceRunner
How to properly use the serviceRunner?
requirements.txt
amqp==2.4.0
certifi==2018.11.29
chardet==3.0.4
dnspython==1.16.0
eventlet==0.24.1
greenlet==0.4.15
idna==2.8
importlib-metadata==0.8
kombu==4.2.2.post1
limits==1.3
mock==2.0.0
monotonic==1.5
nameko==2.11.0
path.py==11.5.0
pbr==5.1.1
pika==0.13.0
PyYAML==3.13
requests==2.21.0
six==1.12.0
urllib3==1.24.1
vine==1.2.0
Werkzeug==0.14.1
wrapt==1.11.1
zipp==0.3.3