@@ -6,12 +6,29 @@ import * as protoLoader from '@grpc/proto-loader';
66import path from 'path' ;
77
88/**
9- * Creates a gRPC client for a specified service defined in a .proto file.
10- * This function loads the .proto file, constructs the service client, and returns it.
11- * @param param0 - Configuration for creating a gRPC client.
12- * @param param0.protoPath - Path to the .proto file defining the gRPC service.
13- * @param param0.serviceName - Name of the service to create a client for.
14- * @returns A gRPC client instance for the specified service.
9+ * Creates and returns a gRPC client for the specified service.
10+ *
11+ * @template T - The type of gRPC client to create, extends grpc.Client
12+ *
13+ * @param options - The configuration options for creating the gRPC client
14+ * @param options.protoPath - Path to the .proto file that defines the service
15+ * @param options.serviceName - Name of the service in the proto file
16+ * @param options.address - The server address to connect to (e.g., "localhost:50051")
17+ * @param options.credentials - gRPC channel credentials to use for secure communication (defaults to insecure)
18+ * @param options.grpcMaxMessageLength - Maximum message length in bytes for both sending and receiving gRPC messages
19+ * @param options.includeDirs - Additional directories to search for imported .proto files
20+ *
21+ * @returns A new instance of the specified gRPC client
22+ *
23+ * @throws {Error } When the specified service name is not found in the proto file
24+ *
25+ * @example
26+ * const client = createGrpcClient<MyServiceClient>({
27+ * protoPath: './protos/my_service.proto',
28+ * serviceName: 'MyService',
29+ * address: 'localhost:50051',
30+ * grpcMaxMessageLength: 4 * 1024 * 1024, // 4MB
31+ * });
1532 */
1633export function createGrpcClient < T extends grpc . Client = grpc . Client > ( {
1734 protoPath,
0 commit comments