Quarkus rest client:如何在YAML配置中合并级别的rest client配置

huangapple go评论56阅读模式
英文:

Quarkus rest client: how to combine leveled rest client config in YAML config

问题

quarkus:
  rest-client:
    my-api:
      url: ${api.url}
      scope: javax.inject.Singleton
      connection-pool-size: 20
      mp-rest/readTimeout: 5000
      mp-rest/connectTimeout: 5000
英文:

I am using Quarkus rest client and I already have congis in YAML like:

quarkus:
  rest-client:
    my-api:
      url: ${api.url}
      scope: javax.inject.Singleton
      connection-pool-size: 20

Now I want to add mp-rest/readTimeout and mp-rest/connectTimeout as per https://stackoverflow.com/questions/63795633/how-to-configure-rest-client-in-quarkus-microprofile-case

How should I put them? Should camel case be converted to hyphen cased?

Like this?

quarkus:
  rest-client:
    my-api:
      url: ${api.url}
      scope: javax.inject.Singleton
      connection-pool-size: 20
      mp-rest/readTimeout: 5000
      mp-rest/connectTimeout: 5000

or:

quarkus:
  rest-client:
    my-api:
      url: ${api.url}
      scope: javax.inject.Singleton
      connection-pool-size: 20
      mp-rest: 
        read-timeout: 5000
        connect-timeout: 5000

BTW why YAML format is not mentioned in doc? I don't know other people but I always prefer YAML and I don't like the doc only preferring .properties format, also I was searching in the Github repo but found no example in YAML. The conversion from properties format to YAML, in many cases, is not trivial.

For me, what is ideal is:

  • when writing tests, externalizing 2 formats of config files and write 2 set of tests
  • providing examples in 2 formats like what Maven repository did:
    Quarkus rest client:如何在YAML配置中合并级别的rest client配置

答案1

得分: 1

你根本不需要使用 /mp-rest

你可以直接使用:

quarkus:
  rest-client:
    my-api:
      url: ${api.url}
      scope: javax.inject.Singleton
      connection-pool-size: 20
      read-timeout: 5000
      connect-timeout: 5000

更多细节请参考 此链接

英文:

You don't need to use the /mp-rest at all.

You can just use:

quarkus:
  rest-client:
    my-api:
      url: ${api.url}
      scope: javax.inject.Singleton
      connection-pool-size: 20
      read-timeout: 5000
      connect-timeout: 5000

See this for more details

huangapple
  • 本文由 发表于 2023年4月19日 22:54:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/76055963.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定