Skip to Content
Mastering Python Design Patterns - Second Edition
book

Mastering Python Design Patterns - Second Edition

by Kamon Ayeva, Sakis Kasampalis
August 2018
Intermediate to advanced
248 pages
5h 51m
English
Packt Publishing
Content preview from Mastering Python Design Patterns - Second Edition

A first example

For our first example, you also need to install the Faker module, if it was not yet done, using the pip install faker command.

Then, we will use a file called service_first.py to contain all our code. We will see in a moment how it is going to be used.

Since the service will be called using the RPC protocol, we import the rpc function that will be used as a decorator to add this capability to the service definition. We also import the Faker class.

Our current service module file starts with these imports:

from nameko.rpc import rpcfrom faker import Faker

In Nameko, a service is a simple class with methods decorated with @rpc for the jobs the service offer. So, our PeopleListService class would look like this (well, just the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Python Design Patterns - Second Edition - Second Edition

Learning Python Design Patterns - Second Edition - Second Edition

Chetan Giridhar, Gennadiy Zlobin

Publisher Resources

ISBN: 9781788837484Supplemental Content