Shared RPC-mixins

Hello there! We're a bunch of microservices on top of nameko and are
interested in sharing the code-base across multiple instances. Currently we
have our own library to share the code but we've faced the difficulty in
creating the base class for all of our microservices. Let me explain, each
of our services has a well-defined interface (HTTP and RPC endpoints for
the documentation, health-checks, etc) and we're looking forward to for the
way to create some kind of the Abstract Base Class for all of our services,
which defines that interface. So what is the proper way to deal with it in
nameko if any? Thank you

class BaseService(object):
   @rpc
   def check_health(self, ...):
       ...

   @http('GET', '/api/health')
   def status(self, request):
       ....

class MyService(BaseService):
    # This does not work

Hi,

I would expect the above example to work. What happens? Do you have a more
complete example?

Best,
David

···

On Friday, 17 March 2017 13:04:36 UTC, trikst...@gmail.com wrote:

Hello there! We're a bunch of microservices on top of nameko and are
interested in sharing the code-base across multiple instances. Currently we
have our own library to share the code but we've faced the difficulty in
creating the base class for all of our microservices. Let me explain, each
of our services has a well-defined interface (HTTP and RPC endpoints for
the documentation, health-checks, etc) and we're looking forward to for the
way to create some kind of the Abstract Base Class for all of our services,
which defines that interface. So what is the proper way to deal with it in
nameko if any? Thank you

class BaseService(object):
   @rpc
   def check_health(self, ...):
       ...

   @http('GET', '/api/health')
   def status(self, request):
       ....

class MyService(BaseService):
    # This does not work

We use this base-class pattern st Student.com. I would also expect your
example to work, except that you haven't specified a name attribute on the
`MyService` class.

One note regarding names -- if you put a name attribute on the base class,
`nameko run` will discover both the base and the subclass and attempt to
run both unless you explicitly specify the service class (i.e. `nameko run
module:MyService`)

···

On Friday, March 17, 2017 at 5:34:04 PM UTC, David Szotten wrote:

Hi,

I would expect the above example to work. What happens? Do you have a more
complete example?

Best,
David

On Friday, 17 March 2017 13:04:36 UTC, trikst...@gmail.com wrote:

Hello there! We're a bunch of microservices on top of nameko and are
interested in sharing the code-base across multiple instances. Currently we
have our own library to share the code but we've faced the difficulty in
creating the base class for all of our microservices. Let me explain, each
of our services has a well-defined interface (HTTP and RPC endpoints for
the documentation, health-checks, etc) and we're looking forward to for the
way to create some kind of the Abstract Base Class for all of our services,
which defines that interface. So what is the proper way to deal with it in
nameko if any? Thank you

class BaseService(object):
   @rpc
   def check_health(self, ...):
       ...

   @http('GET', '/api/health')
   def status(self, request):
       ....

class MyService(BaseService):
    # This does not work

Thank you, specifying the name for the base class solved all the problems.

···

суббота, 18 марта 2017 г., 14:14:51 UTC+3 пользователь Matt Yule-Bennett написал:

We use this base-class pattern st Student.com. I would also expect your
example to work, except that you haven't specified a name attribute on the
`MyService` class.

One note regarding names -- if you put a name attribute on the base class,
`nameko run` will discover both the base and the subclass and attempt to
run both unless you explicitly specify the service class (i.e. `nameko run
module:MyService`)

On Friday, March 17, 2017 at 5:34:04 PM UTC, David Szotten wrote:

Hi,

I would expect the above example to work. What happens? Do you have a
more complete example?

Best,
David

On Friday, 17 March 2017 13:04:36 UTC, trikst...@gmail.com wrote:

Hello there! We're a bunch of microservices on top of nameko and are
interested in sharing the code-base across multiple instances. Currently we
have our own library to share the code but we've faced the difficulty in
creating the base class for all of our microservices. Let me explain, each
of our services has a well-defined interface (HTTP and RPC endpoints for
the documentation, health-checks, etc) and we're looking forward to for the
way to create some kind of the Abstract Base Class for all of our services,
which defines that interface. So what is the proper way to deal with it in
nameko if any? Thank you

class BaseService(object):
   @rpc
   def check_health(self, ...):
       ...

   @http('GET', '/api/health')
   def status(self, request):
       ....

class MyService(BaseService):
    # This does not work