Documentation
¶
Index ¶
- func CompileProto(protoDir, protoFile string) (*pluginpb.CodeGeneratorRequest, error)
- func GeneratePreloadGo(routes []RoutePreload, packageName string) string
- func HashFile(path string) (string, error)
- func ReadStoredHash(projectDir string) string
- func RunGoPlugin(req *pluginpb.CodeGeneratorRequest, param string) (*pluginpb.CodeGeneratorResponse, error)
- func RunPlugin(req *pluginpb.CodeGeneratorRequest, pluginPath string, param string) (*pluginpb.CodeGeneratorResponse, error)
- func WriteHash(projectDir, hash string) error
- func WriteResponse(resp *pluginpb.CodeGeneratorResponse, outDir string) ([]string, error)
- type RoutePreload
- type RpcSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompileProto ¶
func CompileProto(protoDir, protoFile string) (*pluginpb.CodeGeneratorRequest, error)
CompileProto parses a .proto file using protocompile and returns a CodeGeneratorRequest that can be piped to any protoc plugin.
func GeneratePreloadGo ¶
func GeneratePreloadGo(routes []RoutePreload, packageName string) string
GeneratePreloadGo generates Go source code for the preload route config. It imports gapp's RouteSpec/RpcSpec types directly so the generated var is compatible with gapp.NewPreloadEngine.
func ReadStoredHash ¶
ReadStoredHash reads the stored codegen hash from .gapp/codegen.hash.
func RunGoPlugin ¶
func RunGoPlugin(req *pluginpb.CodeGeneratorRequest, param string) (*pluginpb.CodeGeneratorResponse, error)
RunGoPlugin invokes protoc-gen-go via `go run` so no global install is needed.
func RunPlugin ¶
func RunPlugin(req *pluginpb.CodeGeneratorRequest, pluginPath string, param string) (*pluginpb.CodeGeneratorResponse, error)
RunPlugin invokes a protoc plugin binary with the given CodeGeneratorRequest, passing the serialized request on stdin and reading the response from stdout.
func WriteResponse ¶
func WriteResponse(resp *pluginpb.CodeGeneratorResponse, outDir string) ([]string, error)
WriteResponse writes all files from a CodeGeneratorResponse to the output directory.
Types ¶
type RoutePreload ¶
RoutePreload defines preload configuration for a route pattern.
func ParseRouteFile ¶
func ParseRouteFile(filePath string) (*RoutePreload, error)
ParseRouteFile extracts the route path and RPC declarations from a TypeScript route file. It looks for the pattern:
export const xxxRoute = {
path: "/...",
factory: () => ({
rpcs: [
{ method: "MethodName" },
{ method: "Other", params: { "id": "userId" } },
],
}),
};
func ScanRoutes ¶
func ScanRoutes(routesDir string) ([]RoutePreload, error)
ScanRoutes scans a directory for route files and extracts preload configs.