# Entrypoints in seperate file?

**URL:** <https://discourse.nameko.io/t/entrypoints-in-seperate-file/252>\
**Category:** googlegroup\
**Created:** [April 18, 2018, 4:04am UTC](https://discourse.nameko.io/t/entrypoints-in-seperate-file/252 "2018-04-18T04:04:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kirkodouglasjr](https://avatars.discourse-cdn.com/v4/letter/k/65b543/32.png) [@Kirkodouglasjr](https://discourse.nameko.io/u/Kirkodouglasjr)\
**Post date:** [April 18, 2018, 4:04am UTC](https://discourse.nameko.io/t/entrypoints-in-seperate-file/252/1 "2018-04-18T04:04:27Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Jakub\_Borys](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.nameko.io/jakub_borys/32/7_2.png) [@Jakub\_Borys](https://discourse.nameko.io/u/Jakub_Borys)\
**Post date:** [April 18, 2018, 5:57am UTC](https://discourse.nameko.io/t/entrypoints-in-seperate-file/252/2 "2018-04-18T05:57:26Z")

</div>

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:

&nbsp;&nbsp;&nbsp;&nbsp;@rpc  
&nbsp;&nbsp;&nbsp;&nbsp;def pet\_dogs(self):  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pass

class Cats:

&nbsp;&nbsp;&nbsp;&nbsp;@rpc  
&nbsp;&nbsp;&nbsp;&nbsp;def pet\_cats(self):  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pass

class MyService(Dogs, Cats):  
&nbsp;&nbsp;&nbsp;&nbsp;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!
