Entrypoints in seperate file?

Is there a way to create a service and have the entry points declared in
separate files?

My reason is i'm making a service that will have around 30 entry points to
manage the data in it's database (getting, setting, updating, etc..). and i
want to group those entry points into different files just to be more
organised.

For example i would have 10 entry points in manipulating account data,
maybe 10 for users, maybe 2 for recording and getting actions users
performed on an account, etc...

I can imagine a way of doing this, maybe making sub classes with all these
split entry points and make the service class inherit all of these
different sub classes.

Is there a proper way to do this? (is really what i'm asking for)

Thank you!

Hi Kirk,

Yes this is possible. As nameko service is just a python class you can
split your entrypoints into separate ones and then combine them together
like this:

# service.py

from nameko.rpc import rpc

class Dogs:

    @rpc
    def pet_dogs(self):
        pass

class Cats:

    @rpc
    def pet_cats(self):
        pass

class MyService(Dogs, Cats):
    name = 'my-service'

When doing that remember that you should invoke the service by specifying
your main class like this:

nameko run --config config.yaml pets.service:MyService

Otherwise, if you just specify module, nameko will try to run all of your
classes as separate services and start complaining that some of them are
missing required name field.

Jakub

ยทยทยท

On Wednesday, April 18, 2018 at 5:04:27 AM UTC+1, Kirk D wrote:

Is there a way to create a service and have the entry points declared in
separate files?

My reason is i'm making a service that will have around 30 entry points to
manage the data in it's database (getting, setting, updating, etc..). and i
want to group those entry points into different files just to be more
organised.

For example i would have 10 entry points in manipulating account data,
maybe 10 for users, maybe 2 for recording and getting actions users
performed on an account, etc...

I can imagine a way of doing this, maybe making sub classes with all these
split entry points and make the service class inherit all of these
different sub classes.

Is there a proper way to do this? (is really what i'm asking for)

Thank you!