vendredi 14 octobre 2022

SOLID IoC based on configuration in Spring Boot

I would like to have a collection of connections (REST, gRPC, RabbitMQ) for one or more different types of services. For example, with this configuration:

connections:
  http:
    - name: connectionA
      host: localhost
      port: 8081
      endpoints:
        - name: employees
          httpMethod: GET
          endpointType: EMPLOYEE
        - name: departments
          httpMethod: POST
          endpointType: DEPARTMENT
  grpc:
    - name: connectionB
      host: localhost
      port: 8084
      disableTls: true
      endpoints:
        - name: employees
          endpointType: EMPLOYEE

When using the EmployeeService I would have an EmployeeHttpClient and an EmployeeGrpcClient, as well as a DepartmentHttpClient in the DepartmentService. Those clients would have the concrete implementation using the specific connection details, but the service shouldn't care about that.

What do you think about this approach?

What would be the correct way of doing it in Spring Boot?

Aucun commentaire:

Enregistrer un commentaire