Skip to content

Installation

Install with pip

$ pip install nameko

Pre-release versions are also published to PyPI. Get them with:

$ pip install --pre nameko

Create your first service

A nameko service is just a class:

from nameko.rpc import rpc

class GreetingService:
    name = "greeting_service"

    @rpc
    def hello(self, name):
        return u"Hello, {}!".format(name)

This service is using the built-in @rpc entrypoint, which is an RPC implementation that sends messages via a RabbitMQ broker.

You can run it using the CLI:

$ nameko run helloworld
starting services: greeting_service
...

And call it using the convenience shell command:

$ nameko shell
>>> n.rpc.greeting_service.hello(name="ナメコ")
'Hello, ナメコ!'

Info

This example needs a RabbitMQ broker. The RabbitMQ installation guidelines offer several installation options, but you can quickly start one using Docker:

$ docker run -d -p 5672:5672 rabbitmq:3