dotnet / tye

Tye is a tool that makes developing, testing, and deploying microservices and distributed applications easier. Project Tye includes a local orchestrator to make developing microservices easier and the ability to deploy microservices to Kubernetes with minimal configuration.
MIT License
5.29k stars 520 forks source link

Service discovery for databases #476

Open tmds opened 4 years ago

tmds commented 4 years ago

Service discovery for databases doesn't include the type of database (e.g. mssql, PostgreSQL, ...)

Proposal

The service discovery for databases can also use the SERVICE__ prefix.

This means CONNECTIONSTRING__USERS becomes SERVICE__USERS__CONNECTIONSTRING.

The __PROTOCOL suffix can then be used to indicate the type of database: e.g.: SERVICE__USERS__PROTOCOL=postgresql.

An extension method can be added on IConfiguration to GetServiceProtocol.

cc @rynowak @jkotalik @davidfowl

jkotalik commented 4 years ago

What does your tye.yaml look like for this? I think adding that extension method makes sense, however I think we'll need to require people to specify the protocol rather than trying to infer it from the connection string, ex:

- name: postgres
  image: postgres
  bindings:
    - port: 5555
      connectionString: <connectionstring>
      protocol: postgres
glennc commented 4 years ago

The CONNECTIONSTRING__ convention predates Tye. I don't think we would want to remove that from the system as it fits nicely with how people do it today without them needing to change. Adding the others as well though is also possible.

Do you have some specific way of using this in mind?

tmds commented 4 years ago

I think we'll need to require people to specify the protocol rather than trying to infer it from the connection string

Agree. Infering is not needed. And protocol is not mandatory.

Do you have some specific way of using this in mind?

Pick the proper EF Core provider based on GetServiceProtocol(...).