From 7b7d53fc23ebe1275a2d1fcdfccd51a034fb3386 Mon Sep 17 00:00:00 2001 From: "fuchun.zhang" Date: Wed, 14 Dec 2022 16:48:46 +0800 Subject: [PATCH 1/3] add example code of code generator --- examples/code_generator/Makefile | 7 + examples/code_generator/README.md | 18 + .../examples/my_test_grpc_plugin/go.mod | 25 + .../examples/my_test_grpc_plugin/go.sum | 130 +++ .../my_test_grpc_plugin.pb.go | 911 ++++++++++++++++++ .../my_test_grpc_plugin.plugin.go | 46 + .../my_test_grpc_plugin_callee/callee.go | 27 + .../my_test_grpc_plugin_callee/go.mod | 26 + .../my_test_grpc_plugin_callee/go.sum | 130 +++ .../plugin/plugin.go | 20 + .../my_test_grpc_plugin_caller/go.mod | 30 + .../my_test_grpc_plugin_caller/go.sum | 130 +++ .../loader/debugs_util.go | 27 + .../loader/dynamic_plugins.go | 81 ++ .../loader/loader.go | 74 ++ .../loader/loader_test.go | 74 ++ .../proto/my_test_grpc_plugin.proto | 35 + 17 files changed, 1791 insertions(+) create mode 100644 examples/code_generator/Makefile create mode 100644 examples/code_generator/README.md create mode 100644 examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/go.mod create mode 100644 examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/go.sum create mode 100644 examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/my_test_grpc_plugin.pb.go create mode 100644 examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/my_test_grpc_plugin.plugin.go create mode 100644 examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/callee.go create mode 100644 examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/go.mod create mode 100644 examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/go.sum create mode 100644 examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/plugin/plugin.go create mode 100644 examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/go.mod create mode 100644 examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/go.sum create mode 100644 examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/debugs_util.go create mode 100644 examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/dynamic_plugins.go create mode 100644 examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/loader.go create mode 100644 examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/loader_test.go create mode 100644 examples/code_generator/proto/my_test_grpc_plugin.proto diff --git a/examples/code_generator/Makefile b/examples/code_generator/Makefile new file mode 100644 index 00000000..30c7b72f --- /dev/null +++ b/examples/code_generator/Makefile @@ -0,0 +1,7 @@ + +proto_path="${HOME}/code/" + +.PHONY: pb +pb: + protoc -I=. -I=${proto_path} --gogofaster_out=plugins=grpc:. proto/*.proto + diff --git a/examples/code_generator/README.md b/examples/code_generator/README.md new file mode 100644 index 00000000..f4c24b6e --- /dev/null +++ b/examples/code_generator/README.md @@ -0,0 +1,18 @@ +This is a command tool to generate proto3 to grpc plugin golang source code. + +# How to use +## 1.download gogo proto: +```shell +mkdir -p ${HOME}/code/github.com/gogo/ +cd ${HOME}/code/github.com/gogo/ +git clone https://github.com/gogo/protobuf.git +``` + +## 2.add a proto3 idl file: +see example: [./proto/my_test_grpc_plugin.proto] +* define Request and Response message format +* define a service +* use protoc to generate XX.pb.go files +```shell +make pb proto_path="${HOME}/code/" +``` diff --git a/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/go.mod b/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/go.mod new file mode 100644 index 00000000..86225141 --- /dev/null +++ b/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/go.mod @@ -0,0 +1,25 @@ +module github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin + +go 1.17 + +require ( + github.com/gogo/protobuf v1.3.2 + github.com/hashicorp/go-plugin v1.4.8 + google.golang.org/grpc v1.51.0 + google.golang.org/protobuf v1.28.1 +) + +require ( + github.com/fatih/color v1.7.0 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/hashicorp/go-hclog v0.14.1 // indirect + github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb // indirect + github.com/mattn/go-colorable v0.1.4 // indirect + github.com/mattn/go-isatty v0.0.10 // indirect + github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 // indirect + github.com/oklog/run v1.0.0 // indirect + golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect + golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect + golang.org/x/text v0.4.0 // indirect + google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect +) diff --git a/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/go.sum b/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/go.sum new file mode 100644 index 00000000..0bddcd94 --- /dev/null +++ b/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/go.sum @@ -0,0 +1,130 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= +github.com/hashicorp/go-hclog v0.14.1 h1:nQcJDQwIAGnmoUWp8ubocEX40cCml/17YkF6csQLReU= +github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= +github.com/hashicorp/go-plugin v1.4.8 h1:CHGwpxYDOttQOY7HOWgETU9dyVjOXzniXDqJcYJE1zM= +github.com/hashicorp/go-plugin v1.4.8/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s= +github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb h1:b5rjCoWHc7eqmAS4/qyk21ZsHyb6Mxv/jykxvNTkU4M= +github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= +github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= +github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10= +github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= +github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 h1:7GoSOOW2jpsfkntVKaS2rAr1TJqfcxotyaUcuxoZSzg= +github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= +github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.51.0 h1:E1eGv1FTqoLIdnBCZufiSHgKjlqG6fKFf6pPWtMTh8U= +google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/my_test_grpc_plugin.pb.go b/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/my_test_grpc_plugin.pb.go new file mode 100644 index 00000000..21241549 --- /dev/null +++ b/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/my_test_grpc_plugin.pb.go @@ -0,0 +1,911 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: proto/my_test_grpc_plugin.proto + +package my_test_grpc_plugin + +import ( + context "context" + encoding_binary "encoding/binary" + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + descriptorpb "google.golang.org/protobuf/types/descriptorpb" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Request struct { + Field1 int32 `protobuf:"varint,1,opt,name=field1,proto3" json:"field1,omitempty"` + Field2 int64 `protobuf:"varint,2,opt,name=field2,proto3" json:"field2,omitempty"` + Field3 float64 `protobuf:"fixed64,3,opt,name=field3,proto3" json:"field3,omitempty"` + Field4 string `protobuf:"bytes,4,opt,name=field4,proto3" json:"field4,omitempty"` + Field5 []byte `protobuf:"bytes,5,opt,name=field5,proto3" json:"field5,omitempty"` + Field6 []string `protobuf:"bytes,6,rep,name=field6,proto3" json:"field6,omitempty"` +} + +func (m *Request) Reset() { *m = Request{} } +func (m *Request) String() string { return proto.CompactTextString(m) } +func (*Request) ProtoMessage() {} +func (*Request) Descriptor() ([]byte, []int) { + return fileDescriptor_0b06b1e5fa595b1e, []int{0} +} +func (m *Request) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Request) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Request.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Request) XXX_Merge(src proto.Message) { + xxx_messageInfo_Request.Merge(m, src) +} +func (m *Request) XXX_Size() int { + return m.Size() +} +func (m *Request) XXX_DiscardUnknown() { + xxx_messageInfo_Request.DiscardUnknown(m) +} + +var xxx_messageInfo_Request proto.InternalMessageInfo + +func (m *Request) GetField1() int32 { + if m != nil { + return m.Field1 + } + return 0 +} + +func (m *Request) GetField2() int64 { + if m != nil { + return m.Field2 + } + return 0 +} + +func (m *Request) GetField3() float64 { + if m != nil { + return m.Field3 + } + return 0 +} + +func (m *Request) GetField4() string { + if m != nil { + return m.Field4 + } + return "" +} + +func (m *Request) GetField5() []byte { + if m != nil { + return m.Field5 + } + return nil +} + +func (m *Request) GetField6() []string { + if m != nil { + return m.Field6 + } + return nil +} + +type Response struct { + Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` + Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` +} + +func (m *Response) Reset() { *m = Response{} } +func (m *Response) String() string { return proto.CompactTextString(m) } +func (*Response) ProtoMessage() {} +func (*Response) Descriptor() ([]byte, []int) { + return fileDescriptor_0b06b1e5fa595b1e, []int{1} +} +func (m *Response) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Response.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Response) XXX_Merge(src proto.Message) { + xxx_messageInfo_Response.Merge(m, src) +} +func (m *Response) XXX_Size() int { + return m.Size() +} +func (m *Response) XXX_DiscardUnknown() { + xxx_messageInfo_Response.DiscardUnknown(m) +} + +var xxx_messageInfo_Response proto.InternalMessageInfo + +func (m *Response) GetCode() int32 { + if m != nil { + return m.Code + } + return 0 +} + +func (m *Response) GetMsg() string { + if m != nil { + return m.Msg + } + return "" +} + +var E_PluginName = &proto.ExtensionDesc{ + ExtendedType: (*descriptorpb.ServiceOptions)(nil), + ExtensionType: (*string)(nil), + Field: 51235, + Name: "grpc_plugin.plugin_name", + Tag: "bytes,51235,opt,name=plugin_name", + Filename: "proto/my_test_grpc_plugin.proto", +} + +func init() { + proto.RegisterType((*Request)(nil), "grpc_plugin.Request") + proto.RegisterType((*Response)(nil), "grpc_plugin.Response") + proto.RegisterExtension(E_PluginName) +} + +func init() { proto.RegisterFile("proto/my_test_grpc_plugin.proto", fileDescriptor_0b06b1e5fa595b1e) } + +var fileDescriptor_0b06b1e5fa595b1e = []byte{ + // 418 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xbf, 0x6f, 0xd4, 0x30, + 0x14, 0xc7, 0xcf, 0xa4, 0x3d, 0xa8, 0x0f, 0x89, 0xca, 0x02, 0x14, 0x32, 0xa4, 0x51, 0xa7, 0x2c, + 0x4d, 0x68, 0xae, 0xed, 0x50, 0x26, 0x10, 0x3f, 0x26, 0xa0, 0x0a, 0x20, 0x10, 0x4b, 0x94, 0xf3, + 0xbd, 0x3a, 0x91, 0x92, 0x3c, 0x63, 0x3b, 0x88, 0x5b, 0x99, 0x18, 0xbb, 0xc2, 0xca, 0x3f, 0xc3, + 0xd8, 0x91, 0x11, 0xdd, 0xfd, 0x23, 0xe8, 0x12, 0x13, 0x4e, 0x15, 0x0b, 0xdb, 0xf3, 0xc7, 0x5f, + 0xfb, 0xfb, 0x7e, 0xd1, 0x3d, 0xa9, 0xd0, 0x60, 0x5c, 0x2f, 0x32, 0x03, 0xda, 0x64, 0x42, 0x49, + 0x9e, 0xc9, 0xaa, 0x15, 0x65, 0x13, 0x75, 0x37, 0x6c, 0xb2, 0x81, 0xbc, 0x40, 0x20, 0x8a, 0x0a, + 0xe2, 0xee, 0x6a, 0xd6, 0x9e, 0xc7, 0x73, 0xd0, 0x5c, 0x95, 0xd2, 0xa0, 0xea, 0xe5, 0xde, 0x81, + 0x28, 0x4d, 0xd1, 0xce, 0x22, 0x8e, 0x75, 0x2c, 0x50, 0xe0, 0x5f, 0xe9, 0xfa, 0xd4, 0x9b, 0xad, + 0xa3, 0x5e, 0xbe, 0xff, 0x95, 0xd0, 0xeb, 0x29, 0x7c, 0x68, 0x41, 0x1b, 0x76, 0x97, 0x8e, 0xcf, + 0x4b, 0xa8, 0xe6, 0x87, 0x2e, 0x09, 0x48, 0xb8, 0x9d, 0xda, 0xd3, 0xc0, 0x13, 0xf7, 0x5a, 0x40, + 0x42, 0xc7, 0xf2, 0x64, 0xe0, 0x53, 0xd7, 0x09, 0x48, 0x48, 0x2c, 0x9f, 0x0e, 0xfc, 0xc8, 0xdd, + 0x0a, 0x48, 0xb8, 0x63, 0xf9, 0xd1, 0xc0, 0x8f, 0xdd, 0xed, 0x80, 0x84, 0x37, 0x2d, 0x3f, 0x1e, + 0xf8, 0x89, 0x3b, 0x0e, 0x9c, 0x41, 0x7f, 0xb2, 0x7f, 0x9f, 0xde, 0x48, 0x41, 0x4b, 0x6c, 0x34, + 0x30, 0x46, 0xb7, 0x38, 0xce, 0xc1, 0x66, 0xd6, 0xc5, 0x6c, 0x97, 0x3a, 0xb5, 0x16, 0x5d, 0x52, + 0x3b, 0xe9, 0x3a, 0x4c, 0xde, 0xd2, 0xdd, 0xe7, 0x8b, 0xd7, 0xa0, 0xcd, 0x33, 0x25, 0xf9, 0x59, + 0xd7, 0x32, 0x96, 0x50, 0x47, 0xb5, 0x0d, 0xbb, 0x1d, 0x6d, 0xb6, 0xd6, 0x96, 0xec, 0xdd, 0xb9, + 0x42, 0x7b, 0x37, 0xef, 0xd6, 0xb7, 0xcf, 0xf7, 0x26, 0xf5, 0xc2, 0xf2, 0xec, 0x30, 0x79, 0x47, + 0xbd, 0xab, 0x1f, 0x3f, 0x45, 0xf5, 0xb0, 0x41, 0x53, 0x80, 0x62, 0xa7, 0x74, 0x72, 0xa6, 0x90, + 0x83, 0xd6, 0x8f, 0x73, 0x93, 0xff, 0x97, 0xd5, 0xe9, 0x13, 0x3a, 0xb1, 0x2e, 0x4d, 0x5e, 0x03, + 0xdb, 0x8b, 0xfa, 0x09, 0x47, 0x7f, 0xc6, 0x16, 0xbd, 0x02, 0xf5, 0xb1, 0xe4, 0xf0, 0x52, 0x9a, + 0x12, 0x1b, 0xed, 0x7e, 0xbf, 0x70, 0xba, 0x7a, 0x69, 0xff, 0xea, 0x45, 0x5e, 0xc3, 0x17, 0x42, + 0x1e, 0xbd, 0xf9, 0xb1, 0xf4, 0xc9, 0xe5, 0xd2, 0x27, 0xbf, 0x96, 0x3e, 0xb9, 0x58, 0xf9, 0xa3, + 0xcb, 0x95, 0x3f, 0xfa, 0xb9, 0xf2, 0x47, 0xef, 0x1f, 0x6c, 0x2c, 0x44, 0x91, 0xeb, 0xa2, 0xe4, + 0xa8, 0x64, 0x2c, 0xf0, 0xa0, 0xff, 0x20, 0x86, 0x4f, 0x79, 0x2d, 0x2b, 0xd0, 0xff, 0x5a, 0xc1, + 0xd9, 0xb8, 0x4b, 0x63, 0xfa, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x64, 0xc4, 0x8d, 0xa6, 0x02, + 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MyTestGrpcPluginClient is the client API for MyTestGrpcPlugin service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MyTestGrpcPluginClient interface { + Run(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) +} + +type myTestGrpcPluginClient struct { + cc *grpc.ClientConn +} + +func NewMyTestGrpcPluginClient(cc *grpc.ClientConn) MyTestGrpcPluginClient { + return &myTestGrpcPluginClient{cc} +} + +func (c *myTestGrpcPluginClient) Run(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) { + out := new(Response) + err := c.cc.Invoke(ctx, "/grpc_plugin.MyTestGrpcPlugin/run", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MyTestGrpcPluginServer is the server API for MyTestGrpcPlugin service. +type MyTestGrpcPluginServer interface { + Run(context.Context, *Request) (*Response, error) +} + +// UnimplementedMyTestGrpcPluginServer can be embedded to have forward compatible implementations. +type UnimplementedMyTestGrpcPluginServer struct { +} + +func (*UnimplementedMyTestGrpcPluginServer) Run(ctx context.Context, req *Request) (*Response, error) { + return nil, status.Errorf(codes.Unimplemented, "method Run not implemented") +} + +func RegisterMyTestGrpcPluginServer(s *grpc.Server, srv MyTestGrpcPluginServer) { + s.RegisterService(&_MyTestGrpcPlugin_serviceDesc, srv) +} + +func _MyTestGrpcPlugin_Run_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Request) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MyTestGrpcPluginServer).Run(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc_plugin.MyTestGrpcPlugin/Run", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MyTestGrpcPluginServer).Run(ctx, req.(*Request)) + } + return interceptor(ctx, in, info, handler) +} + +var _MyTestGrpcPlugin_serviceDesc = grpc.ServiceDesc{ + ServiceName: "grpc_plugin.MyTestGrpcPlugin", + HandlerType: (*MyTestGrpcPluginServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "run", + Handler: _MyTestGrpcPlugin_Run_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "proto/my_test_grpc_plugin.proto", +} + +// MyTestGrpcPluginForAnotherClient is the client API for MyTestGrpcPluginForAnother service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MyTestGrpcPluginForAnotherClient interface { + ProcessData(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) +} + +type myTestGrpcPluginForAnotherClient struct { + cc *grpc.ClientConn +} + +func NewMyTestGrpcPluginForAnotherClient(cc *grpc.ClientConn) MyTestGrpcPluginForAnotherClient { + return &myTestGrpcPluginForAnotherClient{cc} +} + +func (c *myTestGrpcPluginForAnotherClient) ProcessData(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) { + out := new(Response) + err := c.cc.Invoke(ctx, "/grpc_plugin.MyTestGrpcPluginForAnother/ProcessData", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MyTestGrpcPluginForAnotherServer is the server API for MyTestGrpcPluginForAnother service. +type MyTestGrpcPluginForAnotherServer interface { + ProcessData(context.Context, *Request) (*Response, error) +} + +// UnimplementedMyTestGrpcPluginForAnotherServer can be embedded to have forward compatible implementations. +type UnimplementedMyTestGrpcPluginForAnotherServer struct { +} + +func (*UnimplementedMyTestGrpcPluginForAnotherServer) ProcessData(ctx context.Context, req *Request) (*Response, error) { + return nil, status.Errorf(codes.Unimplemented, "method ProcessData not implemented") +} + +func RegisterMyTestGrpcPluginForAnotherServer(s *grpc.Server, srv MyTestGrpcPluginForAnotherServer) { + s.RegisterService(&_MyTestGrpcPluginForAnother_serviceDesc, srv) +} + +func _MyTestGrpcPluginForAnother_ProcessData_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Request) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MyTestGrpcPluginForAnotherServer).ProcessData(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc_plugin.MyTestGrpcPluginForAnother/ProcessData", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MyTestGrpcPluginForAnotherServer).ProcessData(ctx, req.(*Request)) + } + return interceptor(ctx, in, info, handler) +} + +var _MyTestGrpcPluginForAnother_serviceDesc = grpc.ServiceDesc{ + ServiceName: "grpc_plugin.MyTestGrpcPluginForAnother", + HandlerType: (*MyTestGrpcPluginForAnotherServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ProcessData", + Handler: _MyTestGrpcPluginForAnother_ProcessData_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "proto/my_test_grpc_plugin.proto", +} + +func (m *Request) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Request) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Request) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Field6) > 0 { + for iNdEx := len(m.Field6) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Field6[iNdEx]) + copy(dAtA[i:], m.Field6[iNdEx]) + i = encodeVarintMyTestGrpcPlugin(dAtA, i, uint64(len(m.Field6[iNdEx]))) + i-- + dAtA[i] = 0x32 + } + } + if len(m.Field5) > 0 { + i -= len(m.Field5) + copy(dAtA[i:], m.Field5) + i = encodeVarintMyTestGrpcPlugin(dAtA, i, uint64(len(m.Field5))) + i-- + dAtA[i] = 0x2a + } + if len(m.Field4) > 0 { + i -= len(m.Field4) + copy(dAtA[i:], m.Field4) + i = encodeVarintMyTestGrpcPlugin(dAtA, i, uint64(len(m.Field4))) + i-- + dAtA[i] = 0x22 + } + if m.Field3 != 0 { + i -= 8 + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Field3)))) + i-- + dAtA[i] = 0x19 + } + if m.Field2 != 0 { + i = encodeVarintMyTestGrpcPlugin(dAtA, i, uint64(m.Field2)) + i-- + dAtA[i] = 0x10 + } + if m.Field1 != 0 { + i = encodeVarintMyTestGrpcPlugin(dAtA, i, uint64(m.Field1)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *Response) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Response) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Response) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Msg) > 0 { + i -= len(m.Msg) + copy(dAtA[i:], m.Msg) + i = encodeVarintMyTestGrpcPlugin(dAtA, i, uint64(len(m.Msg))) + i-- + dAtA[i] = 0x12 + } + if m.Code != 0 { + i = encodeVarintMyTestGrpcPlugin(dAtA, i, uint64(m.Code)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintMyTestGrpcPlugin(dAtA []byte, offset int, v uint64) int { + offset -= sovMyTestGrpcPlugin(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Request) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Field1 != 0 { + n += 1 + sovMyTestGrpcPlugin(uint64(m.Field1)) + } + if m.Field2 != 0 { + n += 1 + sovMyTestGrpcPlugin(uint64(m.Field2)) + } + if m.Field3 != 0 { + n += 9 + } + l = len(m.Field4) + if l > 0 { + n += 1 + l + sovMyTestGrpcPlugin(uint64(l)) + } + l = len(m.Field5) + if l > 0 { + n += 1 + l + sovMyTestGrpcPlugin(uint64(l)) + } + if len(m.Field6) > 0 { + for _, s := range m.Field6 { + l = len(s) + n += 1 + l + sovMyTestGrpcPlugin(uint64(l)) + } + } + return n +} + +func (m *Response) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Code != 0 { + n += 1 + sovMyTestGrpcPlugin(uint64(m.Code)) + } + l = len(m.Msg) + if l > 0 { + n += 1 + l + sovMyTestGrpcPlugin(uint64(l)) + } + return n +} + +func sovMyTestGrpcPlugin(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozMyTestGrpcPlugin(x uint64) (n int) { + return sovMyTestGrpcPlugin(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Request) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMyTestGrpcPlugin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Request: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Request: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Field1", wireType) + } + m.Field1 = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMyTestGrpcPlugin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Field1 |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Field2", wireType) + } + m.Field2 = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMyTestGrpcPlugin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Field2 |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field Field3", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.Field3 = float64(math.Float64frombits(v)) + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Field4", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMyTestGrpcPlugin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMyTestGrpcPlugin + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMyTestGrpcPlugin + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Field4 = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Field5", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMyTestGrpcPlugin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthMyTestGrpcPlugin + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthMyTestGrpcPlugin + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Field5 = append(m.Field5[:0], dAtA[iNdEx:postIndex]...) + if m.Field5 == nil { + m.Field5 = []byte{} + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Field6", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMyTestGrpcPlugin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMyTestGrpcPlugin + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMyTestGrpcPlugin + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Field6 = append(m.Field6, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMyTestGrpcPlugin(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMyTestGrpcPlugin + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Response) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMyTestGrpcPlugin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Response: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Response: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) + } + m.Code = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMyTestGrpcPlugin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Code |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Msg", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMyTestGrpcPlugin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMyTestGrpcPlugin + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMyTestGrpcPlugin + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Msg = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMyTestGrpcPlugin(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMyTestGrpcPlugin + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipMyTestGrpcPlugin(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMyTestGrpcPlugin + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMyTestGrpcPlugin + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMyTestGrpcPlugin + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthMyTestGrpcPlugin + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupMyTestGrpcPlugin + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthMyTestGrpcPlugin + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthMyTestGrpcPlugin = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowMyTestGrpcPlugin = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupMyTestGrpcPlugin = fmt.Errorf("proto: unexpected end of group") +) diff --git a/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/my_test_grpc_plugin.plugin.go b/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/my_test_grpc_plugin.plugin.go new file mode 100644 index 00000000..4bf1fea1 --- /dev/null +++ b/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/my_test_grpc_plugin.plugin.go @@ -0,0 +1,46 @@ +package my_test_grpc_plugin + +import ( + "context" + + "github.com/hashicorp/go-plugin" + + "google.golang.org/grpc" +) + +var Handshake = plugin.HandshakeConfig{ + ProtocolVersion: 1, + MagicCookieKey: "BASIC_PLUGIN", + MagicCookieValue: "hello", +} + +type GRPC struct { + plugin.Plugin + Impl MyTestGrpcPluginServer +} + +func (p *GRPC) GRPCServer(broker *plugin.GRPCBroker, server *grpc.Server) error { + RegisterMyTestGrpcPluginServer(server, &GPRCPluginServerWrapper{impl: p.Impl}) + return nil +} + +func (p *GRPC) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, conn *grpc.ClientConn) (interface{}, error) { + return &GRPCPluginClientWrapper{client: NewMyTestGrpcPluginClient(conn)}, nil +} + +type GPRCPluginServerWrapper struct { + impl MyTestGrpcPluginServer + UnimplementedMyTestGrpcPluginServer +} + +func (g *GPRCPluginServerWrapper) Run(ctx context.Context, req *Request) (*Response, error) { + return g.impl.Run(ctx, req) +} + +type GRPCPluginClientWrapper struct { + client MyTestGrpcPluginClient +} + +func (g *GRPCPluginClientWrapper) Run(ctx context.Context, req *Request) (*Response, error) { + return g.client.Run(ctx, req) +} diff --git a/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/callee.go b/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/callee.go new file mode 100644 index 00000000..e29aee53 --- /dev/null +++ b/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/callee.go @@ -0,0 +1,27 @@ +package main + +import ( + "runtime" + + "github.com/hashicorp/go-plugin" + + pb "github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin" + + imp "github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/plugin" +) + +func StartPluginCaller() { + plugin.Serve(&plugin.ServeConfig{ + HandshakeConfig: pb.Handshake, + Plugins: map[string]plugin.Plugin{ + "my_plugin_1": &pb.GRPC{Impl: &imp.PluginService{}}, + }, + // A non-nil value here enables gRPC serving for this plugin... + GRPCServer: plugin.DefaultGRPCServer, + }) +} + +func main() { + runtime.GOMAXPROCS(1) + StartPluginCaller() +} diff --git a/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/go.mod b/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/go.mod new file mode 100644 index 00000000..904db178 --- /dev/null +++ b/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/go.mod @@ -0,0 +1,26 @@ +module github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee + +go 1.17 + +replace github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin => ../my_test_grpc_plugin + +require github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin v0.0.0-00010101000000-000000000000 + +require ( + github.com/fatih/color v1.7.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/hashicorp/go-hclog v0.14.1 // indirect + github.com/hashicorp/go-plugin v1.4.8 // indirect + github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb // indirect + github.com/mattn/go-colorable v0.1.4 // indirect + github.com/mattn/go-isatty v0.0.10 // indirect + github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 // indirect + github.com/oklog/run v1.0.0 // indirect + golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect + golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect + golang.org/x/text v0.4.0 // indirect + google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect + google.golang.org/grpc v1.51.0 // indirect + google.golang.org/protobuf v1.28.1 // indirect +) diff --git a/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/go.sum b/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/go.sum new file mode 100644 index 00000000..0bddcd94 --- /dev/null +++ b/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/go.sum @@ -0,0 +1,130 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= +github.com/hashicorp/go-hclog v0.14.1 h1:nQcJDQwIAGnmoUWp8ubocEX40cCml/17YkF6csQLReU= +github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= +github.com/hashicorp/go-plugin v1.4.8 h1:CHGwpxYDOttQOY7HOWgETU9dyVjOXzniXDqJcYJE1zM= +github.com/hashicorp/go-plugin v1.4.8/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s= +github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb h1:b5rjCoWHc7eqmAS4/qyk21ZsHyb6Mxv/jykxvNTkU4M= +github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= +github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= +github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10= +github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= +github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 h1:7GoSOOW2jpsfkntVKaS2rAr1TJqfcxotyaUcuxoZSzg= +github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= +github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.51.0 h1:E1eGv1FTqoLIdnBCZufiSHgKjlqG6fKFf6pPWtMTh8U= +google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/plugin/plugin.go b/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/plugin/plugin.go new file mode 100644 index 00000000..2474cd7a --- /dev/null +++ b/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/plugin/plugin.go @@ -0,0 +1,20 @@ +package plugin + +import ( + "context" + "fmt" + + pb "github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin" +) + +type PluginService struct{} + +// Run Implement the interface of grpc +// don't use error to return any info to caller +func (p *PluginService) Run(ctx context.Context, req *pb.Request) (*pb.Response, error) { + // todo: add logic here + return &pb.Response{ + Code: 200, + Msg: "req is " + fmt.Sprintf("%+v", req), + }, nil +} diff --git a/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/go.mod b/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/go.mod new file mode 100644 index 00000000..206792cb --- /dev/null +++ b/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/go.mod @@ -0,0 +1,30 @@ +module github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller + +go 1.17 + +replace ( + github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin => ../my_test_grpc_plugin +) + +require ( + github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin v0.0.0-00010101000000-000000000000 +) + +require ( + github.com/fatih/color v1.7.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/hashicorp/go-hclog v0.14.1 // indirect + github.com/hashicorp/go-plugin v1.4.8 // indirect + github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb // indirect + github.com/mattn/go-colorable v0.1.4 // indirect + github.com/mattn/go-isatty v0.0.10 // indirect + github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 // indirect + github.com/oklog/run v1.0.0 // indirect + golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect + golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect + golang.org/x/text v0.4.0 // indirect + google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect + google.golang.org/grpc v1.51.0 // indirect + google.golang.org/protobuf v1.28.1 // indirect +) diff --git a/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/go.sum b/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/go.sum new file mode 100644 index 00000000..0bddcd94 --- /dev/null +++ b/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/go.sum @@ -0,0 +1,130 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= +github.com/hashicorp/go-hclog v0.14.1 h1:nQcJDQwIAGnmoUWp8ubocEX40cCml/17YkF6csQLReU= +github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= +github.com/hashicorp/go-plugin v1.4.8 h1:CHGwpxYDOttQOY7HOWgETU9dyVjOXzniXDqJcYJE1zM= +github.com/hashicorp/go-plugin v1.4.8/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s= +github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb h1:b5rjCoWHc7eqmAS4/qyk21ZsHyb6Mxv/jykxvNTkU4M= +github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= +github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= +github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10= +github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= +github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 h1:7GoSOOW2jpsfkntVKaS2rAr1TJqfcxotyaUcuxoZSzg= +github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= +github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.51.0 h1:E1eGv1FTqoLIdnBCZufiSHgKjlqG6fKFf6pPWtMTh8U= +google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/debugs_util.go b/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/debugs_util.go new file mode 100644 index 00000000..deb5ff72 --- /dev/null +++ b/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/debugs_util.go @@ -0,0 +1,27 @@ +package loader + +import ( + "fmt" + "runtime" + "strings" +) + +// SourceCodeLoc 获取源码行 +// example: SourceCodeLoc(1) 获取当前代码行的行号 +func SourceCodeLoc(callDepth int) string { + _, file, line, ok := runtime.Caller(callDepth) + if !ok { + return "" + } + file = strings.ReplaceAll(file, "\\", "/") + paths := strings.Split(file, "/") + if len(paths) > 3 { + file = strings.Join(paths[len(paths)-3:], "/") + } + return fmt.Sprintf("%s:%d", file, line) +} + +// WrapError 在错误信息的基础上加上当前行号 +func WrapError(err error, infos ...string) error { + return fmt.Errorf("[%s] %+v, err=%+v", SourceCodeLoc(2), infos, err) +} diff --git a/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/dynamic_plugins.go b/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/dynamic_plugins.go new file mode 100644 index 00000000..03a1023f --- /dev/null +++ b/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/dynamic_plugins.go @@ -0,0 +1,81 @@ +package loader + +import ( + "sync" + "time" + + "github.com/hashicorp/go-plugin" +) + +type ProcessBase struct { + Client *plugin.Client + Protocol plugin.ClientProtocol + Entry interface{} + LastRun int64 +} + +func (p *ProcessBase) Close() { + if p.Protocol != nil { + p.Protocol.Close() + } + p.Entry = nil + p.Protocol = nil + if p.Client != nil { + p.Client.Kill() + p.Client = nil + } +} + +type DynamicPluginsBase struct { + Plugins sync.Map + Lock sync.Mutex +} + +func NewDynamicPlugins() *DynamicPluginsBase { + out := &DynamicPluginsBase{Plugins: sync.Map{}} + go out.autoUnLoad() + return out +} + +const defaultUnloadSeconds = 20 * 60 + +var pluginUnloadSeconds int64 = defaultUnloadSeconds + +func SetPluginUnloadSeconds(seconds int64) { + pluginUnloadSeconds = seconds +} + +func (d *DynamicPluginsBase) autoUnLoad() { + tick := time.NewTicker(time.Duration(pluginUnloadSeconds) * time.Second) + for { + select { + case <-tick.C: + toDelete := make(map[string]interface{}) + d.Plugins.Range(func(key, value interface{}) bool { + p, ok := value.(*ProcessBase) + if !ok { + toDelete[key.(string)] = nil + return true + } + now := time.Now().Unix() + if pluginUnloadSeconds > 0 && now-p.LastRun > pluginUnloadSeconds { + toDelete[key.(string)] = p + return true + } + return true + }) + if len(toDelete) > 0 { + d.Lock.Lock() + for k, v := range toDelete { + p, ok := v.(*ProcessBase) + if ok { + p.Close() + } + d.Plugins.Delete(k) + // log.Println("remove:", k) + } + d.Lock.Unlock() + } + } + } +} diff --git a/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/loader.go b/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/loader.go new file mode 100644 index 00000000..75f7d231 --- /dev/null +++ b/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/loader.go @@ -0,0 +1,74 @@ +package loader + +import ( + "context" + "fmt" + "os" + "os/exec" + "time" + + "github.com/hashicorp/go-plugin" + + pb "github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin" +) + +type Process struct { + *ProcessBase +} + +func (p *Process) Run(ctx context.Context, req *pb.Request) (*pb.Response, error) { + p.LastRun = time.Now().Unix() + service := p.Entry.(pb.MyTestGrpcPluginServer) + return service.Run(ctx, req) +} + +type DynamicPlugins struct { + *DynamicPluginsBase +} + +func NewLoader() *DynamicPlugins { + out := &DynamicPlugins{ + DynamicPluginsBase: NewDynamicPlugins(), + } + return out +} + +func (d *DynamicPlugins) Load(name string, path string) (*Process, error) { + if p, ok := d.Plugins.Load(name); ok { + return p.(*Process), nil + } + if _, err := os.Stat(path); os.IsNotExist(err) { + return nil, fmt.Errorf("[%s]plugin file %s not exists", SourceCodeLoc(1), path) + } + d.Lock.Lock() + defer d.Lock.Unlock() + if p, ok := d.Plugins.Load(name); ok { + return p.(*Process), nil + } + pluginClientConfig := &plugin.ClientConfig{ + HandshakeConfig: pb.Handshake, + Cmd: exec.Command(path), + Plugins: map[string]plugin.Plugin{"main": &pb.GRPC{}}, + AllowedProtocols: []plugin.Protocol{plugin.ProtocolGRPC}, + } + client := plugin.NewClient(pluginClientConfig) + pluginClientConfig.Reattach = client.ReattachConfig() + protocol, err := client.Client() + if err != nil { + return nil, WrapError(err, "start process error") + } + raw, err := protocol.Dispense("main") + if err != nil { + return nil, WrapError(err, "find plugin error") + } + p := &Process{ + ProcessBase: &ProcessBase{ + Client: client, + Protocol: protocol, + Entry: raw, + LastRun: 0, + }, + } + d.Plugins.Store(name, p) + return p, nil +} diff --git a/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/loader_test.go b/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/loader_test.go new file mode 100644 index 00000000..a833162a --- /dev/null +++ b/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/loader_test.go @@ -0,0 +1,74 @@ +package loader + +import ( + "context" + "testing" + "time" + + pb "github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin" +) + +func TestProcess_Run(t *testing.T) { + SetPluginUnloadSeconds(3) + loader := NewLoader() + const pluinPath = "../../my_test_grpc_plugin_callee/my_test_grpc_plugin_callee" + p, err := loader.Load("my_test_grpc_plugins", pluinPath) + if err != nil { + t.Errorf("load error, err=%+v", err) + return + } + rsp, err := p.Run(context.Background(), &pb.Request{ + Field1: 1, + Field2: 2, + Field3: 3, + Field4: "4", + Field5: []byte("5"), + Field6: []string{"6"}, + }) + if err != nil { + t.Errorf("run error, err=%+v", err) + return + } + t.Logf("rsp=%+v", rsp) + { + p1, err1 := loader.Load("my_test_grpc_plugins", "../my_test_grpc_plugin_callee") + if err1 != nil { + t.Errorf("load error, err=%+v", err1) + return + } + rsp1, err1 := p1.Run(context.Background(), &pb.Request{ + Field1: 11, + Field2: 22, + Field3: 33, + Field4: "44", + Field5: []byte("55"), + Field6: []string{"66"}, + }) + if err1 != nil { + t.Errorf("run error, err=%+v", err1) + return + } + t.Logf("rsp=%+v", rsp1) + } + time.Sleep(time.Duration(4) * time.Second) + { + p2, err2 := loader.Load("my_test_grpc_plugins", pluinPath) + if err2 != nil { + t.Errorf("load error, err=%+v", err2) + return + } + rsp2, err2 := p2.Run(context.Background(), &pb.Request{ + Field1: 111, + Field2: 222, + Field3: 333, + Field4: "444", + Field5: []byte("555"), + Field6: []string{"666"}, + }) + if err2 != nil { + t.Errorf("run error, err=%+v", err2) + return + } + t.Logf("rsp=%+v", rsp2) + } +} diff --git a/examples/code_generator/proto/my_test_grpc_plugin.proto b/examples/code_generator/proto/my_test_grpc_plugin.proto new file mode 100644 index 00000000..57c78993 --- /dev/null +++ b/examples/code_generator/proto/my_test_grpc_plugin.proto @@ -0,0 +1,35 @@ +syntax = "proto3"; +package grpc_plugin; +option go_package = "github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin"; + +import "google/protobuf/descriptor.proto"; +//import "github.com/golang/protobuf/descriptor/" +import "github.com/gogo/protobuf/gogoproto/gogo.proto"; + +extend google.protobuf.ServiceOptions { + optional string plugin_name = 51235; +} + +message Request{ + int32 field1 = 1; + int64 field2 = 2; + double field3 = 3; + string field4 = 4; + bytes field5 = 5; + repeated string field6 = 6; +} + +message Response { + int32 code = 1; + string msg = 2; +} + +service MyTestGrpcPlugin{ + option (plugin_name) = "my_plugin_1"; + rpc run(Request) returns (Response); +} + +service MyTestGrpcPluginForAnother{ + option (plugin_name) = "my_plugin_2"; + rpc ProcessData(Request) returns (Response); +} From b551f364ac8ffbba73769cb014c9a6d1a81e1b7a Mon Sep 17 00:00:00 2001 From: "fuchun.zhang" Date: Thu, 15 Dec 2022 11:58:59 +0800 Subject: [PATCH 2/3] add code generator --- examples/code_generator/Makefile | 11 +- examples/code_generator/README.md | 24 ++ examples/code_generator/cmd/Makefile | 6 + examples/code_generator/cmd/code_gen.go | 268 ++++++++++++++++++ examples/code_generator/cmd/go.mod | 14 + examples/code_generator/cmd/go.sum | 128 +++++++++ .../cmd/template_files/callee/callee.go.tpl | 29 ++ .../template_files/callee/callee_test.go.tpl | 59 ++++ .../cmd/template_files/callee/go.mod.tpl | 28 ++ .../callee/plugin/plugin.go.tpl | 20 ++ .../cmd/template_files/go.mod.tpl | 25 ++ .../cmd/template_files/xx.plugin.go.tpl | 62 ++++ .../examples/my_test_grpc_plugin/go.mod | 0 .../examples/my_test_grpc_plugin/go.sum | 0 .../my_test_grpc_plugin.pb.go | 0 .../my_test_grpc_plugin.plugin.go | 0 .../my_test_grpc_plugin_callee/callee.go | 0 .../my_test_grpc_plugin_callee/go.mod | 0 .../my_test_grpc_plugin_callee/go.sum | 0 .../plugin/plugin.go | 0 .../my_test_grpc_plugin_caller/go.mod | 0 .../my_test_grpc_plugin_caller/go.sum | 0 .../loader/debugs_util.go | 0 .../loader/dynamic_plugins.go | 0 .../loader/loader.go | 0 .../loader/loader_test.go | 0 26 files changed, 673 insertions(+), 1 deletion(-) create mode 100644 examples/code_generator/cmd/Makefile create mode 100644 examples/code_generator/cmd/code_gen.go create mode 100644 examples/code_generator/cmd/go.mod create mode 100644 examples/code_generator/cmd/go.sum create mode 100644 examples/code_generator/cmd/template_files/callee/callee.go.tpl create mode 100644 examples/code_generator/cmd/template_files/callee/callee_test.go.tpl create mode 100644 examples/code_generator/cmd/template_files/callee/go.mod.tpl create mode 100644 examples/code_generator/cmd/template_files/callee/plugin/plugin.go.tpl create mode 100644 examples/code_generator/cmd/template_files/go.mod.tpl create mode 100644 examples/code_generator/cmd/template_files/xx.plugin.go.tpl rename examples/code_generator/{ => temp}/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/go.mod (100%) rename examples/code_generator/{ => temp}/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/go.sum (100%) rename examples/code_generator/{ => temp}/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/my_test_grpc_plugin.pb.go (100%) rename examples/code_generator/{ => temp}/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/my_test_grpc_plugin.plugin.go (100%) rename examples/code_generator/{ => temp}/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/callee.go (100%) rename examples/code_generator/{ => temp}/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/go.mod (100%) rename examples/code_generator/{ => temp}/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/go.sum (100%) rename examples/code_generator/{ => temp}/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/plugin/plugin.go (100%) rename examples/code_generator/{ => temp}/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/go.mod (100%) rename examples/code_generator/{ => temp}/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/go.sum (100%) rename examples/code_generator/{ => temp}/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/debugs_util.go (100%) rename examples/code_generator/{ => temp}/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/dynamic_plugins.go (100%) rename examples/code_generator/{ => temp}/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/loader.go (100%) rename examples/code_generator/{ => temp}/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/loader_test.go (100%) diff --git a/examples/code_generator/Makefile b/examples/code_generator/Makefile index 30c7b72f..53955bff 100644 --- a/examples/code_generator/Makefile +++ b/examples/code_generator/Makefile @@ -1,7 +1,16 @@ proto_path="${HOME}/code/" -.PHONY: pb +.PHONY: pb plugin gen pb: protoc -I=. -I=${proto_path} --gogofaster_out=plugins=grpc:. proto/*.proto +code_gen: cmd/code_gen.go cmd/go.mod + cd cmd && make build && cd .. && mv cmd/code_gen ./ + #go mod tidy && go build -o code_gen cmd/code_gen.go + +plugin: + ./code_gen -proto_path=${proto_path} -source_proto=./proto/my_test_grpc_plugin.proto -target_path=./ + +gen: pb code_gen plugin + @echo ok diff --git a/examples/code_generator/README.md b/examples/code_generator/README.md index f4c24b6e..09f6eaf3 100644 --- a/examples/code_generator/README.md +++ b/examples/code_generator/README.md @@ -1,12 +1,21 @@ This is a command tool to generate proto3 to grpc plugin golang source code. # How to use +## 0.install protoc +```shell +brew install protobuf +``` + ## 1.download gogo proto: ```shell mkdir -p ${HOME}/code/github.com/gogo/ cd ${HOME}/code/github.com/gogo/ git clone https://github.com/gogo/protobuf.git ``` +And install protoc plugin of gogo proto: +```shell +go install github.com/gogo/protobuf/protoc-gen-gogo +``` ## 2.add a proto3 idl file: see example: [./proto/my_test_grpc_plugin.proto] @@ -16,3 +25,18 @@ see example: [./proto/my_test_grpc_plugin.proto] ```shell make pb proto_path="${HOME}/code/" ``` + +## 3.generate code +```shell +make gen proto_path="${HOME}/code/" +``` + +see current directory `github.com/...`. + +# Test plugin +```shell +cd examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee +go mod tidy -compat=1.17 && go build +# add code to callee_test.go +go test +``` diff --git a/examples/code_generator/cmd/Makefile b/examples/code_generator/cmd/Makefile new file mode 100644 index 00000000..8cb400ce --- /dev/null +++ b/examples/code_generator/cmd/Makefile @@ -0,0 +1,6 @@ + +build: + go build -o code_gen code_gen.go + +test: + ./code_gen -proto_path=${HOME}/code/ -source_proto=../proto/my_test_grpc_plugin.proto -target_path=./ diff --git a/examples/code_generator/cmd/code_gen.go b/examples/code_generator/cmd/code_gen.go new file mode 100644 index 00000000..e6c7b070 --- /dev/null +++ b/examples/code_generator/cmd/code_gen.go @@ -0,0 +1,268 @@ +package main + +import ( + _ "embed" + "flag" + "fmt" + "log" + "os" + "path/filepath" + "strconv" + "strings" + "text/template" + + proto "github.com/gogo/protobuf/proto" + "github.com/jhump/protoreflect/desc" + "github.com/jhump/protoreflect/desc/protoparse" + "google.golang.org/protobuf/types/descriptorpb" +) + +var ( + targetPath = flag.String("target_path", "./", "-target_path=/path/to/save/go/files") + protoPath = flag.String("proto_path", "", "-proto_path=/path/to/include/proto/files") + sourceProto = flag.String("source_proto", "", "-source_proto=/path/to/one/source/proto/file") +) + +func checkArgs() { + if s, err := os.Stat(*targetPath); os.IsNotExist(err) || !s.IsDir() { + log.Fatalln("target_path not exists(or not a dir): " + *targetPath) + } + if s, err := os.Stat(*protoPath); os.IsNotExist(err) || !s.IsDir() { + log.Fatalln("proto_path not exists(or not a dir): " + *protoPath) + } + if s, err := os.Stat(*sourceProto); os.IsNotExist(err) || s.IsDir() { + log.Fatalln("source_proto not exists(or not a file): " + *sourceProto) + } +} + +func parseFile(protoPath *string, sourceProto *string) *desc.FileDescriptor { + p := protoparse.Parser{ + IncludeSourceCodeInfo: true, + ImportPaths: []string{*protoPath, "."}, + } + fds, err := p.ParseFiles(*sourceProto) + if err != nil { + log.Fatalf("load file [%s] fail, err=%+v", *sourceProto, err) + } + if len(fds) != 1 { + log.Fatalf("load file [%s] fail, count=%d", *sourceProto, len(fds)) + } + return fds[0] +} + +//go:embed template_files/xx.plugin.go.tpl +var templateOfService string + +//go:embed template_files/go.mod.tpl +var templateOfGoMod string + +//go:embed template_files/callee/go.mod.tpl +var templateOfCalleeGoMod string + +//go:embed template_files/callee/callee.go.tpl +var templateOfCalleeDotGo string + +//go:embed template_files/callee/plugin/plugin.go.tpl +var templateOfCalleePluginGo string + +//go:embed template_files/callee/callee_test.go.tpl +var templateOfCalleeTestGo string + +var tService = template.Must(template.New("service").Parse(templateOfService)) +var tGoMod = template.Must(template.New("go.mod").Parse(templateOfGoMod)) +var tCalleeGoMod = template.Must(template.New("callee_go.mod").Parse(templateOfCalleeGoMod)) +var tCalleeDotGo = template.Must(template.New("callee.go").Parse(templateOfCalleeDotGo)) +var tCalleePluginGo = template.Must(template.New("callee_plugin.go").Parse(templateOfCalleePluginGo)) +var tCalleeTestGo = template.Must(template.New("callee_test.go").Parse(templateOfCalleeTestGo)) + +func createFile(p string) *os.File { + out, err := os.OpenFile(p, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, os.ModePerm) + if err != nil { + log.Fatalf("create file [%s] fail, err=%s", p, err.Error()) + } + return out +} + +func getMethodOfService(s *desc.ServiceDescriptor) []Method { + out := make([]Method, 0, len(s.GetMethods())) + for _, m := range s.GetMethods() { + out = append(out, Method{ + Name: makeFirstLetterUpperCase(m.GetName()), + InputType: m.GetInputType().GetName(), + OutputType: m.GetOutputType().GetName(), + }) + } + return out +} + +func makeFirstLetterUpperCase(s string) string { + return strings.ToUpper(s[:1]) + s[1:] +} + +func getServiceOptionOfPluginName(service *desc.ServiceDescriptor) string { + opt, ok := service.GetOptions().(*descriptorpb.ServiceOptions) + if !ok { + return service.GetName() + } + prefix := strconv.Itoa(int(E_PluginName.Field)) + ":" + if strings.HasPrefix(opt.String(), prefix) { + s := opt.String()[len(prefix):] + if s[0] == '"' { + s = s[1:] + } + if s[len(s)-1] == '"' { + s = s[:len(s)-1] + } + return s + } + return service.GetName() +} + +func getServiceInfo(pbFile *desc.FileDescriptor) []Service { + out := make([]Service, 0, len(pbFile.GetServices())) + for _, service := range pbFile.GetServices() { + // if proto.HasExtension(service.GetServiceOptions(), E_PluginName) { + // opt1, err := proto.GetExtension(service.GetServiceOptions(), E_PluginName) + // if err != nil { + // log.Fatalln("GetExtension error, err=", err) + // } + // log.Printf("opt1=%+v", opt1) + // } else { + // log.Println("HasExtension fail") + // } + out = append(out, Service{ + Name: service.GetName(), + PluginName: getServiceOptionOfPluginName(service), + Methods: getMethodOfService(service), + }) + } + return out +} + +type Method struct { + Name string + InputType string + OutputType string +} + +type Service struct { + Name string + PluginName string + Methods []Method +} + +type pbStruct struct { + Package string + FullPackagePath string + Services []Service +} + +var E_PluginName = &proto.ExtensionDesc{ + ExtendedType: (*descriptorpb.ServiceOptions)(nil), + ExtensionType: (*string)(nil), + Field: 51235, + Name: "grpc_plugin.plugin_name", + Tag: "bytes,51235,opt,name=plugin_name", + Filename: "proto/my_test_grpc_plugin.proto", +} + +func genPluginFile(fullPath string, pbFile *desc.FileDescriptor, st *pbStruct) { + packageName := filepath.Base(fullPath) + mainFile := createFile(filepath.Join(fullPath, fmt.Sprintf("%s.plugin.go", strings.ToLower(packageName)))) + defer mainFile.Close() + // st := &pbStruct{ + // Package: packageName, + // Services: getServiceInfo(pbFile), + // } + err := tService.Execute(mainFile, st) + if err != nil { + log.Fatalf("write xx.plugin.go fail:%+v", err) + } + // go.mod + goModFile := createFile(filepath.Join(fullPath, "go.mod")) + defer goModFile.Close() + err = tGoMod.Execute(goModFile, map[string]string{ + "FullPackagePath": *pbFile.GetFileOptions().GoPackage, + }) + if err != nil { + log.Fatalf("write go.mod fail:%+v", err) + } +} + +func mkdirs(d string) { + if _, err := os.Stat(d); os.IsNotExist(err) { + if err = os.MkdirAll(d, os.ModePerm); err != nil { + log.Fatalf("create dir [%s] fail, err=%s", d, err.Error()) + } + } +} + +func genCalleeFile(fullPath string, pbFile *desc.FileDescriptor, st *pbStruct) { + calleePath := fullPath + "_callee" + mkdirs(calleePath) + // go.mod + { + goModFile := createFile(filepath.Join(calleePath, "go.mod")) + defer goModFile.Close() + err := tCalleeGoMod.Execute(goModFile, st) + if err != nil { + log.Fatalf("write callee go.mod fail:%+v", err) + } + } + // callee.go + { + calleeGoFile := createFile(filepath.Join(calleePath, "callee.go")) + defer calleeGoFile.Close() + err := tCalleeDotGo.Execute(calleeGoFile, st) + if err != nil { + log.Fatalf("write callee/callee.go fail:%+v", err) + } + } + // callee_test.go + { + calleeTestFile := createFile(filepath.Join(calleePath, "callee_test.go")) + defer calleeTestFile.Close() + err := tCalleeTestGo.Execute(calleeTestFile, st) + if err != nil { + log.Fatalf("write callee/callee_test.go fail:%+v", err) + } + } + // plugin/ + pluginPath := calleePath + "/plugin" + mkdirs(pluginPath) + { + calleePluginGoFile := createFile(filepath.Join(pluginPath, "plugin.go")) + defer calleePluginGoFile.Close() + err := tCalleePluginGo.Execute(calleePluginGoFile, st) + if err != nil { + log.Fatalf("write callee/plugin/plugin.go fail:%+v", err) + } + } + +} + +func main() { + log.SetFlags(log.LstdFlags | log.Lshortfile) + flag.Parse() + checkArgs() + pbFile := parseFile(protoPath, sourceProto) + // log.Println(*pbFile.GetFileOptions().GoPackage) + fullPath := filepath.Join(*targetPath, *pbFile.GetFileOptions().GoPackage) + if _, err := os.Stat(fullPath); os.IsNotExist(err) { + log.Println("mkdir:", fullPath) + if err = os.MkdirAll(fullPath, os.ModePerm); err != nil { + log.Fatalln("mkdir fail: err=", err.Error()) + } + } + // goFilePath := filepath.Dir(fullPath) + // log.Println(goFilePath) + log.Println(fullPath) + packageName := filepath.Base(fullPath) + st := &pbStruct{ + Package: packageName, + FullPackagePath: *pbFile.GetFileOptions().GoPackage, + Services: getServiceInfo(pbFile), + } + genPluginFile(fullPath, pbFile, st) + genCalleeFile(fullPath, pbFile, st) +} diff --git a/examples/code_generator/cmd/go.mod b/examples/code_generator/cmd/go.mod new file mode 100644 index 00000000..2e525ae8 --- /dev/null +++ b/examples/code_generator/cmd/go.mod @@ -0,0 +1,14 @@ +module github.com/hashicorp/go-plugin/examples/code_generator + +go 1.17 + +require ( + github.com/gogo/protobuf v1.3.2 + github.com/jhump/protoreflect v1.14.0 + google.golang.org/protobuf v1.26.0 +) + +require ( + github.com/golang/protobuf v1.5.0 // indirect + google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect +) diff --git a/examples/code_generator/cmd/go.sum b/examples/code_generator/cmd/go.sum new file mode 100644 index 00000000..df1d2619 --- /dev/null +++ b/examples/code_generator/cmd/go.sum @@ -0,0 +1,128 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0 h1:LUVKkCeviFUMKqHa4tXIIij/lbhnMbP7Fn5wKdKkRh4= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/jhump/gopoet v0.0.0-20190322174617-17282ff210b3/go.mod h1:me9yfT6IJSlOL3FCfrg+L6yzUEZ+5jW6WHt4Sk+UPUI= +github.com/jhump/gopoet v0.1.0/go.mod h1:me9yfT6IJSlOL3FCfrg+L6yzUEZ+5jW6WHt4Sk+UPUI= +github.com/jhump/goprotoc v0.5.0/go.mod h1:VrbvcYrQOrTi3i0Vf+m+oqQWk9l72mjkJCYo7UvLHRQ= +github.com/jhump/protoreflect v1.11.0/go.mod h1:U7aMIjN0NWq9swDP7xDdoMfRHb35uiuTd3Z9nFXJf5E= +github.com/jhump/protoreflect v1.14.0 h1:MBbQK392K3u8NTLbKOCIi3XdI+y+c6yt5oMq0X3xviw= +github.com/jhump/protoreflect v1.14.0/go.mod h1:JytZfP5d0r8pVNLZvai7U/MCuTWITgrI4tTg7puQFKI= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.38.0 h1:/9BgsAsa5nWe26HqOlvlgJnqBuktYOLCgjCPqsa56W0= +google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/examples/code_generator/cmd/template_files/callee/callee.go.tpl b/examples/code_generator/cmd/template_files/callee/callee.go.tpl new file mode 100644 index 00000000..89c7ac27 --- /dev/null +++ b/examples/code_generator/cmd/template_files/callee/callee.go.tpl @@ -0,0 +1,29 @@ +package main + +import ( + "runtime" + + "github.com/hashicorp/go-plugin" + + pb "{{.FullPackagePath}}" + + imp "{{.FullPackagePath}}_callee/plugin" +) + +func StartPluginCallee() { + plugin.Serve(&plugin.ServeConfig{ + HandshakeConfig: pb.Handshake, + Plugins: map[string]plugin.Plugin{ +{{- range $item := .Services }} + "{{.PluginName}}": &pb.GRPC{{.Name}}{Impl: &imp.{{.Name}}Service{}}, +{{- end }} + }, + // A non-nil value here enables gRPC serving for this plugin... + GRPCServer: plugin.DefaultGRPCServer, + }) +} + +func main() { + runtime.GOMAXPROCS(1) + StartPluginCallee() +} diff --git a/examples/code_generator/cmd/template_files/callee/callee_test.go.tpl b/examples/code_generator/cmd/template_files/callee/callee_test.go.tpl new file mode 100644 index 00000000..b1267db4 --- /dev/null +++ b/examples/code_generator/cmd/template_files/callee/callee_test.go.tpl @@ -0,0 +1,59 @@ +package main + +import ( + "context" + "os/exec" + "testing" + + "github.com/hashicorp/go-plugin" + + pb "{{.FullPackagePath}}" +) + +func Test_Callee(t *testing.T) { + path := "./{{.Package}}_callee" // todo: `go build` first + pluginClientConfig := &plugin.ClientConfig{ + HandshakeConfig: pb.Handshake, + Cmd: exec.Command(path), + Plugins: map[string]plugin.Plugin{ + +{{- range $item := .Services }} + "{{.PluginName}}": &pb.GRPC{{.Name}}{}, +{{- end }} + }, + AllowedProtocols: []plugin.Protocol{plugin.ProtocolGRPC}, + } + client := plugin.NewClient(pluginClientConfig) + pluginClientConfig.Reattach = client.ReattachConfig() + protocol, err := client.Client() + if err != nil { + t.Errorf("new client error, err=%+v", err) + return + } +{{- range $item := .Services }} + { + raw, err := protocol.Dispense("{{.PluginName}}") + if err != nil { + t.Errorf("PluginName {{.PluginName}} error, err=%+v", err) + return + } + inst, ok := raw.(pb.{{.Name}}Server) + if !ok { + t.Errorf("interface type error") + return + } + // test each method +{{$CurService := .Name}} +{{- range $item := .Methods }} + { + rsp, err := inst.{{.Name}}(context.Background(), &pb.{{.InputType}}{/*todo: add param here*/}) + if err != nil { + t.Errorf("run error, err=%+v", err) + return + } + t.Logf("rsp=%+v", rsp) + } +{{- end }} + } +{{- end }} +} diff --git a/examples/code_generator/cmd/template_files/callee/go.mod.tpl b/examples/code_generator/cmd/template_files/callee/go.mod.tpl new file mode 100644 index 00000000..77c9d54d --- /dev/null +++ b/examples/code_generator/cmd/template_files/callee/go.mod.tpl @@ -0,0 +1,28 @@ +module {{.FullPackagePath}}_callee + +go 1.17 + +replace {{.FullPackagePath}} => ../{{.Package}} + +require ( + github.com/hashicorp/go-plugin v1.4.8 + {{.FullPackagePath}} v0.0.0-00010101000000-000000000000 +) + +require ( + github.com/fatih/color v1.7.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/hashicorp/go-hclog v0.14.1 // indirect + github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb // indirect + github.com/mattn/go-colorable v0.1.4 // indirect + github.com/mattn/go-isatty v0.0.10 // indirect + github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 // indirect + github.com/oklog/run v1.0.0 // indirect + golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect + golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect + golang.org/x/text v0.4.0 // indirect + google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect + google.golang.org/grpc v1.51.0 // indirect + google.golang.org/protobuf v1.28.1 // indirect +) diff --git a/examples/code_generator/cmd/template_files/callee/plugin/plugin.go.tpl b/examples/code_generator/cmd/template_files/callee/plugin/plugin.go.tpl new file mode 100644 index 00000000..4a4b64b3 --- /dev/null +++ b/examples/code_generator/cmd/template_files/callee/plugin/plugin.go.tpl @@ -0,0 +1,20 @@ +package plugin + +import ( + pb "{{.FullPackagePath}}" +) + +{{- range $item := .Services }} + +type {{.Name}}Service struct{} + +{{$CurService := .Name}} +{{- range $item := .Methods }} +// {{.Name}} Implement the interface of grpc +// don't use error to return any info to caller +func (p *{{$CurService}}Service) {{.Name}}(req *pb.{{.InputType}}) *pb.{{.OutputType}} { + // todo: add logic here + return &pb.Response{} +} +{{- end }} +{{- end }} diff --git a/examples/code_generator/cmd/template_files/go.mod.tpl b/examples/code_generator/cmd/template_files/go.mod.tpl new file mode 100644 index 00000000..c2942a4f --- /dev/null +++ b/examples/code_generator/cmd/template_files/go.mod.tpl @@ -0,0 +1,25 @@ +module {{.FullPackagePath}} + +go 1.17 + +require ( + github.com/gogo/protobuf v1.3.2 + github.com/hashicorp/go-plugin v1.4.8 + google.golang.org/grpc v1.51.0 + google.golang.org/protobuf v1.28.1 +) + +require ( + github.com/fatih/color v1.7.0 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/hashicorp/go-hclog v0.14.1 // indirect + github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb // indirect + github.com/mattn/go-colorable v0.1.4 // indirect + github.com/mattn/go-isatty v0.0.10 // indirect + github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 // indirect + github.com/oklog/run v1.0.0 // indirect + golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect + golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect + golang.org/x/text v0.4.0 // indirect + google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect +) diff --git a/examples/code_generator/cmd/template_files/xx.plugin.go.tpl b/examples/code_generator/cmd/template_files/xx.plugin.go.tpl new file mode 100644 index 00000000..3251e4d2 --- /dev/null +++ b/examples/code_generator/cmd/template_files/xx.plugin.go.tpl @@ -0,0 +1,62 @@ +package {{.Package}} + +import ( + "context" + + "github.com/hashicorp/go-plugin" + + "google.golang.org/grpc" +) + +var Handshake = plugin.HandshakeConfig{ + ProtocolVersion: 1, + MagicCookieKey: "BASIC_PLUGIN", + MagicCookieValue: "hello", +} + +{{- range $item := .Services }} + +type {{.Name}}Plugin interface{ +{{$CurService := .Name}} +{{- range $item := .Methods }} + {{.Name}}(req *{{.InputType}}) *{{.OutputType}} +{{- end }} +} + +type GRPC{{.Name}} struct { + plugin.Plugin + Impl {{.Name}}Plugin +} + +func (p *GRPC{{.Name}}) GRPCServer(broker *plugin.GRPCBroker, server *grpc.Server) error { + Register{{.Name}}Server(server, &GPRC{{.Name}}ServerWrapper{impl: p.Impl}) + return nil +} + +func (p *GRPC{{.Name}}) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, conn *grpc.ClientConn) (interface{}, error) { + return &GRPC{{.Name}}ClientWrapper{client: New{{.Name}}Client(conn)}, nil +} + +type GPRC{{.Name}}ServerWrapper struct { + impl {{.Name}}Plugin + Unimplemented{{.Name}}Server +} + +{{$CurService := .Name}} +{{- range $item := .Methods }} +func (g *GPRC{{$CurService}}ServerWrapper) {{.Name}}(ctx context.Context, req *{{.InputType}}) (*{{.OutputType}}, error) { + return g.impl.{{.Name}}(req), nil +} +{{- end }} + +type GRPC{{.Name}}ClientWrapper struct { + client {{.Name}}Client +} + +{{- range $item := .Methods }} +func (g *GRPC{{$CurService}}ClientWrapper) {{.Name}}(ctx context.Context, req *{{.InputType}}) (*{{.OutputType}}, error) { + return g.client.{{.Name}}(ctx, req) +} +{{- end }} + +{{- end }} diff --git a/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/go.mod b/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/go.mod similarity index 100% rename from examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/go.mod rename to examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/go.mod diff --git a/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/go.sum b/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/go.sum similarity index 100% rename from examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/go.sum rename to examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/go.sum diff --git a/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/my_test_grpc_plugin.pb.go b/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/my_test_grpc_plugin.pb.go similarity index 100% rename from examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/my_test_grpc_plugin.pb.go rename to examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/my_test_grpc_plugin.pb.go diff --git a/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/my_test_grpc_plugin.plugin.go b/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/my_test_grpc_plugin.plugin.go similarity index 100% rename from examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/my_test_grpc_plugin.plugin.go rename to examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/my_test_grpc_plugin.plugin.go diff --git a/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/callee.go b/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/callee.go similarity index 100% rename from examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/callee.go rename to examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/callee.go diff --git a/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/go.mod b/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/go.mod similarity index 100% rename from examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/go.mod rename to examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/go.mod diff --git a/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/go.sum b/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/go.sum similarity index 100% rename from examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/go.sum rename to examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/go.sum diff --git a/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/plugin/plugin.go b/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/plugin/plugin.go similarity index 100% rename from examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/plugin/plugin.go rename to examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/plugin/plugin.go diff --git a/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/go.mod b/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/go.mod similarity index 100% rename from examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/go.mod rename to examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/go.mod diff --git a/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/go.sum b/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/go.sum similarity index 100% rename from examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/go.sum rename to examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/go.sum diff --git a/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/debugs_util.go b/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/debugs_util.go similarity index 100% rename from examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/debugs_util.go rename to examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/debugs_util.go diff --git a/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/dynamic_plugins.go b/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/dynamic_plugins.go similarity index 100% rename from examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/dynamic_plugins.go rename to examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/dynamic_plugins.go diff --git a/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/loader.go b/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/loader.go similarity index 100% rename from examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/loader.go rename to examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/loader.go diff --git a/examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/loader_test.go b/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/loader_test.go similarity index 100% rename from examples/code_generator/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/loader_test.go rename to examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/loader_test.go From 2bac292fe404868e381c60c5d3028f1614716d8b Mon Sep 17 00:00:00 2001 From: "fuchun.zhang" Date: Thu, 15 Dec 2022 12:18:17 +0800 Subject: [PATCH 3/3] add code generator for grpc plugins --- examples/code_generator/README.md | 3 + examples/code_generator/cmd/code_gen.go | 69 +- .../callee/plugin/plugin.go.tpl | 1 - .../proto/my_test_grpc_plugin.proto | 1 - .../examples/my_test_grpc_plugin/go.mod | 25 - .../examples/my_test_grpc_plugin/go.sum | 130 --- .../my_test_grpc_plugin.pb.go | 911 ------------------ .../my_test_grpc_plugin.plugin.go | 46 - .../my_test_grpc_plugin_callee/callee.go | 27 - .../my_test_grpc_plugin_callee/go.mod | 26 - .../my_test_grpc_plugin_callee/go.sum | 130 --- .../plugin/plugin.go | 20 - .../my_test_grpc_plugin_caller/go.mod | 30 - .../my_test_grpc_plugin_caller/go.sum | 130 --- .../loader/debugs_util.go | 27 - .../loader/dynamic_plugins.go | 81 -- .../loader/loader.go | 74 -- .../loader/loader_test.go | 74 -- 18 files changed, 39 insertions(+), 1766 deletions(-) delete mode 100644 examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/go.mod delete mode 100644 examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/go.sum delete mode 100644 examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/my_test_grpc_plugin.pb.go delete mode 100644 examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/my_test_grpc_plugin.plugin.go delete mode 100644 examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/callee.go delete mode 100644 examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/go.mod delete mode 100644 examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/go.sum delete mode 100644 examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/plugin/plugin.go delete mode 100644 examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/go.mod delete mode 100644 examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/go.sum delete mode 100644 examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/debugs_util.go delete mode 100644 examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/dynamic_plugins.go delete mode 100644 examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/loader.go delete mode 100644 examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/loader_test.go diff --git a/examples/code_generator/README.md b/examples/code_generator/README.md index 09f6eaf3..cd5465fd 100644 --- a/examples/code_generator/README.md +++ b/examples/code_generator/README.md @@ -21,6 +21,9 @@ go install github.com/gogo/protobuf/protoc-gen-gogo see example: [./proto/my_test_grpc_plugin.proto] * define Request and Response message format * define a service + - use extension to add a plugin name: + - `option (plugin_name) = "my_plugin_1";` + - It will use service name when plugin name not set * use protoc to generate XX.pb.go files ```shell make pb proto_path="${HOME}/code/" diff --git a/examples/code_generator/cmd/code_gen.go b/examples/code_generator/cmd/code_gen.go index e6c7b070..d67b357a 100644 --- a/examples/code_generator/cmd/code_gen.go +++ b/examples/code_generator/cmd/code_gen.go @@ -7,11 +7,10 @@ import ( "log" "os" "path/filepath" - "strconv" + "regexp" "strings" "text/template" - proto "github.com/gogo/protobuf/proto" "github.com/jhump/protoreflect/desc" "github.com/jhump/protoreflect/desc/protoparse" "google.golang.org/protobuf/types/descriptorpb" @@ -99,37 +98,45 @@ func makeFirstLetterUpperCase(s string) string { return strings.ToUpper(s[:1]) + s[1:] } +var pluginNameRE = regexp.MustCompile(`\d+:["]?([^"]+)["]?`) + +func parsePluginName(s string) string { + arr := pluginNameRE.FindAllStringSubmatch(s, -1) + if len(arr) == 0 { + return "" + } + if len(arr[0]) < 2 { + return "" + } + return arr[0][1] +} + func getServiceOptionOfPluginName(service *desc.ServiceDescriptor) string { opt, ok := service.GetOptions().(*descriptorpb.ServiceOptions) if !ok { return service.GetName() } - prefix := strconv.Itoa(int(E_PluginName.Field)) + ":" - if strings.HasPrefix(opt.String(), prefix) { - s := opt.String()[len(prefix):] - if s[0] == '"' { - s = s[1:] - } - if s[len(s)-1] == '"' { - s = s[:len(s)-1] - } - return s + pluginName := parsePluginName(opt.String()) + if len(pluginName) > 0 { + return pluginName } + // prefix := strconv.Itoa(int(E_PluginName.Field)) + ":" + // if strings.HasPrefix(opt.String(), prefix) { + // s := opt.String()[len(prefix):] + // if s[0] == '"' { + // s = s[1:] + // } + // if s[len(s)-1] == '"' { + // s = s[:len(s)-1] + // } + // return s + // } return service.GetName() } func getServiceInfo(pbFile *desc.FileDescriptor) []Service { out := make([]Service, 0, len(pbFile.GetServices())) for _, service := range pbFile.GetServices() { - // if proto.HasExtension(service.GetServiceOptions(), E_PluginName) { - // opt1, err := proto.GetExtension(service.GetServiceOptions(), E_PluginName) - // if err != nil { - // log.Fatalln("GetExtension error, err=", err) - // } - // log.Printf("opt1=%+v", opt1) - // } else { - // log.Println("HasExtension fail") - // } out = append(out, Service{ Name: service.GetName(), PluginName: getServiceOptionOfPluginName(service), @@ -157,23 +164,19 @@ type pbStruct struct { Services []Service } -var E_PluginName = &proto.ExtensionDesc{ - ExtendedType: (*descriptorpb.ServiceOptions)(nil), - ExtensionType: (*string)(nil), - Field: 51235, - Name: "grpc_plugin.plugin_name", - Tag: "bytes,51235,opt,name=plugin_name", - Filename: "proto/my_test_grpc_plugin.proto", -} +// var E_PluginName = &proto.ExtensionDesc{ +// ExtendedType: (*descriptorpb.ServiceOptions)(nil), +// ExtensionType: (*string)(nil), +// Field: 51235, +// Name: "grpc_plugin.plugin_name", +// Tag: "bytes,51235,opt,name=plugin_name", +// Filename: "proto/my_test_grpc_plugin.proto", +// } func genPluginFile(fullPath string, pbFile *desc.FileDescriptor, st *pbStruct) { packageName := filepath.Base(fullPath) mainFile := createFile(filepath.Join(fullPath, fmt.Sprintf("%s.plugin.go", strings.ToLower(packageName)))) defer mainFile.Close() - // st := &pbStruct{ - // Package: packageName, - // Services: getServiceInfo(pbFile), - // } err := tService.Execute(mainFile, st) if err != nil { log.Fatalf("write xx.plugin.go fail:%+v", err) diff --git a/examples/code_generator/cmd/template_files/callee/plugin/plugin.go.tpl b/examples/code_generator/cmd/template_files/callee/plugin/plugin.go.tpl index 4a4b64b3..588fe9ec 100644 --- a/examples/code_generator/cmd/template_files/callee/plugin/plugin.go.tpl +++ b/examples/code_generator/cmd/template_files/callee/plugin/plugin.go.tpl @@ -11,7 +11,6 @@ type {{.Name}}Service struct{} {{$CurService := .Name}} {{- range $item := .Methods }} // {{.Name}} Implement the interface of grpc -// don't use error to return any info to caller func (p *{{$CurService}}Service) {{.Name}}(req *pb.{{.InputType}}) *pb.{{.OutputType}} { // todo: add logic here return &pb.Response{} diff --git a/examples/code_generator/proto/my_test_grpc_plugin.proto b/examples/code_generator/proto/my_test_grpc_plugin.proto index 57c78993..f4bce303 100644 --- a/examples/code_generator/proto/my_test_grpc_plugin.proto +++ b/examples/code_generator/proto/my_test_grpc_plugin.proto @@ -3,7 +3,6 @@ package grpc_plugin; option go_package = "github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin"; import "google/protobuf/descriptor.proto"; -//import "github.com/golang/protobuf/descriptor/" import "github.com/gogo/protobuf/gogoproto/gogo.proto"; extend google.protobuf.ServiceOptions { diff --git a/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/go.mod b/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/go.mod deleted file mode 100644 index 86225141..00000000 --- a/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/go.mod +++ /dev/null @@ -1,25 +0,0 @@ -module github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin - -go 1.17 - -require ( - github.com/gogo/protobuf v1.3.2 - github.com/hashicorp/go-plugin v1.4.8 - google.golang.org/grpc v1.51.0 - google.golang.org/protobuf v1.28.1 -) - -require ( - github.com/fatih/color v1.7.0 // indirect - github.com/golang/protobuf v1.5.2 // indirect - github.com/hashicorp/go-hclog v0.14.1 // indirect - github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb // indirect - github.com/mattn/go-colorable v0.1.4 // indirect - github.com/mattn/go-isatty v0.0.10 // indirect - github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 // indirect - github.com/oklog/run v1.0.0 // indirect - golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect - golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect - golang.org/x/text v0.4.0 // indirect - google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect -) diff --git a/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/go.sum b/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/go.sum deleted file mode 100644 index 0bddcd94..00000000 --- a/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/go.sum +++ /dev/null @@ -1,130 +0,0 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= -github.com/hashicorp/go-hclog v0.14.1 h1:nQcJDQwIAGnmoUWp8ubocEX40cCml/17YkF6csQLReU= -github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-plugin v1.4.8 h1:CHGwpxYDOttQOY7HOWgETU9dyVjOXzniXDqJcYJE1zM= -github.com/hashicorp/go-plugin v1.4.8/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s= -github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb h1:b5rjCoWHc7eqmAS4/qyk21ZsHyb6Mxv/jykxvNTkU4M= -github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= -github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= -github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10= -github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= -github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 h1:7GoSOOW2jpsfkntVKaS2rAr1TJqfcxotyaUcuxoZSzg= -github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= -github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.51.0 h1:E1eGv1FTqoLIdnBCZufiSHgKjlqG6fKFf6pPWtMTh8U= -google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/my_test_grpc_plugin.pb.go b/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/my_test_grpc_plugin.pb.go deleted file mode 100644 index 21241549..00000000 --- a/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/my_test_grpc_plugin.pb.go +++ /dev/null @@ -1,911 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: proto/my_test_grpc_plugin.proto - -package my_test_grpc_plugin - -import ( - context "context" - encoding_binary "encoding/binary" - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - descriptorpb "google.golang.org/protobuf/types/descriptorpb" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type Request struct { - Field1 int32 `protobuf:"varint,1,opt,name=field1,proto3" json:"field1,omitempty"` - Field2 int64 `protobuf:"varint,2,opt,name=field2,proto3" json:"field2,omitempty"` - Field3 float64 `protobuf:"fixed64,3,opt,name=field3,proto3" json:"field3,omitempty"` - Field4 string `protobuf:"bytes,4,opt,name=field4,proto3" json:"field4,omitempty"` - Field5 []byte `protobuf:"bytes,5,opt,name=field5,proto3" json:"field5,omitempty"` - Field6 []string `protobuf:"bytes,6,rep,name=field6,proto3" json:"field6,omitempty"` -} - -func (m *Request) Reset() { *m = Request{} } -func (m *Request) String() string { return proto.CompactTextString(m) } -func (*Request) ProtoMessage() {} -func (*Request) Descriptor() ([]byte, []int) { - return fileDescriptor_0b06b1e5fa595b1e, []int{0} -} -func (m *Request) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Request) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Request.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Request) XXX_Merge(src proto.Message) { - xxx_messageInfo_Request.Merge(m, src) -} -func (m *Request) XXX_Size() int { - return m.Size() -} -func (m *Request) XXX_DiscardUnknown() { - xxx_messageInfo_Request.DiscardUnknown(m) -} - -var xxx_messageInfo_Request proto.InternalMessageInfo - -func (m *Request) GetField1() int32 { - if m != nil { - return m.Field1 - } - return 0 -} - -func (m *Request) GetField2() int64 { - if m != nil { - return m.Field2 - } - return 0 -} - -func (m *Request) GetField3() float64 { - if m != nil { - return m.Field3 - } - return 0 -} - -func (m *Request) GetField4() string { - if m != nil { - return m.Field4 - } - return "" -} - -func (m *Request) GetField5() []byte { - if m != nil { - return m.Field5 - } - return nil -} - -func (m *Request) GetField6() []string { - if m != nil { - return m.Field6 - } - return nil -} - -type Response struct { - Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` - Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` -} - -func (m *Response) Reset() { *m = Response{} } -func (m *Response) String() string { return proto.CompactTextString(m) } -func (*Response) ProtoMessage() {} -func (*Response) Descriptor() ([]byte, []int) { - return fileDescriptor_0b06b1e5fa595b1e, []int{1} -} -func (m *Response) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Response.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Response) XXX_Merge(src proto.Message) { - xxx_messageInfo_Response.Merge(m, src) -} -func (m *Response) XXX_Size() int { - return m.Size() -} -func (m *Response) XXX_DiscardUnknown() { - xxx_messageInfo_Response.DiscardUnknown(m) -} - -var xxx_messageInfo_Response proto.InternalMessageInfo - -func (m *Response) GetCode() int32 { - if m != nil { - return m.Code - } - return 0 -} - -func (m *Response) GetMsg() string { - if m != nil { - return m.Msg - } - return "" -} - -var E_PluginName = &proto.ExtensionDesc{ - ExtendedType: (*descriptorpb.ServiceOptions)(nil), - ExtensionType: (*string)(nil), - Field: 51235, - Name: "grpc_plugin.plugin_name", - Tag: "bytes,51235,opt,name=plugin_name", - Filename: "proto/my_test_grpc_plugin.proto", -} - -func init() { - proto.RegisterType((*Request)(nil), "grpc_plugin.Request") - proto.RegisterType((*Response)(nil), "grpc_plugin.Response") - proto.RegisterExtension(E_PluginName) -} - -func init() { proto.RegisterFile("proto/my_test_grpc_plugin.proto", fileDescriptor_0b06b1e5fa595b1e) } - -var fileDescriptor_0b06b1e5fa595b1e = []byte{ - // 418 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xbf, 0x6f, 0xd4, 0x30, - 0x14, 0xc7, 0xcf, 0xa4, 0x3d, 0xa8, 0x0f, 0x89, 0xca, 0x02, 0x14, 0x32, 0xa4, 0x51, 0xa7, 0x2c, - 0x4d, 0x68, 0xae, 0xed, 0x50, 0x26, 0x10, 0x3f, 0x26, 0xa0, 0x0a, 0x20, 0x10, 0x4b, 0x94, 0xf3, - 0xbd, 0x3a, 0x91, 0x92, 0x3c, 0x63, 0x3b, 0x88, 0x5b, 0x99, 0x18, 0xbb, 0xc2, 0xca, 0x3f, 0xc3, - 0xd8, 0x91, 0x11, 0xdd, 0xfd, 0x23, 0xe8, 0x12, 0x13, 0x4e, 0x15, 0x0b, 0xdb, 0xf3, 0xc7, 0x5f, - 0xfb, 0xfb, 0x7e, 0xd1, 0x3d, 0xa9, 0xd0, 0x60, 0x5c, 0x2f, 0x32, 0x03, 0xda, 0x64, 0x42, 0x49, - 0x9e, 0xc9, 0xaa, 0x15, 0x65, 0x13, 0x75, 0x37, 0x6c, 0xb2, 0x81, 0xbc, 0x40, 0x20, 0x8a, 0x0a, - 0xe2, 0xee, 0x6a, 0xd6, 0x9e, 0xc7, 0x73, 0xd0, 0x5c, 0x95, 0xd2, 0xa0, 0xea, 0xe5, 0xde, 0x81, - 0x28, 0x4d, 0xd1, 0xce, 0x22, 0x8e, 0x75, 0x2c, 0x50, 0xe0, 0x5f, 0xe9, 0xfa, 0xd4, 0x9b, 0xad, - 0xa3, 0x5e, 0xbe, 0xff, 0x95, 0xd0, 0xeb, 0x29, 0x7c, 0x68, 0x41, 0x1b, 0x76, 0x97, 0x8e, 0xcf, - 0x4b, 0xa8, 0xe6, 0x87, 0x2e, 0x09, 0x48, 0xb8, 0x9d, 0xda, 0xd3, 0xc0, 0x13, 0xf7, 0x5a, 0x40, - 0x42, 0xc7, 0xf2, 0x64, 0xe0, 0x53, 0xd7, 0x09, 0x48, 0x48, 0x2c, 0x9f, 0x0e, 0xfc, 0xc8, 0xdd, - 0x0a, 0x48, 0xb8, 0x63, 0xf9, 0xd1, 0xc0, 0x8f, 0xdd, 0xed, 0x80, 0x84, 0x37, 0x2d, 0x3f, 0x1e, - 0xf8, 0x89, 0x3b, 0x0e, 0x9c, 0x41, 0x7f, 0xb2, 0x7f, 0x9f, 0xde, 0x48, 0x41, 0x4b, 0x6c, 0x34, - 0x30, 0x46, 0xb7, 0x38, 0xce, 0xc1, 0x66, 0xd6, 0xc5, 0x6c, 0x97, 0x3a, 0xb5, 0x16, 0x5d, 0x52, - 0x3b, 0xe9, 0x3a, 0x4c, 0xde, 0xd2, 0xdd, 0xe7, 0x8b, 0xd7, 0xa0, 0xcd, 0x33, 0x25, 0xf9, 0x59, - 0xd7, 0x32, 0x96, 0x50, 0x47, 0xb5, 0x0d, 0xbb, 0x1d, 0x6d, 0xb6, 0xd6, 0x96, 0xec, 0xdd, 0xb9, - 0x42, 0x7b, 0x37, 0xef, 0xd6, 0xb7, 0xcf, 0xf7, 0x26, 0xf5, 0xc2, 0xf2, 0xec, 0x30, 0x79, 0x47, - 0xbd, 0xab, 0x1f, 0x3f, 0x45, 0xf5, 0xb0, 0x41, 0x53, 0x80, 0x62, 0xa7, 0x74, 0x72, 0xa6, 0x90, - 0x83, 0xd6, 0x8f, 0x73, 0x93, 0xff, 0x97, 0xd5, 0xe9, 0x13, 0x3a, 0xb1, 0x2e, 0x4d, 0x5e, 0x03, - 0xdb, 0x8b, 0xfa, 0x09, 0x47, 0x7f, 0xc6, 0x16, 0xbd, 0x02, 0xf5, 0xb1, 0xe4, 0xf0, 0x52, 0x9a, - 0x12, 0x1b, 0xed, 0x7e, 0xbf, 0x70, 0xba, 0x7a, 0x69, 0xff, 0xea, 0x45, 0x5e, 0xc3, 0x17, 0x42, - 0x1e, 0xbd, 0xf9, 0xb1, 0xf4, 0xc9, 0xe5, 0xd2, 0x27, 0xbf, 0x96, 0x3e, 0xb9, 0x58, 0xf9, 0xa3, - 0xcb, 0x95, 0x3f, 0xfa, 0xb9, 0xf2, 0x47, 0xef, 0x1f, 0x6c, 0x2c, 0x44, 0x91, 0xeb, 0xa2, 0xe4, - 0xa8, 0x64, 0x2c, 0xf0, 0xa0, 0xff, 0x20, 0x86, 0x4f, 0x79, 0x2d, 0x2b, 0xd0, 0xff, 0x5a, 0xc1, - 0xd9, 0xb8, 0x4b, 0x63, 0xfa, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x64, 0xc4, 0x8d, 0xa6, 0x02, - 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// MyTestGrpcPluginClient is the client API for MyTestGrpcPlugin service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type MyTestGrpcPluginClient interface { - Run(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) -} - -type myTestGrpcPluginClient struct { - cc *grpc.ClientConn -} - -func NewMyTestGrpcPluginClient(cc *grpc.ClientConn) MyTestGrpcPluginClient { - return &myTestGrpcPluginClient{cc} -} - -func (c *myTestGrpcPluginClient) Run(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) { - out := new(Response) - err := c.cc.Invoke(ctx, "/grpc_plugin.MyTestGrpcPlugin/run", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// MyTestGrpcPluginServer is the server API for MyTestGrpcPlugin service. -type MyTestGrpcPluginServer interface { - Run(context.Context, *Request) (*Response, error) -} - -// UnimplementedMyTestGrpcPluginServer can be embedded to have forward compatible implementations. -type UnimplementedMyTestGrpcPluginServer struct { -} - -func (*UnimplementedMyTestGrpcPluginServer) Run(ctx context.Context, req *Request) (*Response, error) { - return nil, status.Errorf(codes.Unimplemented, "method Run not implemented") -} - -func RegisterMyTestGrpcPluginServer(s *grpc.Server, srv MyTestGrpcPluginServer) { - s.RegisterService(&_MyTestGrpcPlugin_serviceDesc, srv) -} - -func _MyTestGrpcPlugin_Run_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Request) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MyTestGrpcPluginServer).Run(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/grpc_plugin.MyTestGrpcPlugin/Run", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MyTestGrpcPluginServer).Run(ctx, req.(*Request)) - } - return interceptor(ctx, in, info, handler) -} - -var _MyTestGrpcPlugin_serviceDesc = grpc.ServiceDesc{ - ServiceName: "grpc_plugin.MyTestGrpcPlugin", - HandlerType: (*MyTestGrpcPluginServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "run", - Handler: _MyTestGrpcPlugin_Run_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "proto/my_test_grpc_plugin.proto", -} - -// MyTestGrpcPluginForAnotherClient is the client API for MyTestGrpcPluginForAnother service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type MyTestGrpcPluginForAnotherClient interface { - ProcessData(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) -} - -type myTestGrpcPluginForAnotherClient struct { - cc *grpc.ClientConn -} - -func NewMyTestGrpcPluginForAnotherClient(cc *grpc.ClientConn) MyTestGrpcPluginForAnotherClient { - return &myTestGrpcPluginForAnotherClient{cc} -} - -func (c *myTestGrpcPluginForAnotherClient) ProcessData(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) { - out := new(Response) - err := c.cc.Invoke(ctx, "/grpc_plugin.MyTestGrpcPluginForAnother/ProcessData", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// MyTestGrpcPluginForAnotherServer is the server API for MyTestGrpcPluginForAnother service. -type MyTestGrpcPluginForAnotherServer interface { - ProcessData(context.Context, *Request) (*Response, error) -} - -// UnimplementedMyTestGrpcPluginForAnotherServer can be embedded to have forward compatible implementations. -type UnimplementedMyTestGrpcPluginForAnotherServer struct { -} - -func (*UnimplementedMyTestGrpcPluginForAnotherServer) ProcessData(ctx context.Context, req *Request) (*Response, error) { - return nil, status.Errorf(codes.Unimplemented, "method ProcessData not implemented") -} - -func RegisterMyTestGrpcPluginForAnotherServer(s *grpc.Server, srv MyTestGrpcPluginForAnotherServer) { - s.RegisterService(&_MyTestGrpcPluginForAnother_serviceDesc, srv) -} - -func _MyTestGrpcPluginForAnother_ProcessData_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Request) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MyTestGrpcPluginForAnotherServer).ProcessData(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/grpc_plugin.MyTestGrpcPluginForAnother/ProcessData", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MyTestGrpcPluginForAnotherServer).ProcessData(ctx, req.(*Request)) - } - return interceptor(ctx, in, info, handler) -} - -var _MyTestGrpcPluginForAnother_serviceDesc = grpc.ServiceDesc{ - ServiceName: "grpc_plugin.MyTestGrpcPluginForAnother", - HandlerType: (*MyTestGrpcPluginForAnotherServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "ProcessData", - Handler: _MyTestGrpcPluginForAnother_ProcessData_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "proto/my_test_grpc_plugin.proto", -} - -func (m *Request) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Request) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Request) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Field6) > 0 { - for iNdEx := len(m.Field6) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Field6[iNdEx]) - copy(dAtA[i:], m.Field6[iNdEx]) - i = encodeVarintMyTestGrpcPlugin(dAtA, i, uint64(len(m.Field6[iNdEx]))) - i-- - dAtA[i] = 0x32 - } - } - if len(m.Field5) > 0 { - i -= len(m.Field5) - copy(dAtA[i:], m.Field5) - i = encodeVarintMyTestGrpcPlugin(dAtA, i, uint64(len(m.Field5))) - i-- - dAtA[i] = 0x2a - } - if len(m.Field4) > 0 { - i -= len(m.Field4) - copy(dAtA[i:], m.Field4) - i = encodeVarintMyTestGrpcPlugin(dAtA, i, uint64(len(m.Field4))) - i-- - dAtA[i] = 0x22 - } - if m.Field3 != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Field3)))) - i-- - dAtA[i] = 0x19 - } - if m.Field2 != 0 { - i = encodeVarintMyTestGrpcPlugin(dAtA, i, uint64(m.Field2)) - i-- - dAtA[i] = 0x10 - } - if m.Field1 != 0 { - i = encodeVarintMyTestGrpcPlugin(dAtA, i, uint64(m.Field1)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *Response) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Response) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Response) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Msg) > 0 { - i -= len(m.Msg) - copy(dAtA[i:], m.Msg) - i = encodeVarintMyTestGrpcPlugin(dAtA, i, uint64(len(m.Msg))) - i-- - dAtA[i] = 0x12 - } - if m.Code != 0 { - i = encodeVarintMyTestGrpcPlugin(dAtA, i, uint64(m.Code)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintMyTestGrpcPlugin(dAtA []byte, offset int, v uint64) int { - offset -= sovMyTestGrpcPlugin(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Request) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Field1 != 0 { - n += 1 + sovMyTestGrpcPlugin(uint64(m.Field1)) - } - if m.Field2 != 0 { - n += 1 + sovMyTestGrpcPlugin(uint64(m.Field2)) - } - if m.Field3 != 0 { - n += 9 - } - l = len(m.Field4) - if l > 0 { - n += 1 + l + sovMyTestGrpcPlugin(uint64(l)) - } - l = len(m.Field5) - if l > 0 { - n += 1 + l + sovMyTestGrpcPlugin(uint64(l)) - } - if len(m.Field6) > 0 { - for _, s := range m.Field6 { - l = len(s) - n += 1 + l + sovMyTestGrpcPlugin(uint64(l)) - } - } - return n -} - -func (m *Response) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Code != 0 { - n += 1 + sovMyTestGrpcPlugin(uint64(m.Code)) - } - l = len(m.Msg) - if l > 0 { - n += 1 + l + sovMyTestGrpcPlugin(uint64(l)) - } - return n -} - -func sovMyTestGrpcPlugin(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozMyTestGrpcPlugin(x uint64) (n int) { - return sovMyTestGrpcPlugin(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Request) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMyTestGrpcPlugin - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Request: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Request: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Field1", wireType) - } - m.Field1 = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMyTestGrpcPlugin - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Field1 |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Field2", wireType) - } - m.Field2 = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMyTestGrpcPlugin - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Field2 |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field Field3", wireType) - } - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - m.Field3 = float64(math.Float64frombits(v)) - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Field4", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMyTestGrpcPlugin - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMyTestGrpcPlugin - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMyTestGrpcPlugin - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Field4 = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Field5", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMyTestGrpcPlugin - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthMyTestGrpcPlugin - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthMyTestGrpcPlugin - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Field5 = append(m.Field5[:0], dAtA[iNdEx:postIndex]...) - if m.Field5 == nil { - m.Field5 = []byte{} - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Field6", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMyTestGrpcPlugin - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMyTestGrpcPlugin - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMyTestGrpcPlugin - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Field6 = append(m.Field6, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMyTestGrpcPlugin(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMyTestGrpcPlugin - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Response) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMyTestGrpcPlugin - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Response: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Response: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) - } - m.Code = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMyTestGrpcPlugin - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Code |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Msg", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMyTestGrpcPlugin - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMyTestGrpcPlugin - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMyTestGrpcPlugin - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Msg = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMyTestGrpcPlugin(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMyTestGrpcPlugin - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipMyTestGrpcPlugin(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowMyTestGrpcPlugin - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowMyTestGrpcPlugin - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowMyTestGrpcPlugin - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthMyTestGrpcPlugin - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupMyTestGrpcPlugin - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthMyTestGrpcPlugin - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthMyTestGrpcPlugin = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowMyTestGrpcPlugin = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupMyTestGrpcPlugin = fmt.Errorf("proto: unexpected end of group") -) diff --git a/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/my_test_grpc_plugin.plugin.go b/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/my_test_grpc_plugin.plugin.go deleted file mode 100644 index 4bf1fea1..00000000 --- a/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin/my_test_grpc_plugin.plugin.go +++ /dev/null @@ -1,46 +0,0 @@ -package my_test_grpc_plugin - -import ( - "context" - - "github.com/hashicorp/go-plugin" - - "google.golang.org/grpc" -) - -var Handshake = plugin.HandshakeConfig{ - ProtocolVersion: 1, - MagicCookieKey: "BASIC_PLUGIN", - MagicCookieValue: "hello", -} - -type GRPC struct { - plugin.Plugin - Impl MyTestGrpcPluginServer -} - -func (p *GRPC) GRPCServer(broker *plugin.GRPCBroker, server *grpc.Server) error { - RegisterMyTestGrpcPluginServer(server, &GPRCPluginServerWrapper{impl: p.Impl}) - return nil -} - -func (p *GRPC) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, conn *grpc.ClientConn) (interface{}, error) { - return &GRPCPluginClientWrapper{client: NewMyTestGrpcPluginClient(conn)}, nil -} - -type GPRCPluginServerWrapper struct { - impl MyTestGrpcPluginServer - UnimplementedMyTestGrpcPluginServer -} - -func (g *GPRCPluginServerWrapper) Run(ctx context.Context, req *Request) (*Response, error) { - return g.impl.Run(ctx, req) -} - -type GRPCPluginClientWrapper struct { - client MyTestGrpcPluginClient -} - -func (g *GRPCPluginClientWrapper) Run(ctx context.Context, req *Request) (*Response, error) { - return g.client.Run(ctx, req) -} diff --git a/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/callee.go b/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/callee.go deleted file mode 100644 index e29aee53..00000000 --- a/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/callee.go +++ /dev/null @@ -1,27 +0,0 @@ -package main - -import ( - "runtime" - - "github.com/hashicorp/go-plugin" - - pb "github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin" - - imp "github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/plugin" -) - -func StartPluginCaller() { - plugin.Serve(&plugin.ServeConfig{ - HandshakeConfig: pb.Handshake, - Plugins: map[string]plugin.Plugin{ - "my_plugin_1": &pb.GRPC{Impl: &imp.PluginService{}}, - }, - // A non-nil value here enables gRPC serving for this plugin... - GRPCServer: plugin.DefaultGRPCServer, - }) -} - -func main() { - runtime.GOMAXPROCS(1) - StartPluginCaller() -} diff --git a/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/go.mod b/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/go.mod deleted file mode 100644 index 904db178..00000000 --- a/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/go.mod +++ /dev/null @@ -1,26 +0,0 @@ -module github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee - -go 1.17 - -replace github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin => ../my_test_grpc_plugin - -require github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin v0.0.0-00010101000000-000000000000 - -require ( - github.com/fatih/color v1.7.0 // indirect - github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/protobuf v1.5.2 // indirect - github.com/hashicorp/go-hclog v0.14.1 // indirect - github.com/hashicorp/go-plugin v1.4.8 // indirect - github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb // indirect - github.com/mattn/go-colorable v0.1.4 // indirect - github.com/mattn/go-isatty v0.0.10 // indirect - github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 // indirect - github.com/oklog/run v1.0.0 // indirect - golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect - golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect - golang.org/x/text v0.4.0 // indirect - google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect - google.golang.org/grpc v1.51.0 // indirect - google.golang.org/protobuf v1.28.1 // indirect -) diff --git a/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/go.sum b/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/go.sum deleted file mode 100644 index 0bddcd94..00000000 --- a/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/go.sum +++ /dev/null @@ -1,130 +0,0 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= -github.com/hashicorp/go-hclog v0.14.1 h1:nQcJDQwIAGnmoUWp8ubocEX40cCml/17YkF6csQLReU= -github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-plugin v1.4.8 h1:CHGwpxYDOttQOY7HOWgETU9dyVjOXzniXDqJcYJE1zM= -github.com/hashicorp/go-plugin v1.4.8/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s= -github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb h1:b5rjCoWHc7eqmAS4/qyk21ZsHyb6Mxv/jykxvNTkU4M= -github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= -github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= -github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10= -github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= -github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 h1:7GoSOOW2jpsfkntVKaS2rAr1TJqfcxotyaUcuxoZSzg= -github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= -github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.51.0 h1:E1eGv1FTqoLIdnBCZufiSHgKjlqG6fKFf6pPWtMTh8U= -google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/plugin/plugin.go b/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/plugin/plugin.go deleted file mode 100644 index 2474cd7a..00000000 --- a/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_callee/plugin/plugin.go +++ /dev/null @@ -1,20 +0,0 @@ -package plugin - -import ( - "context" - "fmt" - - pb "github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin" -) - -type PluginService struct{} - -// Run Implement the interface of grpc -// don't use error to return any info to caller -func (p *PluginService) Run(ctx context.Context, req *pb.Request) (*pb.Response, error) { - // todo: add logic here - return &pb.Response{ - Code: 200, - Msg: "req is " + fmt.Sprintf("%+v", req), - }, nil -} diff --git a/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/go.mod b/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/go.mod deleted file mode 100644 index 206792cb..00000000 --- a/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/go.mod +++ /dev/null @@ -1,30 +0,0 @@ -module github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller - -go 1.17 - -replace ( - github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin => ../my_test_grpc_plugin -) - -require ( - github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin v0.0.0-00010101000000-000000000000 -) - -require ( - github.com/fatih/color v1.7.0 // indirect - github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/protobuf v1.5.2 // indirect - github.com/hashicorp/go-hclog v0.14.1 // indirect - github.com/hashicorp/go-plugin v1.4.8 // indirect - github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb // indirect - github.com/mattn/go-colorable v0.1.4 // indirect - github.com/mattn/go-isatty v0.0.10 // indirect - github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 // indirect - github.com/oklog/run v1.0.0 // indirect - golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect - golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect - golang.org/x/text v0.4.0 // indirect - google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect - google.golang.org/grpc v1.51.0 // indirect - google.golang.org/protobuf v1.28.1 // indirect -) diff --git a/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/go.sum b/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/go.sum deleted file mode 100644 index 0bddcd94..00000000 --- a/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/go.sum +++ /dev/null @@ -1,130 +0,0 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= -github.com/hashicorp/go-hclog v0.14.1 h1:nQcJDQwIAGnmoUWp8ubocEX40cCml/17YkF6csQLReU= -github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-plugin v1.4.8 h1:CHGwpxYDOttQOY7HOWgETU9dyVjOXzniXDqJcYJE1zM= -github.com/hashicorp/go-plugin v1.4.8/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s= -github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb h1:b5rjCoWHc7eqmAS4/qyk21ZsHyb6Mxv/jykxvNTkU4M= -github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= -github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= -github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10= -github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= -github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 h1:7GoSOOW2jpsfkntVKaS2rAr1TJqfcxotyaUcuxoZSzg= -github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= -github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.51.0 h1:E1eGv1FTqoLIdnBCZufiSHgKjlqG6fKFf6pPWtMTh8U= -google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/debugs_util.go b/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/debugs_util.go deleted file mode 100644 index deb5ff72..00000000 --- a/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/debugs_util.go +++ /dev/null @@ -1,27 +0,0 @@ -package loader - -import ( - "fmt" - "runtime" - "strings" -) - -// SourceCodeLoc 获取源码行 -// example: SourceCodeLoc(1) 获取当前代码行的行号 -func SourceCodeLoc(callDepth int) string { - _, file, line, ok := runtime.Caller(callDepth) - if !ok { - return "" - } - file = strings.ReplaceAll(file, "\\", "/") - paths := strings.Split(file, "/") - if len(paths) > 3 { - file = strings.Join(paths[len(paths)-3:], "/") - } - return fmt.Sprintf("%s:%d", file, line) -} - -// WrapError 在错误信息的基础上加上当前行号 -func WrapError(err error, infos ...string) error { - return fmt.Errorf("[%s] %+v, err=%+v", SourceCodeLoc(2), infos, err) -} diff --git a/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/dynamic_plugins.go b/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/dynamic_plugins.go deleted file mode 100644 index 03a1023f..00000000 --- a/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/dynamic_plugins.go +++ /dev/null @@ -1,81 +0,0 @@ -package loader - -import ( - "sync" - "time" - - "github.com/hashicorp/go-plugin" -) - -type ProcessBase struct { - Client *plugin.Client - Protocol plugin.ClientProtocol - Entry interface{} - LastRun int64 -} - -func (p *ProcessBase) Close() { - if p.Protocol != nil { - p.Protocol.Close() - } - p.Entry = nil - p.Protocol = nil - if p.Client != nil { - p.Client.Kill() - p.Client = nil - } -} - -type DynamicPluginsBase struct { - Plugins sync.Map - Lock sync.Mutex -} - -func NewDynamicPlugins() *DynamicPluginsBase { - out := &DynamicPluginsBase{Plugins: sync.Map{}} - go out.autoUnLoad() - return out -} - -const defaultUnloadSeconds = 20 * 60 - -var pluginUnloadSeconds int64 = defaultUnloadSeconds - -func SetPluginUnloadSeconds(seconds int64) { - pluginUnloadSeconds = seconds -} - -func (d *DynamicPluginsBase) autoUnLoad() { - tick := time.NewTicker(time.Duration(pluginUnloadSeconds) * time.Second) - for { - select { - case <-tick.C: - toDelete := make(map[string]interface{}) - d.Plugins.Range(func(key, value interface{}) bool { - p, ok := value.(*ProcessBase) - if !ok { - toDelete[key.(string)] = nil - return true - } - now := time.Now().Unix() - if pluginUnloadSeconds > 0 && now-p.LastRun > pluginUnloadSeconds { - toDelete[key.(string)] = p - return true - } - return true - }) - if len(toDelete) > 0 { - d.Lock.Lock() - for k, v := range toDelete { - p, ok := v.(*ProcessBase) - if ok { - p.Close() - } - d.Plugins.Delete(k) - // log.Println("remove:", k) - } - d.Lock.Unlock() - } - } - } -} diff --git a/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/loader.go b/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/loader.go deleted file mode 100644 index 75f7d231..00000000 --- a/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/loader.go +++ /dev/null @@ -1,74 +0,0 @@ -package loader - -import ( - "context" - "fmt" - "os" - "os/exec" - "time" - - "github.com/hashicorp/go-plugin" - - pb "github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin" -) - -type Process struct { - *ProcessBase -} - -func (p *Process) Run(ctx context.Context, req *pb.Request) (*pb.Response, error) { - p.LastRun = time.Now().Unix() - service := p.Entry.(pb.MyTestGrpcPluginServer) - return service.Run(ctx, req) -} - -type DynamicPlugins struct { - *DynamicPluginsBase -} - -func NewLoader() *DynamicPlugins { - out := &DynamicPlugins{ - DynamicPluginsBase: NewDynamicPlugins(), - } - return out -} - -func (d *DynamicPlugins) Load(name string, path string) (*Process, error) { - if p, ok := d.Plugins.Load(name); ok { - return p.(*Process), nil - } - if _, err := os.Stat(path); os.IsNotExist(err) { - return nil, fmt.Errorf("[%s]plugin file %s not exists", SourceCodeLoc(1), path) - } - d.Lock.Lock() - defer d.Lock.Unlock() - if p, ok := d.Plugins.Load(name); ok { - return p.(*Process), nil - } - pluginClientConfig := &plugin.ClientConfig{ - HandshakeConfig: pb.Handshake, - Cmd: exec.Command(path), - Plugins: map[string]plugin.Plugin{"main": &pb.GRPC{}}, - AllowedProtocols: []plugin.Protocol{plugin.ProtocolGRPC}, - } - client := plugin.NewClient(pluginClientConfig) - pluginClientConfig.Reattach = client.ReattachConfig() - protocol, err := client.Client() - if err != nil { - return nil, WrapError(err, "start process error") - } - raw, err := protocol.Dispense("main") - if err != nil { - return nil, WrapError(err, "find plugin error") - } - p := &Process{ - ProcessBase: &ProcessBase{ - Client: client, - Protocol: protocol, - Entry: raw, - LastRun: 0, - }, - } - d.Plugins.Store(name, p) - return p, nil -} diff --git a/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/loader_test.go b/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/loader_test.go deleted file mode 100644 index a833162a..00000000 --- a/examples/code_generator/temp/github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin_caller/loader/loader_test.go +++ /dev/null @@ -1,74 +0,0 @@ -package loader - -import ( - "context" - "testing" - "time" - - pb "github.com/hashicorp/go-plugin/examples/my_test_grpc_plugin" -) - -func TestProcess_Run(t *testing.T) { - SetPluginUnloadSeconds(3) - loader := NewLoader() - const pluinPath = "../../my_test_grpc_plugin_callee/my_test_grpc_plugin_callee" - p, err := loader.Load("my_test_grpc_plugins", pluinPath) - if err != nil { - t.Errorf("load error, err=%+v", err) - return - } - rsp, err := p.Run(context.Background(), &pb.Request{ - Field1: 1, - Field2: 2, - Field3: 3, - Field4: "4", - Field5: []byte("5"), - Field6: []string{"6"}, - }) - if err != nil { - t.Errorf("run error, err=%+v", err) - return - } - t.Logf("rsp=%+v", rsp) - { - p1, err1 := loader.Load("my_test_grpc_plugins", "../my_test_grpc_plugin_callee") - if err1 != nil { - t.Errorf("load error, err=%+v", err1) - return - } - rsp1, err1 := p1.Run(context.Background(), &pb.Request{ - Field1: 11, - Field2: 22, - Field3: 33, - Field4: "44", - Field5: []byte("55"), - Field6: []string{"66"}, - }) - if err1 != nil { - t.Errorf("run error, err=%+v", err1) - return - } - t.Logf("rsp=%+v", rsp1) - } - time.Sleep(time.Duration(4) * time.Second) - { - p2, err2 := loader.Load("my_test_grpc_plugins", pluinPath) - if err2 != nil { - t.Errorf("load error, err=%+v", err2) - return - } - rsp2, err2 := p2.Run(context.Background(), &pb.Request{ - Field1: 111, - Field2: 222, - Field3: 333, - Field4: "444", - Field5: []byte("555"), - Field6: []string{"666"}, - }) - if err2 != nil { - t.Errorf("run error, err=%+v", err2) - return - } - t.Logf("rsp=%+v", rsp2) - } -}