
io.p8e.grpc.Constant.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of p8e-common Show documentation
Show all versions of p8e-common Show documentation
A collection of services and libraries that iteract and run Provenance Java based contracts.
The newest version!
package io.p8e.grpc
import com.google.protobuf.Empty
import com.google.protobuf.Message
import io.grpc.Context
import io.grpc.Metadata
import io.grpc.stub.StreamObserver
import io.p8e.util.toJavaPublicKey
object Constant {
val JWT_ALGORITHM = "SHA256withECDSA"
val PUBLIC_KEY_CTX = Context.key("public-key")
val CLIENT_IP_CTX = Context.key("client-ip")
val JWT_METADATA_KEY = Metadata.Key.of("jwt", Metadata.ASCII_STRING_MARSHALLER)
val JWT_CTX_KEY = Context.key("jwt")
val MAX_MESSAGE_SIZE = 200 * 1024 * 1024
}
fun publicKey() = Constant.PUBLIC_KEY_CTX.get().toJavaPublicKey()
fun clientIp() = Constant.CLIENT_IP_CTX.get()
fun T.complete(observer: StreamObserver) {
observer.onNext(this)
observer.onCompleted()
}
fun StreamObserver.complete() {
onNext(Empty.getDefaultInstance())
onCompleted()
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy