All Downloads are FREE. Search and download functionalities are using the official Maven repository.

grpc.health.v1.HealthFs2Grpc.scala Maven / Gradle / Ivy

The newest version!
package grpc.health.v1

import _root_.cats.syntax.all._

trait HealthFs2Grpc[F[_], A] {
  def check(request: grpc.health.v1.HealthCheckRequest, ctx: A): F[grpc.health.v1.HealthCheckResponse]
  def watch(request: grpc.health.v1.HealthCheckRequest, ctx: A): _root_.fs2.Stream[F, grpc.health.v1.HealthCheckResponse]
}

object HealthFs2Grpc extends _root_.fs2.grpc.GeneratedCompanion[HealthFs2Grpc] {
  
  def mkClient[F[_]: _root_.cats.effect.Async, A](dispatcher: _root_.cats.effect.std.Dispatcher[F], channel: _root_.io.grpc.Channel, mkMetadata: A => F[_root_.io.grpc.Metadata], clientOptions: _root_.fs2.grpc.client.ClientOptions): HealthFs2Grpc[F, A] = new HealthFs2Grpc[F, A] {
    def check(request: grpc.health.v1.HealthCheckRequest, ctx: A): F[grpc.health.v1.HealthCheckResponse] = {
      mkMetadata(ctx).flatMap { m =>
        _root_.fs2.grpc.client.Fs2ClientCall[F](channel, grpc.health.v1.HealthGrpc.METHOD_CHECK, dispatcher, clientOptions).flatMap(_.unaryToUnaryCall(request, m))
      }
    }
    def watch(request: grpc.health.v1.HealthCheckRequest, ctx: A): _root_.fs2.Stream[F, grpc.health.v1.HealthCheckResponse] = {
      _root_.fs2.Stream.eval(mkMetadata(ctx)).flatMap { m =>
        _root_.fs2.Stream.eval(_root_.fs2.grpc.client.Fs2ClientCall[F](channel, grpc.health.v1.HealthGrpc.METHOD_WATCH, dispatcher, clientOptions)).flatMap(_.unaryToStreamingCall(request, m))
      }
    }
  }
  
  protected def serviceBinding[F[_]: _root_.cats.effect.Async, A](dispatcher: _root_.cats.effect.std.Dispatcher[F], serviceImpl: HealthFs2Grpc[F, A], mkCtx: _root_.io.grpc.Metadata => F[A], serverOptions: _root_.fs2.grpc.server.ServerOptions): _root_.io.grpc.ServerServiceDefinition = {
    _root_.io.grpc.ServerServiceDefinition
      .builder(grpc.health.v1.HealthGrpc.SERVICE)
      .addMethod(grpc.health.v1.HealthGrpc.METHOD_CHECK, _root_.fs2.grpc.server.Fs2ServerCallHandler[F](dispatcher, serverOptions).unaryToUnaryCall[grpc.health.v1.HealthCheckRequest, grpc.health.v1.HealthCheckResponse]((r, m) => mkCtx(m).flatMap(serviceImpl.check(r, _))))
      .addMethod(grpc.health.v1.HealthGrpc.METHOD_WATCH, _root_.fs2.grpc.server.Fs2ServerCallHandler[F](dispatcher, serverOptions).unaryToStreamingCall[grpc.health.v1.HealthCheckRequest, grpc.health.v1.HealthCheckResponse]((r, m) => _root_.fs2.Stream.eval(mkCtx(m)).flatMap(serviceImpl.watch(r, _))))
      .build()
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy