title: Implementing (Abstract) Nameko Service Inheritance
body: <p>I have a nameko service that deals with lots of entities, and having the entrypoints in a single <code>service.py</code> module would render the module highly unreadable and harder to maintain.</p>
  
  <p>So I've decided to split up the module in to multiple Services which are then used to extend the main service. I am kind of worried about dependency injection and thought a dependency like the db, might have multiple instances due to this approach. This is what I have so far:</p>
  
  <p>the customer service module with all customer-related endpoints</p>
  
  <pre><code># app/customer/service.py
  
  class HTTPCustomerService:
      """HTTP endpoints for customer module"""
  
      name = "http_customer_service"
      db = None
      context = None
      dispatch = None
  
      @http("GET,POST", "/customers")
      def customer_listing(self, request):
          session = self.db.get_session()
          return CustomerListController.as_view(session, request)
  
      @http("GET,PUT,DELETE", "/customers/&lt;uuid:pk&gt;")
      def customer_detail(self, request, pk):
          session = self.db.get_session()
          return CustomerDetailController.as_view(session, request, pk)
  </code></pre>
  
  <p>and main service module that inherits from customer service, and possibly other abstract services</p>
  
  <pre><code># app/service.py
  
  class HTTPSalesService(HTTPCustomerService):
      """Nameko http service."""
  
      name = "http_sales_service"
      db = Database(Base)
      context = ContextData()
      dispatch = EventDispatcher()
  
  </code></pre>
  
  <p>and finally I run it with:</p>
  
  <pre><code>nameko run app.service
  </code></pre>
  
  <p>So this works well, but is the approach right? Especially with regards to dependency injection?</p>