小编Jer*_*y L的帖子

我们可以在Kotlin中使用中缀泛型方法吗?

编译器接受中缀+泛型方法,但使用它的语法是什么?例如,给出了两个相同的方法(模任意通用类型):

infix inline fun Int1.plus1(i: Int1) = Int1(this.value + i.value)
infix inline fun <U> Int1.plus2(i: Int1) = Int1(this.value + i.value)
Run Code Online (Sandbox Code Playgroud)

我可以写:

Int1(3).plus1(Int1(4))
Int1(3) plus1 Int1(4)
Int1(3).plus2<Int>(Int1(4))
Run Code Online (Sandbox Code Playgroud)

但这个电话无效:

Int1(3) plus2<Int> Int1(4)
Run Code Online (Sandbox Code Playgroud)

有人能解释我为什么吗?

generics infix-notation kotlin

6
推荐指数
1
解决办法
884
查看次数

自动重试请求的http代码是什么?

我正在使用混合 Spring-Cloud + feign + spring-retry 来帮助在客户端重试请求(都是基于 Kotlin 的后端)

我的 spring-boot conf 是这样的:

myApp:
  ribbon:
    OkToRetryOnAllOperations: true
    retryableStatusCodes: 404, 503
Run Code Online (Sandbox Code Playgroud)

(注意:OkToRetryOnAllOperations=true 仅用于重试 POST/PUT 请求)

重试 404 和 503 HTTP 代码听起来不错,但我不知道是否有要重试的“经典”或“默认”错误代码列表。这种好的做法存在吗?

我们假设所有请求在服务器端都是幂等的(如果不是,重试可能会导致问题)。

spring kotlin spring-retry spring-boot spring-cloud-feign

5
推荐指数
2
解决办法
4269
查看次数