let
inline fun <T, R> T.let(block: (T) -> R): R = block(this)
run
inline fun <T, R> T.run(block: T.() -> R): R = block()
import io.github.resilience4j.bulkhead.Bulkhead | |
import okhttp3.Interceptor | |
import okhttp3.Response | |
class BulkheadInterceptor(private val bulkhead: Bulkhead) : Interceptor { | |
override fun intercept(chain: Interceptor.Chain): Response = | |
bulkhead.executeCallable { chain.proceed(chain.request()) } | |
} |
import org.springframework.restdocs.headers.HeaderDescriptor | |
import org.springframework.restdocs.headers.HeaderDocumentation | |
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation | |
import org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse | |
import org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint | |
import org.springframework.restdocs.payload.FieldDescriptor | |
import org.springframework.restdocs.payload.PayloadDocumentation | |
import org.springframework.restdocs.payload.SubsectionDescriptor | |
import org.springframework.restdocs.request.ParameterDescriptor | |
import org.springframework.restdocs.request.RequestDocumentation |
import com.google.gson.Gson | |
import com.google.gson.GsonBuilder | |
import io.jaegertracing.zipkin.internal.V2SpanConverter | |
import java.lang.reflect.Field | |
import java.lang.reflect.Modifier | |
import java.lang.invoke.MethodHandles | |
import java.lang.invoke.VarHandle | |
class FixZipkinV2Reporter(gson: Gson = PRIVACY_RESPECTING_GSON) { | |
init { |
import io.github.resilience4j.bulkhead.Bulkhead | |
import io.github.resilience4j.bulkhead.utils.BulkheadUtils | |
import io.grpc.CallOptions | |
import io.grpc.Channel | |
import io.grpc.ClientCall | |
import io.grpc.ClientInterceptor | |
import io.grpc.ClientInterceptors | |
import io.grpc.ForwardingClientCallListener | |
import io.grpc.Metadata | |
import io.grpc.MethodDescriptor |
import com.athaydes.rawhttp.core.EagerBodyReader; | |
import com.athaydes.rawhttp.core.EagerHttpResponse; | |
import com.athaydes.rawhttp.core.MethodLine; | |
import com.athaydes.rawhttp.core.RawHttp; | |
import com.athaydes.rawhttp.core.RawHttpHeaders; | |
import com.athaydes.rawhttp.core.RawHttpRequest; | |
import org.apache.thrift.transport.TTransport; | |
import org.apache.thrift.transport.TTransportException; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; |
interface CircuitBreakerMetrics { | |
fun executionCompleted(name: String, latency: Double) = Unit | |
} |
@Test | |
fun simple() { | |
val observable = Observable.create<Int> { emitter -> | |
emitter.onNext(1) | |
emitter.onError(IOException("Timeout")) | |
} | |
observable | |
.take(1) | |
.subscribe({ assertEquals(1, it) }, { assertTrue(it is UndeliverableException) }) | |
} |
override fun connectDevice(userDeviceRef: UserDeviceRef, deviceAttributes: DeviceAttributes, nodeRef: PilsnerRef): Completable | |
= Completable.fromRunnable { | |
rwLock.write { | |
devicePresences[userDeviceRef.deviceId] = Presence(userDeviceRef, deviceAttributes, nodeRef) | |
userDevices.put(userDeviceRef.userId, userDeviceRef.deviceId) | |
} | |
} | |
override fun getPresencesOfUser(userId: UserId): Single<List<Presence>> | |
= Single.fromCallable { |
class Http { | |
data class HeaderName(val name: String) : Comparable<HeaderName> { | |
override fun compareTo(other: HeaderName): Int = name.compareTo(other.name, true) | |
fun get(headers: MultiMap): String? = headers.get(name) | |
fun set(headers: MultiMap, value: String): Unit { headers.set(name, value) } | |
fun copyIfExist(from: MultiMap, to: MultiMap) { | |
get(from)?.let { set(to, it) } | |
} |
inline fun <T, R> T.let(block: (T) -> R): R = block(this)
inline fun <T, R> T.run(block: T.() -> R): R = block()