Explorar o código

:bug: add php@grpc server support

Jeremy Zheng %!s(int64=2) %!d(string=hai) anos
pai
achega
5f9b48c02a

+ 42 - 0
rpc/morus/morus/Mint/Morus/V1/MarkdownStub.php

@@ -0,0 +1,42 @@
+<?php
+// GENERATED CODE -- DO NOT EDIT!
+
+namespace Mint\Morus\V1;
+
+/**
+ * ----------------------------------------------------------------------------
+ */
+class MarkdownStub {
+
+    /**
+     * @param \Mint\Morus\V1\MarkdownToHtmlRequest $request client request
+     * @param \Grpc\ServerContext $context server request context
+     * @return \Mint\Morus\V1\MarkdownToHtmlResponse for response data, null if if error occured
+     *     initial metadata (if any) and status (if not ok) should be set to $context
+     */
+    public function ToHtml(
+        \Mint\Morus\V1\MarkdownToHtmlRequest $request,
+        \Grpc\ServerContext $context
+    ): ?\Mint\Morus\V1\MarkdownToHtmlResponse {
+        $context->setStatus(\Grpc\Status::unimplemented());
+        return null;
+    }
+
+    /**
+     * Get the method descriptors of the service for server registration
+     *
+     * @return array of \Grpc\MethodDescriptor for the service methods
+     */
+    public final function getMethodDescriptors(): array
+    {
+        return [
+            '/mint.morus.v1.Markdown/ToHtml' => new \Grpc\MethodDescriptor(
+                $this,
+                'ToHtml',
+                '\Mint\Morus\V1\MarkdownToHtmlRequest',
+                \Grpc\MethodDescriptor::UNARY_CALL
+            ),
+        ];
+    }
+
+}

+ 16 - 10
rpc/schema.sh

@@ -7,13 +7,6 @@ export WORKSPACE=$PWD
 
 # -----------------------------------------------------------------------------
 
