1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Is there a low-maintenance way to implement microservice chassis pattern in Python?

Discussão em 'Python' iniciado por Stack, Setembro 16, 2024.

  1. Stack

    Stack Membro Participativo

    Context: I'm developing my first microservice project, and still trying to wrap my head around some best practices.

    The project structure is not that complicated:

    DaProject/
    +- ServiceA/
    | +- main.py
    | \- Dockerfile
    +- ServiceB/
    | +- some_ServiceB_specific_lib/
    | +- main.py
    | \- Dockerfile
    \- docker-compose.yml


    Now, as I played around with implementing a couple of services, I've figured out some of the cross-cutting concerns for my project. Since all services will be implemented in Python, I want to take care of those concerns using Service Chassis pattern. The question is, is there a simple, but decent way to do that? For example, if I do this:

    DaProject/
    +- Chassis/
    | \- __init__.py
    +- ServiceA/
    | +- main.py
    | \- Dockerfile
    +- ServiceB/
    | +- some_ServiceB_specific_lib/
    | +- main.py
    | \- Dockerfile
    \- docker-compose.yml


    then I will need to reference the Chassis package from within the services.

    What I have thought about:

    1. I can't just reference ../Chassis in any Dockerfile, as it is outside of the build scope. Okay, that makes sense.
    2. I don't want to manually copy the chassis into each service directory whenever I happen to update it. It's a very simple solution, but high-maintenance and error-prone.
    3. Hardlinking the directory is a hack, and will likely break if the code is moved somewhere else.
    4. Implementing a local pypi repo sounds like a high-maintenance way to handle it. Perhaps it would be more worth it I was implementing a more abstract and reusable library, not something as project-bound as this.
    5. Googling pointed me towards 'git submodule' concept... but I have only basic familiarity with Git, and so I can't really judge how complex this solution is.

    Is there any other way I'm not aware of? Or should I bite the bullet and learn the submodule feature?

    Continue reading...

Compartilhe esta Página