### Navigate to example directory Source: https://scalapb.github.io/zio-grpc/docs/basics Change the working directory to the routeguide example folder. ```bash $ cd zio-grpc/examples/routeguide ``` -------------------------------- ### Clone and navigate to example repository Source: https://scalapb.github.io/zio-grpc/docs/quickstart Commands to download the repository and enter the helloworld example directory. ```bash git clone https://github.com/scalapb/zio-grpc ``` ```bash cd zio-grpc/examples/helloworld ``` -------------------------------- ### Mixin Service Example Source: https://scalapb.github.io/api/com/google/protobuf/api/index.html Example showing how to define services for mixin usage in protocol buffer files. ```protobuf package google.acl.v1; service AccessControl { // Get the underlying ACL object. rpc GetAcl(GetAclRequest) returns (Acl) { option (google.api.http).get = "/v1/{resource=**}:getAcl"; } } package google.storage.v2; service Storage { rpc GetAcl(GetAclRequest) returns (Acl); // Get a data record. rpc GetData(GetDataRequest) returns (Data) { option (google.api.http).get = "/v2/{resource=**}"; } } ``` -------------------------------- ### Clone ScalaPB Example Repository Source: https://scalapb.github.io/docs/getting-started Commands to retrieve the example code from the ScalaPB GitHub repository. ```bash git clone https://github.com/scalapb/ScalaPB.git cd examples/basic ``` -------------------------------- ### Mixin Configuration Example Source: https://scalapb.github.io/api/com/google/protobuf/api/index.html Example configuration for applying a mixin to an API service. ```yaml apis: * name: google.storage.v2.Storage mixins: * name: google.acl.v1.AccessControl ``` -------------------------------- ### Clone ZIO gRPC repository Source: https://scalapb.github.io/zio-grpc/docs/basics Download the example project by cloning the specific release branch. ```bash $ git clone -b v0.6.0-rc6 https://github.com/scalapb/zio-grpc.git ``` -------------------------------- ### Pack and unpack a message in Go Source: https://scalapb.github.io/api/com/google/protobuf/any/index.html Example demonstrating how to pack and unpack a message using the Any type in Go. ```go foo := &pb.Foo{...} any, err := ptypes.MarshalAny(foo) ... foo := &pb.Foo{} if err := ptypes.UnmarshalAny(any, foo); err != nil { ... } ``` -------------------------------- ### Field Mask Path Examples Source: https://scalapb.github.io/api/com/google/protobuf/field_mask/index.html Example of defining symbolic field paths for a nested message structure. ```protobuf paths: "f.a" paths: "f.b.d" ``` -------------------------------- ### JSON Representation of Any Source: https://scalapb.github.io/api/com/google/protobuf/any/index.html Examples showing how Any messages are represented in JSON format. ```json { "@type": "type.googleapis.com/google.profile.Person", "firstName": , "lastName": } ``` ```json { "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } ``` -------------------------------- ### Pack and unpack a message in Java Source: https://scalapb.github.io/api/com/google/protobuf/any/index.html Example demonstrating how to pack and unpack a message using the Any type in Java. ```java Foo foo = ...; Any any = Any.pack(foo); ... if (any.is(Foo.class)) { foo = any.unpack(Foo.class); } ``` -------------------------------- ### Pack and unpack a message in Python Source: https://scalapb.github.io/api/com/google/protobuf/any/index.html Example demonstrating how to pack and unpack a message using the Any type in Python. ```python foo = Foo(...) any = Any() any.Pack(foo) ... if any.Is(Foo.DESCRIPTOR): any.Unpack(foo) ... ``` -------------------------------- ### Pack and unpack a message in C++ Source: https://scalapb.github.io/api/com/google/protobuf/any/index.html Example demonstrating how to pack and unpack a message using the Any type in C++. ```cpp Foo foo = ...; Any any; any.PackFrom(foo); ... if (any.UnpackTo(&foo)) { ... } ``` -------------------------------- ### Define Custom Options Source: https://scalapb.github.io/docs/transformations Example definition of a custom protobuf option using a message structure. ```protobuf // opts.proto syntax = "proto2"; package mypkg; import "google/protobuf/descriptor.proto"; extend google.protobuf.FieldOptions { optional MyCustomOptions opts = 50001; } message MyCustomOptions { optional bool sensitive = 1; optional int32 num = 2; } ``` -------------------------------- ### Install Rosetta on Apple M1 Source: https://scalapb.github.io/docs/faq If you are encountering 'Bad CPU type' errors on an Apple M1, ensure Rosetta is installed. This command installs Rosetta. ```bash softwareupdate --install-rosetta ``` -------------------------------- ### Configure Server with Dependency Layers Source: https://scalapb.github.io/zio-grpc/docs/context Demonstrates how to assemble the application layer using ZLayer.make and launch the gRPC server. ```scala object MyServer3 extends zio.ZIOAppDefault { val serverLayer = ServerLayer.fromServiceList( io.grpc.ServerBuilder.forPort(9000), ServiceList.addFromEnvironment[ZSimpleService[RequestContext]] ) val appLayer = ZLayer.make[Server]( serverLayer, DepA.layer, DepB.layer, MyService2.layer ) def run = ourApp.launch.exitCode } ``` -------------------------------- ### Duration Examples Source: https://scalapb.github.io/api/com/google/protobuf/duration/Duration.html Provides examples of computing Duration from Timestamps and Python's datetime.timedelta. ```APIDOC # Examples Example 1: Compute Duration from two Timestamps in pseudo code. Timestamp start = ...; Timestamp end = ...; Duration duration = ...; duration.seconds = end.seconds - start.seconds; duration.nanos = end.nanos - start.nanos; if (duration.seconds < 0 && duration.nanos > 0) { duration.seconds += 1; duration.nanos -= 1000000000; } else if (duration.seconds > 0 && duration.nanos < 0) { duration.seconds -= 1; duration.nanos += 1000000000; } Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. Timestamp start = ...; Duration duration = ...; Timestamp end = ...; end.seconds = start.seconds + duration.seconds; end.nanos = start.nanos + duration.nanos; if (end.nanos < 0) { end.seconds -= 1; end.nanos += 1000000000; } else if (end.nanos >= 1000000000) { end.seconds += 1; end.nanos -= 1000000000; } Example 3: Compute Duration from datetime.timedelta in Python. td = datetime.timedelta(days=3, minutes=10) duration = Duration() duration.FromTimedelta(td) ``` -------------------------------- ### Lens: Get Field Value Source: https://scalapb.github.io/api/com/google/protobuf/descriptor/FieldDescriptorProto%24%24FieldDescriptorProtoLens.html Gets knows how to extract some field of type `A` from a container. ```scala def get(u: UpperPB): FieldDescriptorProto ``` -------------------------------- ### Define RouteGuide Service Source: https://scalapb.github.io/zio-grpc/docs/basics Initializes the service definition block. ```protobuf service RouteGuide { ... } ``` -------------------------------- ### Start a gRPC server with ServerMain Source: https://scalapb.github.io/zio-grpc/docs/basics Implement a gRPC server by extending ServerMain and defining the service list and port. ```scala object RouteGuideServer extends ServerMain { override def port: Int = 8980 val featuresDatabase = JsonFormat.fromJsonString[FeatureDatabase]( Source.fromResource("route_guide_db.json").mkString ) val createRouteGuide = for { routeNotes <- Ref.make(Map.empty[Point, List[RouteNote]]) } yield new RouteGuideService(featuresDatabase.feature, routeNotes) def services: ServiceList[Any] = ServiceList.addZIO(createRouteGuide) } ``` -------------------------------- ### Simple Mixin Example Source: https://scalapb.github.io/api/com/google/protobuf/api/Mixin.html Demonstrates a basic mixin where one service includes another, showing how HTTP annotations are inherited. The version in the path pattern is updated. ```proto package google.acl.v1; service AccessControl { // Get the underlying ACL object. rpc GetAcl(GetAclRequest) returns (Acl) { option (google.api.http).get = "/v1/{resource=**}:getAcl"; } } package google.storage.v2; service Storage { rpc GetAcl(GetAclRequest) returns (Acl); // Get a data record. rpc GetData(GetDataRequest) returns (Data) { option (google.api.http).get = "/v2/{resource=**}"; } } ``` -------------------------------- ### Getting a Field Value with Lens in ScalaPB Source: https://scalapb.github.io/api/com/google/protobuf/descriptor/GeneratedCodeInfo%24%24GeneratedCodeInfoLens.html Extracts a field of type `A` from a container using a lens. This is the fundamental 'get' operation for lenses. ```scala def get(u: UpperPB): GeneratedCodeInfo ``` -------------------------------- ### Get Field Value Source: https://scalapb.github.io/api/com/google/protobuf/descriptor/GeneratedCodeInfo%24%24Annotation%24%24AnnotationLens.html The 'get' method extracts a specific field of type 'A' from a container. Ensure the provided container type matches the expected 'UpperPB'. ```scala def get(u: UpperPB): Annotation ``` -------------------------------- ### Mixin Configuration Example Source: https://scalapb.github.io/api/com/google/protobuf/api/Mixin.html Shows how to configure a mixin in a .proto file, specifying the API name and the mixin's name. This implies that all methods from the mixed-in service are also declared in the including service. ```yaml apis: - name: google.storage.v2.Storage mixins: - name: google.acl.v1.AccessControl ``` -------------------------------- ### Get Field Value Source: https://scalapb.github.io/api/com/google/protobuf/descriptor/FieldOptions%24%24FieldOptionsLens.html The `get` method extracts a specific field's value from a container object. It's a fundamental operation for reading data from Protocol Buffers. ```scala def get(u: UpperPB): FieldOptions ``` -------------------------------- ### Using Refined Types with Field Transformations Source: https://scalapb.github.io/docs/validation Example of using field transformations to integrate with refined types. This example transforms an int32 field with a 'greater than' rule into a Refined type. ```protobuf syntax = "proto3"; package refined_test; import "validate/validate.proto"; import "scalapb/validate.proto"; import "scalapb/scalapb.proto"; option (scalapb.options) = { preprocessors : [ "scalapb-validate-preprocessor" ] import : "eu.timepit.refined.api.Refined" import : "eu.timepit.refined.numeric._" import : "eu.timepit.refined.generic._" import : "shapeless.{Witness => W}" field_transformations : [ { when : {options: {[validate.rules] {int32 : {gt : 1}}}} set : {type : "Int Refined Greater[$(options.[validate.rules].int32.gt)]"} match_type : PRESENCE } ] }; message Test { int32 gt_test = 1 [ (validate.rules).int32 = {gt : 5} ]; // transformed to: Int Refined Greater[5] } ``` -------------------------------- ### SBT Subprojects Example Source: https://scalapb.github.io/docs/writing-plugins After creating a project, running `sbt projects` in the sbt shell lists all the subprojects. These typically include variations for different JVM versions and platform-specific plugin artifacts. ```text [info] In file:/tmp/my-cool-plugin/ [info] codeGenJVM2_12 [info] codeGenJVM2_13 [info] coreJVM2_12 [info] coreJVM2_13 [info] e2eJVM2_12 [info] e2eJVM2_13 [info] protoc-gen-my-cool-plugin [info] protoc-gen-my-cool-plugin-unix [info] protoc-gen-my-cool-plugin-windows [info] * root ``` -------------------------------- ### GET /getTagWireType Source: https://scalapb.github.io/api/scalapb/WireType%24.html Retrieves the wire type from a given tag. ```APIDOC ## GET /getTagWireType ### Description Extracts the wire type from a protobuf tag. ### Method GET ### Parameters #### Query Parameters - **tag** (Int) - Required - The tag value to process. ### Response #### Success Response (200) - **wireType** (Int) - The extracted wire type. ``` -------------------------------- ### Run server and client Source: https://scalapb.github.io/zio-grpc/docs/quickstart Commands to execute the server and client applications using sbt. ```bash sbt "runMain zio_grpc.examples.helloworld.HelloWorldServer" ``` ```bash sbt "runMain zio_grpc.examples.helloworld.HelloWorldClient" ``` -------------------------------- ### GET /getTagFieldNumber Source: https://scalapb.github.io/api/scalapb/WireType%24.html Retrieves the field number from a given tag. ```APIDOC ## GET /getTagFieldNumber ### Description Extracts the field number from a protobuf tag. ### Method GET ### Parameters #### Query Parameters - **tag** (Int) - Required - The tag value to process. ### Response #### Success Response (200) - **fieldNumber** (Int) - The extracted field number. ``` -------------------------------- ### Extract field with get Source: https://scalapb.github.io/api/com/google/protobuf/descriptor/EnumValueOptions%24%24EnumValueOptionsLens.html Extracts a field of type A from the container. ```scala def get(u: UpperPB): EnumValueOptions ``` -------------------------------- ### Define gRPC service in proto file Source: https://scalapb.github.io/zio-grpc/docs/quickstart Protocol buffer definitions for the Greeter service, showing the initial state and the updated state with SayHelloAgain. ```protobuf // The greeting service definition. service Greeter { // Sends a greeting rpc SayHello (HelloRequest) returns (HelloReply) {} } // The request message containing the user's name. message HelloRequest { string name = 1; } // The response message containing the greetings message HelloReply { string message = 1; } ``` ```protobuf // The greeting service definition. service Greeter { // Sends a greeting rpc SayHello (HelloRequest) returns (HelloReply) {} // Sends another greeting rpc SayHelloAgain (HelloRequest) returns (HelloReply) {} } // The request message containing the user's name. message HelloRequest { string name = 1; } // The response message containing the greetings message HelloReply { string message = 1; } ``` -------------------------------- ### GET /descriptor/service Source: https://scalapb.github.io/api/scalapb/grpc/ConcreteProtoMethodDescriptorSupplier.html Retrieves the service descriptor associated with the current supplier. ```APIDOC ## GET /descriptor/service ### Description Retrieves the ServiceDescriptor for the current proto service. ### Method GET ### Response #### Success Response (200) - **ServiceDescriptor** (Object) - The service descriptor object. ``` -------------------------------- ### Initialize SourceCodeInfo Source: https://scalapb.github.io/api/com/google/protobuf/descriptor/SourceCodeInfo.html Constructor for creating a new SourceCodeInfo instance with optional location sequences and unknown fields. ```scala new SourceCodeInfo(location: Seq[Location] = _root_.scala.Seq.empty, unknownFields: scalapb.UnknownFieldSet = ...) ``` -------------------------------- ### GET /descriptor/method Source: https://scalapb.github.io/api/scalapb/grpc/ConcreteProtoMethodDescriptorSupplier.html Retrieves the method descriptor associated with the current supplier. ```APIDOC ## GET /descriptor/method ### Description Retrieves the MethodDescriptor for the current proto method. ### Method GET ### Response #### Success Response (200) - **MethodDescriptor** (Object) - The method descriptor object. ``` -------------------------------- ### GET /descriptor/file Source: https://scalapb.github.io/api/scalapb/grpc/ConcreteProtoMethodDescriptorSupplier.html Retrieves the file descriptor associated with the current supplier. ```APIDOC ## GET /descriptor/file ### Description Retrieves the FileDescriptor for the current proto definition. ### Method GET ### Response #### Success Response (200) - **FileDescriptor** (Object) - The file descriptor object. ``` -------------------------------- ### FileDescriptorProto Builder Source: https://scalapb.github.io/api/scalapb/descriptors/FileDescriptor%24.html This section details the `buildFrom` method used for constructing a FileDescriptor from a FileDescriptorProto and a sequence of dependencies. ```APIDOC ## POST /buildFrom ### Description Constructs a `FileDescriptor` from a `FileDescriptorProto` and a sequence of `FileDescriptor` dependencies. ### Method POST ### Endpoint /buildFrom ### Parameters #### Request Body - **proto** (FileDescriptorProto) - Required - The FileDescriptorProto to build from. - **dependencies** (Seq[FileDescriptor]) - Required - A sequence of FileDescriptor dependencies. ``` -------------------------------- ### GET /getFileDescriptor Source: https://scalapb.github.io/api/scalapb/grpc/ConcreteProtoFileDescriptorSupplier.html Retrieves the file descriptor associated with the current object. ```APIDOC ## GET /getFileDescriptor ### Description Retrieves the FileDescriptor for the current ProtoFileDescriptorSupplier instance. ### Method GET ### Endpoint /getFileDescriptor ### Response #### Success Response (200) - **FileDescriptor** (Object) - The file descriptor object associated with the proto definition. ``` -------------------------------- ### Run gRPC server and client Source: https://scalapb.github.io/zio-grpc/docs/basics Commands to execute the server and client applications via sbt. ```bash sbt "runMain zio_grpc.examples.routeguide.RouteGuideServer" ``` ```bash sbt "runMain zio_grpc.examples.routeguide.RouteGuideClientApp" ``` -------------------------------- ### Configure ScalaPB File-level Options Source: https://scalapb.github.io/docs/customizations Define file-level settings for ScalaPB by importing the options proto and setting the scalapb.options message. ```protobuf import "scalapb/scalapb.proto"; option (scalapb.options) = { scope: FILE package_name: "com.example.myprotos" flat_package: true single_file: true java_conversions: false import: "com.thesamet.pb.MyType" import: "com.thesamet.other._" preamble: "sealed trait BaseMessage" preamble: "sealed trait CommonMessage" lenses: true getters: true retain_source_code_info: false no_default_values_in_constructor: false preserve_unknown_fields: false enum_value_naming: CAMEL_CASE enum_strip_prefix: false bytes_type: "scodec.bits.ByteVector" scala3_sources: false public_constructor_parameters: false }; ``` -------------------------------- ### Extract field value with get Source: https://scalapb.github.io/api/com/google/protobuf/api/Api%24%24ApiLens.html Extracts a field of type A from the container. ```scala def get(u: UpperPB): Api ``` -------------------------------- ### GET /descriptor/metadata Source: https://scalapb.github.io/api/scalapb/descriptors/SourceCodePath%24.html Retrieves metadata sequences for various Protobuf descriptor types. ```APIDOC ## GET /descriptor/metadata ### Description Retrieves a sequence of integers associated with a specific Protobuf descriptor. ### Parameters #### Request Body - **fd** (Descriptor/FieldDescriptor/ServiceDescriptor/MethodDescriptor/EnumDescriptor/EnumValueDescriptor) - Required - The descriptor object to query. ### Response #### Success Response (200) - **result** (Seq[Int]) - The sequence of integers associated with the provided descriptor. ``` -------------------------------- ### Create Protoc Plugin Project with SBT Source: https://scalapb.github.io/docs/writing-plugins Use the sbt new command with the scalapb/protoc-gen-template.g8 template to scaffold a new Protoc plugin project in Scala. This sets up a streamlined development environment. ```bash sbt new scalapb/protoc-gen-template.g8 ``` -------------------------------- ### Class Information Source: https://scalapb.github.io/api/scalapb/descriptors/PackageDescriptor.html Provides methods to get information about the runtime class of an object. ```APIDOC ## Class Information ### Description Provides methods to retrieve information about the runtime class of an object. ### Methods - **getClass(): Class[_]** Returns the runtime class of this object. ### Definition Classes - AnyRef → Any ### Annotations - @native() ``` -------------------------------- ### Generate a minimal ScalaPB project Source: https://scalapb.github.io/docs/contact Use this command to create a new sbt project based on the ScalaPB template for reproducing issues. ```bash sbt new scalapb/scalapb-template.g8 ``` -------------------------------- ### Instantiate a gRPC client layer Source: https://scalapb.github.io/zio-grpc/docs/basics Create a ZLayer to provide a RouteGuideClient using a managed channel. ```scala val clientLayer: Layer[Throwable, RouteGuideClient] = RouteGuideClient.live( ZManagedChannel( ManagedChannelBuilder.forAddress("localhost", 8980).usePlaintext() ) ) ``` -------------------------------- ### Get Field Value Source: https://scalapb.github.io/api/com/google/protobuf/descriptor/SourceCodeInfo%24%24Location%24%24LocationLens.html This method extracts a specific field of type `A` from a container. ```scala def get(u: UpperPB): Location ``` -------------------------------- ### Provide client layer to application logic Source: https://scalapb.github.io/zio-grpc/docs/basics Shows how to inject the RouteGuideClient layer into the application logic using provideLayer. ```scala val myAppLogic = for { // Looking for a valid feature _ <- getFeature(409146138, -746188906) // Looking for a missing feature _ <- getFeature(0, 0) // Calls listFeatures with a rectangle of interest. Prints // each response feature as it arrives. // start: listFeatures _ <- RouteGuideClient .listFeatures( Rectangle( lo = Some(Point(400000000, -750000000)), hi = Some(Point(420000000, -730000000)) ) ) .zipWithIndex .foreach { case (feature, index) => printLine(s"Result #${index + 1}: $feature") } // end: listFeatures _ <- recordRoute(10) _ <- routeChat } yield () final def run = myAppLogic.provideLayer(clientLayer).exitCode ``` -------------------------------- ### FileOptions Getters Source: https://scalapb.github.io/api/com/google/protobuf/descriptor/FileOptions.html Provides methods to get the value of specific file options. ```APIDOC ## FileOptions Getters ### Description Methods to retrieve the concrete values of file options. ### Methods - **getCcEnableArenas** - Description: Gets the value of `ccEnableArenas`. - Returns: `Boolean` - **getCcGenericServices** - Description: Gets the value of `ccGenericServices`. - Returns: `Boolean` - **getCsharpNamespace** - Description: Gets the value of `csharpNamespace`. - Returns: `String` - **getDeprecated** - Description: Gets the value of `deprecated`. - Returns: `Boolean` - **getGoPackage** - Description: Gets the value of `goPackage`. - Returns: `String` - **getJavaGenerateEqualsAndHash** - Description: Gets the value of `javaGenerateEqualsAndHash`. - Returns: `Boolean` - **getJavaGenericServices** - Description: Gets the value of `javaGenericServices`. - Returns: `Boolean` - **getJavaMultipleFiles** - Description: Gets the value of `javaMultipleFiles`. - Returns: `Boolean` - **getJavaOuterClassname** - Description: Gets the value of `javaOuterClassname`. - Returns: `String` - **getJavaPackage** - Description: Gets the value of `javaPackage`. - Returns: `String` - **getJavaStringCheckUtf8** - Description: Gets the value of `javaStringCheckUtf8`. - Returns: `Boolean` - **getObjcClassPrefix** - Description: Gets the value of `objcClassPrefix`. - Returns: `String` - **getOptimizeFor** - Description: Gets the value of `optimizeFor`. - Returns: `OptimizeMode` - **getPhpClassPrefix** - Description: Gets the value of `phpClassPrefix`. - Returns: `String` - **getPhpGenericServices** - Description: Gets the value of `phpGenericServices`. - Returns: `Boolean` - **getPhpMetadataNamespace** - Description: Gets the value of `phpMetadataNamespace`. - Returns: `String` - **getPhpNamespace** - Description: Gets the value of `phpNamespace`. - Returns: `String` - **getPyGenericServices** - Description: Gets the value of `pyGenericServices`. - Returns: `Boolean` - **getRubyPackage** - Description: Gets the value of `rubyPackage`. - Returns: `String` - **getSwiftPrefix** - Description: Gets the value of `swiftPrefix`. - Returns: `String` ``` -------------------------------- ### Running a ZIO gRPC Server Source: https://scalapb.github.io/zio-grpc/docs/generated-code The simplest way to run a ZIO gRPC service is by extending the `scalapb.zio_grpc.ServerMain` class and defining the services to be included. ```APIDOC ## Running the server The easiest way to run a service is to create an object that extends `scalapb.zio_grpc.ServerMain`: ```scala import scalapb.zio_grpc.{ServerMain, ServiceList} object MyMain extends ServerMain { def services = ServiceList.add(ServiceNameImpl) // Default port is 9000 override def port: Int = 8980 } ``` You can override `def port: Int` to set a specific port number. `ServiceList` offers additional methods for adding services. ``` -------------------------------- ### GET /IdempotencyLevel/fromName Source: https://scalapb.github.io/api/com/google/protobuf/descriptor/MethodOptions%24%24IdempotencyLevel%24.html Retrieves an IdempotencyLevel instance based on the provided name string. ```APIDOC ## GET /IdempotencyLevel/fromName ### Description Retrieves an IdempotencyLevel enum value by its name. ### Parameters #### Query Parameters - **name** (String) - Required - The name of the idempotency level to retrieve. ### Response #### Success Response (200) - **result** (Option[IdempotencyLevel]) - The matching IdempotencyLevel if found, otherwise None. ``` -------------------------------- ### GET /OptimizeMode/fromName Source: https://scalapb.github.io/api/com/google/protobuf/descriptor/FileOptions%24%24OptimizeMode%24.html Retrieves an OptimizeMode instance based on the provided name string. ```APIDOC ## GET /OptimizeMode/fromName ### Description Retrieves an OptimizeMode instance by its name. ### Method GET ### Endpoint /OptimizeMode/fromName ### Parameters #### Query Parameters - **name** (String) - Required - The name of the OptimizeMode to retrieve. ### Response #### Success Response (200) - **result** (scala.Option[OptimizeMode]) - The matching OptimizeMode instance if found, otherwise None. ``` -------------------------------- ### Implement SayHelloAgain in server Source: https://scalapb.github.io/zio-grpc/docs/quickstart Implementation of the new RPC method in the server classes. ```scala def sayHelloAgain(request: HelloRequest) = ZIO.succeed(HelloReply(s"Hello again, ${request.name}")) ``` ```scala def sayHelloAgain(request: HelloRequest) = ZIO.succeed(HelloReply(s"Hello again, ${request.name}")) ``` -------------------------------- ### Construct server with ZLayer Source: https://scalapb.github.io/zio-grpc/docs/context Wires multiple layers together to launch a gRPC server using ZIO App. ```scala import scalapb.zio_grpc.ServerLayer import scalapb.zio_grpc.Server import zio.ZLayer val serviceList = ServiceList .addFromEnvironment[ZSimpleService[RequestContext]] val serverLayer = ServerLayer.fromServiceList( io.grpc.ServerBuilder.forPort(9000), serviceList ) val ourApp = ZLayer.make[Server]( serverLayer, myServiceLayer, UserDatabase.layer ) object LayeredApp extends zio.ZIOAppDefault { def run = ourApp.launch.exitCode } ``` -------------------------------- ### GET /fromName Source: https://scalapb.github.io/api/com/google/protobuf/descriptor/FieldDescriptorProto%24%24Type%24.html Retrieves a Type object based on its string name representation. ```APIDOC ## GET /fromName ### Description Retrieves a Type object from the provided name string. ### Method GET ### Parameters #### Query Parameters - **name** (String) - Required - The name of the type to retrieve. ### Response #### Success Response (200) - **result** (Option[Type]) - The matching Type object if found. ``` -------------------------------- ### Get Class Information Source: https://scalapb.github.io/api/com/google/protobuf/any/Any%24%24AnyLens.html Returns the runtime class of this object. Inherited from `AnyRef`. ```scala final def getClass(): Class[_] ```