-# if [[ "$1" == "php" ]]
-#         then
-           
-#         else
-            
-#         fi
-
 function generate_grpc_by_lang() {
     local target=$WORKSPACE/sdk/$1
     echo "generate code for grpc-$1"
@@ -69,9 +62,9 @@ function generate_for_morus() {
     done
     $PROTOBUF_ROOT/bin/protoc -I $WORKSPACE/protocols \
         -I $PROTOBUF_ROOT/include/google/protobuf \
-        --php_out=$target --grpc_out=$target \
+        --php_out=$target --grpc_out=generate_server:$target \
         --plugin=protoc-gen-grpc=$PROTOBUF_ROOT/bin/grpc_php_plugin \
-        $WORKSPACE/protocols/morus.proto
+        $WORKSPACE/protocols/morus.proto    
 }
 
 function generate_for_lily() {
@@ -97,6 +90,19 @@ function generate_for_lily() {
     sed -i 's/import lily_/from . import lily_/g' $target/lily_pb2_grpc.py
 }
 
+function generate_grpc_for_php() {
+    if [ -d $1 ]
+    then
+        rm -r $1
+    fi
+    mkdir -p $1
+    $PROTOBUF_ROOT/bin/protoc -I $WORKSPACE/protocols \
+        -I $PROTOBUF_ROOT/include/google/protobuf \
+        --php_out=$1 --grpc_out=generate_server:$1 \
+        --plugin=protoc-gen-grpc=$PROTOBUF_ROOT/bin/grpc_php_plugin \
+        $WORKSPACE/protocols/*.proto
+}
+
 # -----------------------------------------------------------------------------
 
 declare -a languages=(    
@@ -105,13 +111,13 @@ declare -a languages=(
     "cpp"
     "csharp"    
     "java"
-    "php"
 )
 
 for l in "${languages[@]}"
 do
     generate_grpc_by_lang $l
 done
+generate_grpc_for_php $WORKSPACE/sdk/php
 
 generate_for_morus
 generate_for_lily

+ 42 - 0
rpc/sdk/php/Mint/Morus/V1/MarkdownStub.php

@@ -0,0 +1,42 @@
+<?php
+// GENERATED CODE -- DO NOT EDIT!
+
+namespace Mint\Morus\V1;
+
+/**
+ * ----------------------------------------------------------------------------
+ */
+class MarkdownStub {
+
+    /**
+     * @param \Mint\Morus\V1\MarkdownToHtmlRequest $request client request
+     * @param \Grpc\ServerContext $context server request context
+     * @return \Mint\Morus\V1\MarkdownToHtmlResponse for response data, null if if error occured
+     *     initial metadata (if any) and status (if not ok) should be set to $context
+     */
+    public function ToHtml(
+        \Mint\Morus\V1\MarkdownToHtmlRequest $request,
+        \Grpc\ServerContext $context
+    ): ?\Mint\Morus\V1\MarkdownToHtmlResponse {
+        $context->setStatus(\Grpc\Status::unimplemented());
+        return null;
+    }
+
+    /**
+     * Get the method descriptors of the service for server registration
+     *
+     * @return array of \Grpc\MethodDescriptor for the service methods
+     */
+    public final function getMethodDescriptors(): array
+    {
+        return [
+            '/mint.morus.v1.Markdown/ToHtml' => new \Grpc\MethodDescriptor(
+                $this,
+                'ToHtml',
+                '\Mint\Morus\V1\MarkdownToHtmlRequest',
+                \Grpc\MethodDescriptor::UNARY_CALL
+            ),
+        ];
+    }
+
+}

+ 43 - 0
rpc/sdk/php/Palm/Lily/V1/EpubStub.php

@@ -0,0 +1,43 @@
+<?php
+// GENERATED CODE -- DO NOT EDIT!
+
+namespace Palm\Lily\V1;
+
+/**
+ * ----------------------------------------------------------------------------
+ *
+ */
+class EpubStub {
+
+    /**
+     * @param \Palm\Lily\V1\EpubBuildRequest $request client request
+     * @param \Grpc\ServerContext $context server request context
+     * @return \Palm\Lily\V1\S3File for response data, null if if error occured
+     *     initial metadata (if any) and status (if not ok) should be set to $context
+     */
+    public function Build(
+        \Palm\Lily\V1\EpubBuildRequest $request,
+        \Grpc\ServerContext $context
+    ): ?\Palm\Lily\V1\S3File {
+        $context->setStatus(\Grpc\Status::unimplemented());
+        return null;
+    }
+
+    /**
+     * Get the method descriptors of the service for server registration
+     *
+     * @return array of \Grpc\MethodDescriptor for the service methods
+     */
+    public final function getMethodDescriptors(): array
+    {
+        return [
+            '/palm.lily.v1.Epub/Build' => new \Grpc\MethodDescriptor(
+                $this,
+                'Build',
+                '\Palm\Lily\V1\EpubBuildRequest',
+                \Grpc\MethodDescriptor::UNARY_CALL
+            ),
+        ];
+    }
+
+}

+ 63 - 0
rpc/sdk/php/Palm/Lily/V1/ExcelStub.php

@@ -0,0 +1,63 @@
+<?php
+// GENERATED CODE -- DO NOT EDIT!
+
+namespace Palm\Lily\V1;
+
+/**
+ * ----------------------------------------------------------------------------
+ *
+ */
+class ExcelStub {
+
+    /**
+     * @param \Palm\Lily\V1\S3File $request client request
+     * @param \Grpc\ServerContext $context server request context
+     * @return \Palm\Lily\V1\ExcelModel for response data, null if if error occured
+     *     initial metadata (if any) and status (if not ok) should be set to $context
+     */
+    public function Parse(
+        \Palm\Lily\V1\S3File $request,
+        \Grpc\ServerContext $context
+    ): ?\Palm\Lily\V1\ExcelModel {
+        $context->setStatus(\Grpc\Status::unimplemented());
+        return null;
+    }
+
+    /**
+     * @param \Palm\Lily\V1\ExcelModel $request client request
+     * @param \Grpc\ServerContext $context server request context
+     * @return \Palm\Lily\V1\S3File for response data, null if if error occured
+     *     initial metadata (if any) and status (if not ok) should be set to $context
+     */
+    public function Generate(
+        \Palm\Lily\V1\ExcelModel $request,
+        \Grpc\ServerContext $context
+    ): ?\Palm\Lily\V1\S3File {
+        $context->setStatus(\Grpc\Status::unimplemented());
+        return null;
+    }
+
+    /**
+     * Get the method descriptors of the service for server registration
+     *
+     * @return array of \Grpc\MethodDescriptor for the service methods
+     */
+    public final function getMethodDescriptors(): array
+    {
+        return [
+            '/palm.lily.v1.Excel/Parse' => new \Grpc\MethodDescriptor(
+                $this,
+                'Parse',
+                '\Palm\Lily\V1\S3File',
+                \Grpc\MethodDescriptor::UNARY_CALL
+            ),
+            '/palm.lily.v1.Excel/Generate' => new \Grpc\MethodDescriptor(
+                $this,
+                'Generate',
+                '\Palm\Lily\V1\ExcelModel',
+                \Grpc\MethodDescriptor::UNARY_CALL
+            ),
+        ];
+    }
+
+}

+ 41 - 0
rpc/sdk/php/Palm/Lily/V1/S3Stub.php

@@ -0,0 +1,41 @@
+<?php
+// GENERATED CODE -- DO NOT EDIT!
+
+namespace Palm\Lily\V1;
+
+/**
+ */
+class S3Stub {
+
+    /**
+     * @param \Palm\Lily\V1\S3GetFileRequest $request client request
+     * @param \Grpc\ServerContext $context server request context
+     * @return \Palm\Lily\V1\S3GetFileResponse for response data, null if if error occured
+     *     initial metadata (if any) and status (if not ok) should be set to $context
+     */
+    public function GetFile(
+        \Palm\Lily\V1\S3GetFileRequest $request,
+        \Grpc\ServerContext $context
+    ): ?\Palm\Lily\V1\S3GetFileResponse {
+        $context->setStatus(\Grpc\Status::unimplemented());
+        return null;
+    }
+
+    /**
+     * Get the method descriptors of the service for server registration
+     *
+     * @return array of \Grpc\MethodDescriptor for the service methods
+     */
+    public final function getMethodDescriptors(): array
+    {
+        return [
+            '/palm.lily.v1.S3/GetFile' => new \Grpc\MethodDescriptor(
+                $this,
+                'GetFile',
+                '\Palm\Lily\V1\S3GetFileRequest',
+                \Grpc\MethodDescriptor::UNARY_CALL
+            ),
+        ];
+    }
+
+}

+ 61 - 0
rpc/sdk/php/Palm/Lily/V1/TexStub.php

@@ -0,0 +1,61 @@
+<?php
+// GENERATED CODE -- DO NOT EDIT!
+
+namespace Palm\Lily\V1;
+
+/**
+ */
+class TexStub {
+
+    /**
+     * @param \Palm\Lily\V1\TexToRequest $request client request
+     * @param \Grpc\ServerContext $context server request context
+     * @return \Palm\Lily\V1\S3File for response data, null if if error occured
+     *     initial metadata (if any) and status (if not ok) should be set to $context
+     */
+    public function ToPdf(
+        \Palm\Lily\V1\TexToRequest $request,
+        \Grpc\ServerContext $context
+    ): ?\Palm\Lily\V1\S3File {
+        $context->setStatus(\Grpc\Status::unimplemented());
+        return null;
+    }
+
+    /**
+     * @param \Palm\Lily\V1\TexToRequest $request client request
+     * @param \Grpc\ServerContext $context server request context
+     * @return \Palm\Lily\V1\S3File for response data, null if if error occured
+     *     initial metadata (if any) and status (if not ok) should be set to $context
+     */
+    public function ToWord(
+        \Palm\Lily\V1\TexToRequest $request,
+        \Grpc\ServerContext $context
+    ): ?\Palm\Lily\V1\S3File {
+        $context->setStatus(\Grpc\Status::unimplemented());
+        return null;
+    }
+
+    /**
+     * Get the method descriptors of the service for server registration
+     *
+     * @return array of \Grpc\MethodDescriptor for the service methods
+     */
+    public final function getMethodDescriptors(): array
+    {
+        return [
+            '/palm.lily.v1.Tex/ToPdf' => new \Grpc\MethodDescriptor(
+                $this,
+                'ToPdf',
+                '\Palm\Lily\V1\TexToRequest',
+                \Grpc\MethodDescriptor::UNARY_CALL
+            ),
+            '/palm.lily.v1.Tex/ToWord' => new \Grpc\MethodDescriptor(
+                $this,
+                'ToWord',
+                '\Palm\Lily\V1\TexToRequest',
+                \Grpc\MethodDescriptor::UNARY_CALL
+            ),
+        ];
+    }
+
+}