View Source Sidecar.GRPC.CodeGenerator (spawn v2.0.0-RC6)
Module for generating gRPC code from Protobuf files.
This module provides functionality to compile Protobuf files and generate gRPC-related code. It supports both gRPC and HTTP transcoding code generation.
Usage
- Call
compile_protos/1
to generate gRPC code from Protobuf files. - Ensure that Protobuf files are placed in the specified directory (
priv/protos
by default).
Summary
Functions
Compiles an Elixir module generated from Protobuf files and returns the compiled code.
Compiles Protobuf files and generates gRPC-related code.
Loads Elixir modules from the specified directory with a '.pb.ex' file extension.
Functions
Compiles an Elixir module generated from Protobuf files and returns the compiled code.
Parameters:
module
- The String of Elixir module code generated from Protobuf files.
Returns:
The compiled Elixir code.
Example:
module_code = Sidecar.Grpc.CodeGenerator.compile_modules(generated_code)
Raises:
Raises an error if there are issues during the compilation process.
Compiles Protobuf files and generates gRPC-related code.
### Options:
:protos_path
- Include path of protobufs to generate (default: "priv/protos").:output_path
- Output path for generated code (default: "priv/protos/modules").:http_transcoding_enabled
- Enable HTTP transcoding (default: true).
### Example:
Sidecar.Grpc.CodeGenerator.compile_protos(output_path: "custom_output", http_transcoding_enabled: false)
Loads Elixir modules from the specified directory with a '.pb.ex' file extension.
Parameters
opts
(KeywordList): Options for loading modules.:output_path
(String): Path to the directory containing the modules. Default is "/home/dev/workspace/spawn/priv/protos/modules".
Returns
A list of strings, where each string represents the content of an Elixir module file.
Examples
opts = [output_path: "/path/to/modules"]
modules = load_modules(opts)
IO.inspect(modules)
This example loads Elixir modules from the specified directory "/path/to/modules" and prints the content of each module.