Skip to content

Microservice gateway env variable is required, but it could not be deployed #185

Open
@davidebianchi

Description

@davidebianchi
Member

Description

Here the MICROSERVICE_GATEWAY_SERVICE_NAME env variable is set as required, but the service could not exist.

The presence of this variable could bring to use the getServiceProxy function, which url is set to the microservice-gateway (which is unreachable).

An example usecase is a project which initially contains the microservice-gateway, and at a later time it will be removed. If a service called to the microservice-gateway, it throws with some error.

Proposed feature

My proposal is to set the MICROSERVICE_GATEWAY_SERVICE_NAME env variable as not required.
If it is set (and it is not empty), the getServiceProxy remains as today (so the microservice-gateway service is called).

If, on the other hand, the env variable is not set (or is empty) and the service calls the getServiceProxy method, the service will throw a clear error. In this way, it is possible to catch the issue with the explaination on how to fix it.
If possible, it would be great if throwed error could be raised on service startup.

Activity

fredmaggiowski

fredmaggiowski commented on Jan 27, 2022

@fredmaggiowski
Member

What about dismissing (after a deprecation period) getServiceProxy and getDirectServiceProxy altogether and moving to a single builder where you specify the url you whish to use? I feel like the use-case for the direct/msgw-proxy is a bit outdated as a need and we can move forward on a clearer API.

davidebianchi

davidebianchi commented on Jan 28, 2022

@davidebianchi
MemberAuthor

Interesting idea, it's quite a big breaking change but it could be handled in some way.

We could handle it in this way:

  • create a new getServiceClient method, which is quite similar to getDirectServiceProxy but it always require a correct url (not only a hostname)
  • deprecate the previous functions, and remove the required MICROSERVICE_GATEWAY_SERVICE_NAME env var
  • communicate a new breaking changes which removes the old functions, and after few month make the new breaking change version of the lib

We could also change the http client used under the hood with an http client more extensible, like axios or got

davidebianchi

davidebianchi commented on May 11, 2022

@davidebianchi
MemberAuthor

Implemented the http client method. At the next major (v6), we could remove the MICROSERVICE_GATEWAY_SERVICE_NAME env variables as, when removed the getServiceProxy, it will be unused

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @fredmaggiowski@davidebianchi

        Issue actions

          Microservice gateway env variable is required, but it could not be deployed · Issue #185 · mia-platform/custom-plugin-lib