commit f2384a3ae89ef613160ebd1f12c7d549cfb8c24d Author: 刘祥超 Date: Tue Jul 21 17:27:00 2020 +0800 阶段性提交 diff --git a/build/.gitignore b/build/.gitignore new file mode 100644 index 00000000..a7d94920 --- /dev/null +++ b/build/.gitignore @@ -0,0 +1 @@ +configs/api.yaml \ No newline at end of file diff --git a/build/configs/api.template.yaml b/build/configs/api.template.yaml new file mode 100644 index 00000000..e69de29b diff --git a/build/grpc.sh b/build/grpc.sh new file mode 100755 index 00000000..a04830e7 --- /dev/null +++ b/build/grpc.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +function proto_compile() { + protoc --go_out=plugins=grpc:../internal/rpc --proto_path=../internal/rpc ../internal/rpc/${1}/*.proto +} + +proto_compile "admin" +proto_compile "dns" +proto_compile "log" +proto_compile "provider" +proto_compile "stat" +proto_compile "user" +proto_compile "monitor" +proto_compile "node" \ No newline at end of file diff --git a/cmd/edge-api/main.go b/cmd/edge-api/main.go new file mode 100644 index 00000000..8275c0fc --- /dev/null +++ b/cmd/edge-api/main.go @@ -0,0 +1,10 @@ +package main + +import ( + "github.com/TeaOSLab/EdgeAPI/internal/apis" + _ "github.com/iwind/TeaGo/bootstrap" +) + +func main() { + apis.NewAPINode().Start() +} diff --git a/go.mod b/go.mod new file mode 100644 index 00000000..48ec9a6c --- /dev/null +++ b/go.mod @@ -0,0 +1,15 @@ +module github.com/TeaOSLab/EdgeAPI + +go 1.14 + +require ( + github.com/go-yaml/yaml v2.1.0+incompatible + github.com/golang/protobuf v1.4.1 + github.com/iwind/TeaGo v0.0.0-20200720020412-96dbe21b81d4 + github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect + github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7 // indirect + google.golang.org/grpc v1.30.0 + google.golang.org/protobuf v1.25.0 + gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect + gopkg.in/yaml.v2 v2.3.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 00000000..85c4572f --- /dev/null +++ b/go.sum @@ -0,0 +1,97 @@ +cloud.google.com/go v0.26.0 h1:e0WKqKTd5BnrG8aKH3J3h+QvEIQtSUcf2n5UZ5ZgLtQ= +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-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +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.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/go-yaml/yaml v2.1.0+incompatible h1:RYi2hDdss1u4YE7GwixGzWwVo47T8UQwnTLB6vQiq+o= +github.com/go-yaml/yaml v2.1.0+incompatible/go.mod h1:w2MrLa16VYP0jy6N7M5kHaCkaLENm+P+Tv+MfurjSw0= +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.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +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 h1:ZFgWrT+bLgsYPirOnRfKLYJLvssAegOj/hgyMFdJZe0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +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 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/iwind/TeaGo v0.0.0-20200720020412-96dbe21b81d4 h1:893FbgV8PRV/rCqEAtpifgAmsIYTDrZruWHMWIw4+x8= +github.com/iwind/TeaGo v0.0.0-20200720020412-96dbe21b81d4/go.mod h1:taNzU+Tt7Axz5t1v8pEV7xRuioNJxbMeMAbDVQpxq20= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7 h1:xoIK0ctDddBMnc74udxJYBqlo9Ylnsp1waqjLsnef20= +github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7/go.mod h1:YARuvh7BUWHNhzDq2OM5tzR2RiCcN2D7sapiKyCel/M= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +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/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 h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs= +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/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +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/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/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 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE= +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.30.0 h1:M5a8xTlYTxwMn5ZFkwhRabsygDY5G8TYLyQDBxJNAxE= +google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +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.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= +gopkg.in/yaml.v2 v2.3.0/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/internal/apis/api_node.go b/internal/apis/api_node.go new file mode 100644 index 00000000..278f360d --- /dev/null +++ b/internal/apis/api_node.go @@ -0,0 +1,68 @@ +package apis + +import ( + "errors" + "github.com/TeaOSLab/EdgeAPI/internal/configs" + "github.com/TeaOSLab/EdgeAPI/internal/rpc/dns" + "github.com/TeaOSLab/EdgeAPI/internal/rpc/log" + "github.com/TeaOSLab/EdgeAPI/internal/rpc/monitor" + "github.com/TeaOSLab/EdgeAPI/internal/rpc/node" + "github.com/TeaOSLab/EdgeAPI/internal/rpc/provider" + "github.com/TeaOSLab/EdgeAPI/internal/rpc/stat" + "github.com/TeaOSLab/EdgeAPI/internal/rpc/user" + "github.com/iwind/TeaGo/logs" + "google.golang.org/grpc" + "net" + "os" + "strconv" +) + +var sharedAPIConfig *configs.APIConfig = nil + +type APINode struct { +} + +func NewAPINode() *APINode { + return &APINode{} +} + +func (this *APINode) Start() { + logs.Println("[API]start api node, pid: " + strconv.Itoa(os.Getpid())) + + config, err := configs.SharedAPIConfig() + if err != nil { + logs.Println("[API]start failed: " + err.Error()) + return + } + sharedAPIConfig = config + + // 监听RPC服务 + logs.Println("[API]start rpc: " + config.RPC.Listen) + err = this.listenRPC() + if err != nil { + logs.Println(err.Error()) + return + } +} + +// 启动RPC监听 +func (this *APINode) listenRPC() error { + listener, err := net.Listen("tcp", sharedAPIConfig.RPC.Listen) + if err != nil { + return errors.New("[API]listen rpc failed: " + err.Error()) + } + rpcServer := grpc.NewServer() + dns.RegisterServiceServer(rpcServer, &dns.Service{}) + log.RegisterServiceServer(rpcServer, &log.Service{}) + monitor.RegisterServiceServer(rpcServer, &monitor.Service{}) + node.RegisterServiceServer(rpcServer, &node.Service{}) + provider.RegisterServiceServer(rpcServer, &provider.Service{}) + stat.RegisterServiceServer(rpcServer, &stat.Service{}) + user.RegisterServiceServer(rpcServer, &user.Service{}) + err = rpcServer.Serve(listener) + if err != nil { + return errors.New("[API]start rpc failed: " + err.Error()) + } + + return nil +} diff --git a/internal/configs/api_config.go b/internal/configs/api_config.go new file mode 100644 index 00000000..d5fee40b --- /dev/null +++ b/internal/configs/api_config.go @@ -0,0 +1,38 @@ +package configs + +import ( + "github.com/go-yaml/yaml" + "github.com/iwind/TeaGo/Tea" + "io/ioutil" +) + +var sharedAPIConfig *APIConfig = nil + +type APIConfig struct { + RPC struct { + Listen string `yaml:"listen"` + } `yaml:"rpc"` +} + +func SharedAPIConfig() (*APIConfig, error) { + sharedLocker.Lock() + defer sharedLocker.Unlock() + + if sharedAPIConfig != nil { + return sharedAPIConfig, nil + } + + data, err := ioutil.ReadFile(Tea.ConfigFile("api.yaml")) + if err != nil { + return nil, err + } + + config := &APIConfig{} + err = yaml.Unmarshal(data, config) + if err != nil { + return nil, err + } + + sharedAPIConfig = config + return config, nil +} diff --git a/internal/configs/api_config_test.go b/internal/configs/api_config_test.go new file mode 100644 index 00000000..74fe515a --- /dev/null +++ b/internal/configs/api_config_test.go @@ -0,0 +1,14 @@ +package configs + +import ( + _ "github.com/iwind/TeaGo/bootstrap" + "testing" +) + +func TestSharedAPIConfig(t *testing.T) { + config, err := SharedAPIConfig() + if err != nil { + t.Fatal(err) + } + t.Log(config) +} diff --git a/internal/configs/locker.go b/internal/configs/locker.go new file mode 100644 index 00000000..5768a10d --- /dev/null +++ b/internal/configs/locker.go @@ -0,0 +1,5 @@ +package configs + +import "sync" + +var sharedLocker = &sync.RWMutex{} diff --git a/internal/rpc/admin/service.pb.go b/internal/rpc/admin/service.pb.go new file mode 100644 index 00000000..fa5d1efe --- /dev/null +++ b/internal/rpc/admin/service.pb.go @@ -0,0 +1,279 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.12.3 +// source: admin/service.proto + +package admin + +import ( + context "context" + proto "github.com/golang/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +type LoginRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *LoginRequest) Reset() { + *x = LoginRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_admin_service_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LoginRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LoginRequest) ProtoMessage() {} + +func (x *LoginRequest) ProtoReflect() protoreflect.Message { + mi := &file_admin_service_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LoginRequest.ProtoReflect.Descriptor instead. +func (*LoginRequest) Descriptor() ([]byte, []int) { + return file_admin_service_proto_rawDescGZIP(), []int{0} +} + +type LoginResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *LoginResponse) Reset() { + *x = LoginResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_admin_service_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LoginResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LoginResponse) ProtoMessage() {} + +func (x *LoginResponse) ProtoReflect() protoreflect.Message { + mi := &file_admin_service_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LoginResponse.ProtoReflect.Descriptor instead. +func (*LoginResponse) Descriptor() ([]byte, []int) { + return file_admin_service_proto_rawDescGZIP(), []int{1} +} + +var File_admin_service_proto protoreflect.FileDescriptor + +var file_admin_service_proto_rawDesc = []byte{ + 0x0a, 0x13, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x22, 0x0e, 0x0a, 0x0c, + 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x0f, 0x0a, 0x0d, + 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x3f, 0x0a, + 0x07, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x34, 0x0a, 0x05, 0x6c, 0x6f, 0x67, 0x69, + 0x6e, 0x12, 0x13, 0x2e, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2e, 0x4c, + 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x09, + 0x5a, 0x07, 0x2e, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, +} + +var ( + file_admin_service_proto_rawDescOnce sync.Once + file_admin_service_proto_rawDescData = file_admin_service_proto_rawDesc +) + +func file_admin_service_proto_rawDescGZIP() []byte { + file_admin_service_proto_rawDescOnce.Do(func() { + file_admin_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_admin_service_proto_rawDescData) + }) + return file_admin_service_proto_rawDescData +} + +var file_admin_service_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_admin_service_proto_goTypes = []interface{}{ + (*LoginRequest)(nil), // 0: admin.LoginRequest + (*LoginResponse)(nil), // 1: admin.LoginResponse +} +var file_admin_service_proto_depIdxs = []int32{ + 0, // 0: admin.Service.login:input_type -> admin.LoginRequest + 1, // 1: admin.Service.login:output_type -> admin.LoginResponse + 1, // [1:2] is the sub-list for method output_type + 0, // [0:1] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_admin_service_proto_init() } +func file_admin_service_proto_init() { + if File_admin_service_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_admin_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LoginRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_admin_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LoginResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_admin_service_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_admin_service_proto_goTypes, + DependencyIndexes: file_admin_service_proto_depIdxs, + MessageInfos: file_admin_service_proto_msgTypes, + }.Build() + File_admin_service_proto = out.File + file_admin_service_proto_rawDesc = nil + file_admin_service_proto_goTypes = nil + file_admin_service_proto_depIdxs = nil +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConnInterface + +// 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.SupportPackageIsVersion6 + +// ServiceClient is the client API for Service service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type ServiceClient interface { + Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) +} + +type serviceClient struct { + cc grpc.ClientConnInterface +} + +func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient { + return &serviceClient{cc} +} + +func (c *serviceClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) { + out := new(LoginResponse) + err := c.cc.Invoke(ctx, "/admin.Service/login", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ServiceServer is the server API for Service service. +type ServiceServer interface { + Login(context.Context, *LoginRequest) (*LoginResponse, error) +} + +// UnimplementedServiceServer can be embedded to have forward compatible implementations. +type UnimplementedServiceServer struct { +} + +func (*UnimplementedServiceServer) Login(context.Context, *LoginRequest) (*LoginResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Login not implemented") +} + +func RegisterServiceServer(s *grpc.Server, srv ServiceServer) { + s.RegisterService(&_Service_serviceDesc, srv) +} + +func _Service_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LoginRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ServiceServer).Login(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/admin.Service/Login", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ServiceServer).Login(ctx, req.(*LoginRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Service_serviceDesc = grpc.ServiceDesc{ + ServiceName: "admin.Service", + HandlerType: (*ServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "login", + Handler: _Service_Login_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "admin/service.proto", +} diff --git a/internal/rpc/admin/service.proto b/internal/rpc/admin/service.proto new file mode 100644 index 00000000..776ef5ce --- /dev/null +++ b/internal/rpc/admin/service.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; + +package admin; + +option go_package = "./admin"; + +service Service { + rpc login (LoginRequest) returns (LoginResponse) { + } +} + +message LoginRequest { + +} + +message LoginResponse { + +} \ No newline at end of file diff --git a/internal/rpc/dns/service.go b/internal/rpc/dns/service.go new file mode 100644 index 00000000..d6b4fce8 --- /dev/null +++ b/internal/rpc/dns/service.go @@ -0,0 +1,4 @@ +package dns + +type Service struct { +} diff --git a/internal/rpc/dns/service.pb.go b/internal/rpc/dns/service.pb.go new file mode 100644 index 00000000..a9e723a5 --- /dev/null +++ b/internal/rpc/dns/service.pb.go @@ -0,0 +1,111 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.12.3 +// source: dns/service.proto + +package dns + +import ( + context "context" + proto "github.com/golang/protobuf/proto" + grpc "google.golang.org/grpc" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +var File_dns_service_proto protoreflect.FileDescriptor + +var file_dns_service_proto_rawDesc = []byte{ + 0x0a, 0x11, 0x64, 0x6e, 0x73, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x64, 0x6e, 0x73, 0x32, 0x09, 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x42, 0x07, 0x5a, 0x05, 0x2e, 0x2f, 0x64, 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, +} + +var file_dns_service_proto_goTypes = []interface{}{} +var file_dns_service_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_dns_service_proto_init() } +func file_dns_service_proto_init() { + if File_dns_service_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_dns_service_proto_rawDesc, + NumEnums: 0, + NumMessages: 0, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_dns_service_proto_goTypes, + DependencyIndexes: file_dns_service_proto_depIdxs, + }.Build() + File_dns_service_proto = out.File + file_dns_service_proto_rawDesc = nil + file_dns_service_proto_goTypes = nil + file_dns_service_proto_depIdxs = nil +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConnInterface + +// 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.SupportPackageIsVersion6 + +// ServiceClient is the client API for Service service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type ServiceClient interface { +} + +type serviceClient struct { + cc grpc.ClientConnInterface +} + +func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient { + return &serviceClient{cc} +} + +// ServiceServer is the server API for Service service. +type ServiceServer interface { +} + +// UnimplementedServiceServer can be embedded to have forward compatible implementations. +type UnimplementedServiceServer struct { +} + +func RegisterServiceServer(s *grpc.Server, srv ServiceServer) { + s.RegisterService(&_Service_serviceDesc, srv) +} + +var _Service_serviceDesc = grpc.ServiceDesc{ + ServiceName: "dns.Service", + HandlerType: (*ServiceServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{}, + Metadata: "dns/service.proto", +} diff --git a/internal/rpc/dns/service.proto b/internal/rpc/dns/service.proto new file mode 100644 index 00000000..41dc48a8 --- /dev/null +++ b/internal/rpc/dns/service.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package dns; + +option go_package = "./dns"; + +service Service { + +} diff --git a/internal/rpc/log/service.go b/internal/rpc/log/service.go new file mode 100644 index 00000000..877884f1 --- /dev/null +++ b/internal/rpc/log/service.go @@ -0,0 +1,4 @@ +package log + +type Service struct { +} diff --git a/internal/rpc/log/service.pb.go b/internal/rpc/log/service.pb.go new file mode 100644 index 00000000..526c9390 --- /dev/null +++ b/internal/rpc/log/service.pb.go @@ -0,0 +1,111 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.12.3 +// source: log/service.proto + +package log + +import ( + context "context" + proto "github.com/golang/protobuf/proto" + grpc "google.golang.org/grpc" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +var File_log_service_proto protoreflect.FileDescriptor + +var file_log_service_proto_rawDesc = []byte{ + 0x0a, 0x11, 0x6c, 0x6f, 0x67, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x6c, 0x6f, 0x67, 0x32, 0x09, 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x42, 0x07, 0x5a, 0x05, 0x2e, 0x2f, 0x6c, 0x6f, 0x67, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, +} + +var file_log_service_proto_goTypes = []interface{}{} +var file_log_service_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_log_service_proto_init() } +func file_log_service_proto_init() { + if File_log_service_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_log_service_proto_rawDesc, + NumEnums: 0, + NumMessages: 0, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_log_service_proto_goTypes, + DependencyIndexes: file_log_service_proto_depIdxs, + }.Build() + File_log_service_proto = out.File + file_log_service_proto_rawDesc = nil + file_log_service_proto_goTypes = nil + file_log_service_proto_depIdxs = nil +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConnInterface + +// 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.SupportPackageIsVersion6 + +// ServiceClient is the client API for Service service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type ServiceClient interface { +} + +type serviceClient struct { + cc grpc.ClientConnInterface +} + +func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient { + return &serviceClient{cc} +} + +// ServiceServer is the server API for Service service. +type ServiceServer interface { +} + +// UnimplementedServiceServer can be embedded to have forward compatible implementations. +type UnimplementedServiceServer struct { +} + +func RegisterServiceServer(s *grpc.Server, srv ServiceServer) { + s.RegisterService(&_Service_serviceDesc, srv) +} + +var _Service_serviceDesc = grpc.ServiceDesc{ + ServiceName: "log.Service", + HandlerType: (*ServiceServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{}, + Metadata: "log/service.proto", +} diff --git a/internal/rpc/log/service.proto b/internal/rpc/log/service.proto new file mode 100644 index 00000000..5822a8ca --- /dev/null +++ b/internal/rpc/log/service.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package log; + +option go_package = "./log"; + +service Service { + +} diff --git a/internal/rpc/monitor/service.go b/internal/rpc/monitor/service.go new file mode 100644 index 00000000..dd0066c5 --- /dev/null +++ b/internal/rpc/monitor/service.go @@ -0,0 +1,4 @@ +package monitor + +type Service struct { +} diff --git a/internal/rpc/monitor/service.pb.go b/internal/rpc/monitor/service.pb.go new file mode 100644 index 00000000..5a9a0667 --- /dev/null +++ b/internal/rpc/monitor/service.pb.go @@ -0,0 +1,111 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.12.3 +// source: monitor/service.proto + +package monitor + +import ( + context "context" + proto "github.com/golang/protobuf/proto" + grpc "google.golang.org/grpc" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +var File_monitor_service_proto protoreflect.FileDescriptor + +var file_monitor_service_proto_rawDesc = []byte{ + 0x0a, 0x15, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, + 0x32, 0x09, 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x0b, 0x5a, 0x09, 0x2e, + 0x2f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var file_monitor_service_proto_goTypes = []interface{}{} +var file_monitor_service_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_monitor_service_proto_init() } +func file_monitor_service_proto_init() { + if File_monitor_service_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_monitor_service_proto_rawDesc, + NumEnums: 0, + NumMessages: 0, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_monitor_service_proto_goTypes, + DependencyIndexes: file_monitor_service_proto_depIdxs, + }.Build() + File_monitor_service_proto = out.File + file_monitor_service_proto_rawDesc = nil + file_monitor_service_proto_goTypes = nil + file_monitor_service_proto_depIdxs = nil +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConnInterface + +// 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.SupportPackageIsVersion6 + +// ServiceClient is the client API for Service service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type ServiceClient interface { +} + +type serviceClient struct { + cc grpc.ClientConnInterface +} + +func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient { + return &serviceClient{cc} +} + +// ServiceServer is the server API for Service service. +type ServiceServer interface { +} + +// UnimplementedServiceServer can be embedded to have forward compatible implementations. +type UnimplementedServiceServer struct { +} + +func RegisterServiceServer(s *grpc.Server, srv ServiceServer) { + s.RegisterService(&_Service_serviceDesc, srv) +} + +var _Service_serviceDesc = grpc.ServiceDesc{ + ServiceName: "monitor.Service", + HandlerType: (*ServiceServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{}, + Metadata: "monitor/service.proto", +} diff --git a/internal/rpc/monitor/service.proto b/internal/rpc/monitor/service.proto new file mode 100644 index 00000000..84a13e5c --- /dev/null +++ b/internal/rpc/monitor/service.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package monitor; + +option go_package = "./monitor"; + +service Service { + +} diff --git a/internal/rpc/node/service.go b/internal/rpc/node/service.go new file mode 100644 index 00000000..45231966 --- /dev/null +++ b/internal/rpc/node/service.go @@ -0,0 +1,14 @@ +package node + +import ( + "context" + "github.com/iwind/TeaGo/logs" +) + +type Service struct { +} + +func (this *Service) Node(context.Context, *NodeRequest) (*NodeResponse, error) { + logs.Println("you called me") + return &NodeResponse{}, nil +} diff --git a/internal/rpc/node/service.pb.go b/internal/rpc/node/service.pb.go new file mode 100644 index 00000000..864016a4 --- /dev/null +++ b/internal/rpc/node/service.pb.go @@ -0,0 +1,278 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.12.3 +// source: node/service.proto + +package node + +import ( + context "context" + proto "github.com/golang/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +type NodeRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *NodeRequest) Reset() { + *x = NodeRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_node_service_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NodeRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NodeRequest) ProtoMessage() {} + +func (x *NodeRequest) ProtoReflect() protoreflect.Message { + mi := &file_node_service_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NodeRequest.ProtoReflect.Descriptor instead. +func (*NodeRequest) Descriptor() ([]byte, []int) { + return file_node_service_proto_rawDescGZIP(), []int{0} +} + +type NodeResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *NodeResponse) Reset() { + *x = NodeResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_node_service_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NodeResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NodeResponse) ProtoMessage() {} + +func (x *NodeResponse) ProtoReflect() protoreflect.Message { + mi := &file_node_service_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NodeResponse.ProtoReflect.Descriptor instead. +func (*NodeResponse) Descriptor() ([]byte, []int) { + return file_node_service_proto_rawDescGZIP(), []int{1} +} + +var File_node_service_proto protoreflect.FileDescriptor + +var file_node_service_proto_rawDesc = []byte{ + 0x0a, 0x12, 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x6e, 0x6f, 0x64, 0x65, 0x22, 0x0d, 0x0a, 0x0b, 0x4e, 0x6f, + 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x0e, 0x0a, 0x0c, 0x4e, 0x6f, 0x64, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x3a, 0x0a, 0x07, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x12, 0x2f, 0x0a, 0x04, 0x6e, 0x6f, 0x64, 0x65, 0x12, 0x11, 0x2e, 0x6e, + 0x6f, 0x64, 0x65, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x12, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x08, 0x5a, 0x06, 0x2e, 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_node_service_proto_rawDescOnce sync.Once + file_node_service_proto_rawDescData = file_node_service_proto_rawDesc +) + +func file_node_service_proto_rawDescGZIP() []byte { + file_node_service_proto_rawDescOnce.Do(func() { + file_node_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_node_service_proto_rawDescData) + }) + return file_node_service_proto_rawDescData +} + +var file_node_service_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_node_service_proto_goTypes = []interface{}{ + (*NodeRequest)(nil), // 0: node.NodeRequest + (*NodeResponse)(nil), // 1: node.NodeResponse +} +var file_node_service_proto_depIdxs = []int32{ + 0, // 0: node.Service.node:input_type -> node.NodeRequest + 1, // 1: node.Service.node:output_type -> node.NodeResponse + 1, // [1:2] is the sub-list for method output_type + 0, // [0:1] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_node_service_proto_init() } +func file_node_service_proto_init() { + if File_node_service_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_node_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*NodeRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_node_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*NodeResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_node_service_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_node_service_proto_goTypes, + DependencyIndexes: file_node_service_proto_depIdxs, + MessageInfos: file_node_service_proto_msgTypes, + }.Build() + File_node_service_proto = out.File + file_node_service_proto_rawDesc = nil + file_node_service_proto_goTypes = nil + file_node_service_proto_depIdxs = nil +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConnInterface + +// 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.SupportPackageIsVersion6 + +// ServiceClient is the client API for Service service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type ServiceClient interface { + Node(ctx context.Context, in *NodeRequest, opts ...grpc.CallOption) (*NodeResponse, error) +} + +type serviceClient struct { + cc grpc.ClientConnInterface +} + +func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient { + return &serviceClient{cc} +} + +func (c *serviceClient) Node(ctx context.Context, in *NodeRequest, opts ...grpc.CallOption) (*NodeResponse, error) { + out := new(NodeResponse) + err := c.cc.Invoke(ctx, "/node.Service/node", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ServiceServer is the server API for Service service. +type ServiceServer interface { + Node(context.Context, *NodeRequest) (*NodeResponse, error) +} + +// UnimplementedServiceServer can be embedded to have forward compatible implementations. +type UnimplementedServiceServer struct { +} + +func (*UnimplementedServiceServer) Node(context.Context, *NodeRequest) (*NodeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Node not implemented") +} + +func RegisterServiceServer(s *grpc.Server, srv ServiceServer) { + s.RegisterService(&_Service_serviceDesc, srv) +} + +func _Service_Node_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(NodeRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ServiceServer).Node(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/node.Service/Node", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ServiceServer).Node(ctx, req.(*NodeRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Service_serviceDesc = grpc.ServiceDesc{ + ServiceName: "node.Service", + HandlerType: (*ServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "node", + Handler: _Service_Node_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "node/service.proto", +} diff --git a/internal/rpc/node/service.proto b/internal/rpc/node/service.proto new file mode 100644 index 00000000..f269c21e --- /dev/null +++ b/internal/rpc/node/service.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; + +package node; + +option go_package = "./node"; + +service Service { + rpc node (NodeRequest) returns (NodeResponse) { + + } +} + +message NodeRequest { + +} + +message NodeResponse { + +} \ No newline at end of file diff --git a/internal/rpc/provider/provider.pb.go b/internal/rpc/provider/provider.pb.go new file mode 100644 index 00000000..b9a765b5 --- /dev/null +++ b/internal/rpc/provider/provider.pb.go @@ -0,0 +1,112 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.12.3 +// source: provider/provider.proto + +package provider + +import ( + context "context" + proto "github.com/golang/protobuf/proto" + grpc "google.golang.org/grpc" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +var File_provider_provider_proto protoreflect.FileDescriptor + +var file_provider_provider_proto_rawDesc = []byte{ + 0x0a, 0x17, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x76, 0x69, + 0x64, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, + 0x64, 0x65, 0x72, 0x32, 0x09, 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x0c, + 0x5a, 0x0a, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, +} + +var file_provider_provider_proto_goTypes = []interface{}{} +var file_provider_provider_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_provider_provider_proto_init() } +func file_provider_provider_proto_init() { + if File_provider_provider_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_provider_provider_proto_rawDesc, + NumEnums: 0, + NumMessages: 0, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_provider_provider_proto_goTypes, + DependencyIndexes: file_provider_provider_proto_depIdxs, + }.Build() + File_provider_provider_proto = out.File + file_provider_provider_proto_rawDesc = nil + file_provider_provider_proto_goTypes = nil + file_provider_provider_proto_depIdxs = nil +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConnInterface + +// 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.SupportPackageIsVersion6 + +// ServiceClient is the client API for Service service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type ServiceClient interface { +} + +type serviceClient struct { + cc grpc.ClientConnInterface +} + +func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient { + return &serviceClient{cc} +} + +// ServiceServer is the server API for Service service. +type ServiceServer interface { +} + +// UnimplementedServiceServer can be embedded to have forward compatible implementations. +type UnimplementedServiceServer struct { +} + +func RegisterServiceServer(s *grpc.Server, srv ServiceServer) { + s.RegisterService(&_Service_serviceDesc, srv) +} + +var _Service_serviceDesc = grpc.ServiceDesc{ + ServiceName: "provider.Service", + HandlerType: (*ServiceServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{}, + Metadata: "provider/provider.proto", +} diff --git a/internal/rpc/provider/provider.proto b/internal/rpc/provider/provider.proto new file mode 100644 index 00000000..746c1d45 --- /dev/null +++ b/internal/rpc/provider/provider.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package provider; + +option go_package = "./provider"; + +service Service { + +} diff --git a/internal/rpc/provider/service.go b/internal/rpc/provider/service.go new file mode 100644 index 00000000..456bad43 --- /dev/null +++ b/internal/rpc/provider/service.go @@ -0,0 +1,4 @@ +package provider + +type Service struct { +} diff --git a/internal/rpc/stat/service.go b/internal/rpc/stat/service.go new file mode 100644 index 00000000..d292157d --- /dev/null +++ b/internal/rpc/stat/service.go @@ -0,0 +1,4 @@ +package stat + +type Service struct { +} diff --git a/internal/rpc/stat/service.pb.go b/internal/rpc/stat/service.pb.go new file mode 100644 index 00000000..d5320334 --- /dev/null +++ b/internal/rpc/stat/service.pb.go @@ -0,0 +1,111 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.12.3 +// source: stat/service.proto + +package stat + +import ( + context "context" + proto "github.com/golang/protobuf/proto" + grpc "google.golang.org/grpc" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +var File_stat_service_proto protoreflect.FileDescriptor + +var file_stat_service_proto_rawDesc = []byte{ + 0x0a, 0x12, 0x73, 0x74, 0x61, 0x74, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x73, 0x74, 0x61, 0x74, 0x32, 0x09, 0x0a, 0x07, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x08, 0x5a, 0x06, 0x2e, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var file_stat_service_proto_goTypes = []interface{}{} +var file_stat_service_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_stat_service_proto_init() } +func file_stat_service_proto_init() { + if File_stat_service_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_stat_service_proto_rawDesc, + NumEnums: 0, + NumMessages: 0, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_stat_service_proto_goTypes, + DependencyIndexes: file_stat_service_proto_depIdxs, + }.Build() + File_stat_service_proto = out.File + file_stat_service_proto_rawDesc = nil + file_stat_service_proto_goTypes = nil + file_stat_service_proto_depIdxs = nil +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConnInterface + +// 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.SupportPackageIsVersion6 + +// ServiceClient is the client API for Service service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type ServiceClient interface { +} + +type serviceClient struct { + cc grpc.ClientConnInterface +} + +func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient { + return &serviceClient{cc} +} + +// ServiceServer is the server API for Service service. +type ServiceServer interface { +} + +// UnimplementedServiceServer can be embedded to have forward compatible implementations. +type UnimplementedServiceServer struct { +} + +func RegisterServiceServer(s *grpc.Server, srv ServiceServer) { + s.RegisterService(&_Service_serviceDesc, srv) +} + +var _Service_serviceDesc = grpc.ServiceDesc{ + ServiceName: "stat.Service", + HandlerType: (*ServiceServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{}, + Metadata: "stat/service.proto", +} diff --git a/internal/rpc/stat/service.proto b/internal/rpc/stat/service.proto new file mode 100644 index 00000000..9908410d --- /dev/null +++ b/internal/rpc/stat/service.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package stat; + +option go_package = "./stat"; + +service Service { + +} diff --git a/internal/rpc/user/service.go b/internal/rpc/user/service.go new file mode 100644 index 00000000..5e19ef00 --- /dev/null +++ b/internal/rpc/user/service.go @@ -0,0 +1,4 @@ +package user + +type Service struct { +} diff --git a/internal/rpc/user/service.pb.go b/internal/rpc/user/service.pb.go new file mode 100644 index 00000000..f440699a --- /dev/null +++ b/internal/rpc/user/service.pb.go @@ -0,0 +1,111 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.12.3 +// source: user/service.proto + +package user + +import ( + context "context" + proto "github.com/golang/protobuf/proto" + grpc "google.golang.org/grpc" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +var File_user_service_proto protoreflect.FileDescriptor + +var file_user_service_proto_rawDesc = []byte{ + 0x0a, 0x12, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x75, 0x73, 0x65, 0x72, 0x32, 0x09, 0x0a, 0x07, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x08, 0x5a, 0x06, 0x2e, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var file_user_service_proto_goTypes = []interface{}{} +var file_user_service_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_user_service_proto_init() } +func file_user_service_proto_init() { + if File_user_service_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_user_service_proto_rawDesc, + NumEnums: 0, + NumMessages: 0, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_user_service_proto_goTypes, + DependencyIndexes: file_user_service_proto_depIdxs, + }.Build() + File_user_service_proto = out.File + file_user_service_proto_rawDesc = nil + file_user_service_proto_goTypes = nil + file_user_service_proto_depIdxs = nil +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConnInterface + +// 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.SupportPackageIsVersion6 + +// ServiceClient is the client API for Service service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type ServiceClient interface { +} + +type serviceClient struct { + cc grpc.ClientConnInterface +} + +func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient { + return &serviceClient{cc} +} + +// ServiceServer is the server API for Service service. +type ServiceServer interface { +} + +// UnimplementedServiceServer can be embedded to have forward compatible implementations. +type UnimplementedServiceServer struct { +} + +func RegisterServiceServer(s *grpc.Server, srv ServiceServer) { + s.RegisterService(&_Service_serviceDesc, srv) +} + +var _Service_serviceDesc = grpc.ServiceDesc{ + ServiceName: "user.Service", + HandlerType: (*ServiceServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{}, + Metadata: "user/service.proto", +} diff --git a/internal/rpc/user/service.proto b/internal/rpc/user/service.proto new file mode 100644 index 00000000..91ed305e --- /dev/null +++ b/internal/rpc/user/service.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package user; + +option go_package = "./user"; + +service Service { + +} diff --git a/internal/tests/grpc_test.go b/internal/tests/grpc_test.go new file mode 100644 index 00000000..2142e733 --- /dev/null +++ b/internal/tests/grpc_test.go @@ -0,0 +1,175 @@ +package tests + +import ( + "context" + "encoding/json" + nodepb "github.com/TeaOSLab/EdgeAPI/internal/rpc/node" + pb "github.com/TeaOSLab/EdgeAPI/internal/tests/helloworld" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials" + "google.golang.org/grpc/metadata" + "log" + "net" + "runtime" + "strings" + "testing" + "time" +) + +type server struct { +} + +func (this *server) SayHello(ctx context.Context, request *pb.HelloRequest) (*pb.HelloReply, error) { + md, ok := metadata.FromIncomingContext(ctx) + if ok { + jsonData, _ := json.MarshalIndent(md, "", " ") + log.Print(string(jsonData)) + + _ = md + } + + return &pb.HelloReply{ + Message: "Hello, " + request.Name, + }, nil +} + +func TestTCPServer(t *testing.T) { + listener, err := net.Listen("tcp", ":8001") + if err != nil { + t.Fatal(err) + } + + s := grpc.NewServer() + pb.RegisterGreeterServer(s, &server{}) + nodepb.RegisterServiceServer(s, &nodepb.Service{}) + + err = s.Serve(listener) + if err != nil { + t.Fatal(err) + } +} + +func TestTCPClient(t *testing.T) { + conn, err := grpc.Dial("127.0.0.1:8001", grpc.WithInsecure()) + if err != nil { + t.Fatal(err) + } + defer func() { + _ = conn.Close() + }() + + c := pb.NewGreeterClient(conn) + + before := time.Now() + + ctx := context.Background() + ctx = metadata.AppendToOutgoingContext(ctx, "name", "liu", "age", "20") + reply, err := c.SayHello(ctx, &pb.HelloRequest{ + Name: strings.Repeat("golang", 1), + }) + if err != nil { + t.Fatal(err) + } + t.Log(reply.Message) + t.Log(time.Since(before).Seconds()*1000, "ms") +} + +func TestTCPClient_Node(t *testing.T) { + conn, err := grpc.Dial("127.0.0.1:8001", grpc.WithInsecure()) + if err != nil { + t.Fatal(err) + } + defer func() { + _ = conn.Close() + }() + + c := nodepb.NewServiceClient(conn) + + before := time.Now() + + ctx := context.Background() + ctx = metadata.AppendToOutgoingContext(ctx, "name", "liu", "age", "20") + reply, err := c.Node(ctx, &nodepb.NodeRequest{ + }) + if err != nil { + t.Fatal(err) + } + t.Log(reply) + t.Log(time.Since(before).Seconds()*1000, "ms") +} + +func TestTLSServer(t *testing.T) { + listener, err := net.Listen("tcp", ":8001") + if err != nil { + t.Fatal(err) + } + + tlsCred, err := credentials.NewServerTLSFromFile("test.pem", "test.key") + if err != nil { + t.Fatal(err) + } + + s := grpc.NewServer(grpc.Creds(tlsCred)) + pb.RegisterGreeterServer(s, &server{}) + err = s.Serve(listener) + if err != nil { + t.Fatal(err) + } +} + +func TestTLSClient(t *testing.T) { + tlsCred, err := credentials.NewClientTLSFromFile("test.pem", "www.hisock.cn") + if err != nil { + t.Fatal(err) + } + + conn, err := grpc.Dial("127.0.0.1:8001", grpc.WithTransportCredentials(tlsCred)) + if err != nil { + t.Fatal(err) + } + defer func() { + _ = conn.Close() + }() + + c := pb.NewGreeterClient(conn) + + before := time.Now() + + ctx := context.Background() + ctx = metadata.AppendToOutgoingContext(ctx, "name", "liu") + reply, err := c.SayHello(ctx, &pb.HelloRequest{ + Name: strings.Repeat("golang", 1), + }) + if err != nil { + t.Fatal(err) + } + t.Log(reply.Message) + t.Log(time.Since(before).Seconds()*1000, "ms") +} + +func BenchmarkClient(b *testing.B) { + runtime.GOMAXPROCS(1) + + tlsCred, err := credentials.NewClientTLSFromFile("test.pem", "www.hisock.cn") + if err != nil { + b.Fatal(err) + } + conn, err := grpc.Dial("127.0.0.1:8001", grpc.WithTransportCredentials(tlsCred)) + if err != nil { + b.Fatal(err) + } + defer func() { + _ = conn.Close() + }() + + c := pb.NewGreeterClient(conn) + + for i := 0; i < b.N; i++ { + ctx := context.Background() + ctx = metadata.AppendToOutgoingContext(ctx, "name", "liu") + reply, err := c.SayHello(ctx, &pb.HelloRequest{ + Name: "golang", + }) + _, _ = reply, err + } +} diff --git a/internal/tests/hello_service.proto b/internal/tests/hello_service.proto new file mode 100644 index 00000000..b6dcc147 --- /dev/null +++ b/internal/tests/hello_service.proto @@ -0,0 +1,45 @@ +syntax = "proto3"; + +option go_package = "./helloworld"; + +service Greeter { + rpc SayHello (HelloRequest) returns (HelloReply) { + } +} + +message HelloRequest { + string name = 100; + int32 page_number = 101; + repeated int32 ages = 102; +} + +message HelloReply { + string message = 1; +} + +message SearchResult { + string query = 1; + int32 page_number = 2; + int32 result_per_page = 3; + + enum Corpus { + option allow_alias = true; + + UNIVERSAL = 0; + WEB = 1; + IMAGES = 2; + RUNNING = 2; + } + + Corpus corpus = 4; + SearchResponse result = 5; + map resultMap = 6; +} + +message SearchResponse { + reserved 1 to 15; + + int32 count = 16; + bool isOk = 17; + bytes padding = 18; +} \ No newline at end of file diff --git a/internal/tests/helloworld/hello_service.pb.go b/internal/tests/helloworld/hello_service.pb.go new file mode 100644 index 00000000..4fa0ca5a --- /dev/null +++ b/internal/tests/helloworld/hello_service.pb.go @@ -0,0 +1,584 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.12.3 +// source: hello_service.proto + +package helloworld + +import ( + context "context" + proto "github.com/golang/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +type SearchResult_Corpus int32 + +const ( + SearchResult_UNIVERSAL SearchResult_Corpus = 0 + SearchResult_WEB SearchResult_Corpus = 1 + SearchResult_IMAGES SearchResult_Corpus = 2 + SearchResult_RUNNING SearchResult_Corpus = 2 +) + +// Enum value maps for SearchResult_Corpus. +var ( + SearchResult_Corpus_name = map[int32]string{ + 0: "UNIVERSAL", + 1: "WEB", + 2: "IMAGES", + // Duplicate value: 2: "RUNNING", + } + SearchResult_Corpus_value = map[string]int32{ + "UNIVERSAL": 0, + "WEB": 1, + "IMAGES": 2, + "RUNNING": 2, + } +) + +func (x SearchResult_Corpus) Enum() *SearchResult_Corpus { + p := new(SearchResult_Corpus) + *p = x + return p +} + +func (x SearchResult_Corpus) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (SearchResult_Corpus) Descriptor() protoreflect.EnumDescriptor { + return file_hello_service_proto_enumTypes[0].Descriptor() +} + +func (SearchResult_Corpus) Type() protoreflect.EnumType { + return &file_hello_service_proto_enumTypes[0] +} + +func (x SearchResult_Corpus) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use SearchResult_Corpus.Descriptor instead. +func (SearchResult_Corpus) EnumDescriptor() ([]byte, []int) { + return file_hello_service_proto_rawDescGZIP(), []int{2, 0} +} + +type HelloRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,100,opt,name=name,proto3" json:"name,omitempty"` + PageNumber int32 `protobuf:"varint,101,opt,name=page_number,json=pageNumber,proto3" json:"page_number,omitempty"` + Ages []int32 `protobuf:"varint,102,rep,packed,name=ages,proto3" json:"ages,omitempty"` +} + +func (x *HelloRequest) Reset() { + *x = HelloRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_hello_service_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HelloRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HelloRequest) ProtoMessage() {} + +func (x *HelloRequest) ProtoReflect() protoreflect.Message { + mi := &file_hello_service_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead. +func (*HelloRequest) Descriptor() ([]byte, []int) { + return file_hello_service_proto_rawDescGZIP(), []int{0} +} + +func (x *HelloRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *HelloRequest) GetPageNumber() int32 { + if x != nil { + return x.PageNumber + } + return 0 +} + +func (x *HelloRequest) GetAges() []int32 { + if x != nil { + return x.Ages + } + return nil +} + +type HelloReply struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *HelloReply) Reset() { + *x = HelloReply{} + if protoimpl.UnsafeEnabled { + mi := &file_hello_service_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HelloReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HelloReply) ProtoMessage() {} + +func (x *HelloReply) ProtoReflect() protoreflect.Message { + mi := &file_hello_service_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HelloReply.ProtoReflect.Descriptor instead. +func (*HelloReply) Descriptor() ([]byte, []int) { + return file_hello_service_proto_rawDescGZIP(), []int{1} +} + +func (x *HelloReply) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +type SearchResult struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Query string `protobuf:"bytes,1,opt,name=query,proto3" json:"query,omitempty"` + PageNumber int32 `protobuf:"varint,2,opt,name=page_number,json=pageNumber,proto3" json:"page_number,omitempty"` + ResultPerPage int32 `protobuf:"varint,3,opt,name=result_per_page,json=resultPerPage,proto3" json:"result_per_page,omitempty"` + Corpus SearchResult_Corpus `protobuf:"varint,4,opt,name=corpus,proto3,enum=SearchResult_Corpus" json:"corpus,omitempty"` + Result *SearchResponse `protobuf:"bytes,5,opt,name=result,proto3" json:"result,omitempty"` + ResultMap map[string]*SearchResponse `protobuf:"bytes,6,rep,name=resultMap,proto3" json:"resultMap,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *SearchResult) Reset() { + *x = SearchResult{} + if protoimpl.UnsafeEnabled { + mi := &file_hello_service_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SearchResult) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SearchResult) ProtoMessage() {} + +func (x *SearchResult) ProtoReflect() protoreflect.Message { + mi := &file_hello_service_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SearchResult.ProtoReflect.Descriptor instead. +func (*SearchResult) Descriptor() ([]byte, []int) { + return file_hello_service_proto_rawDescGZIP(), []int{2} +} + +func (x *SearchResult) GetQuery() string { + if x != nil { + return x.Query + } + return "" +} + +func (x *SearchResult) GetPageNumber() int32 { + if x != nil { + return x.PageNumber + } + return 0 +} + +func (x *SearchResult) GetResultPerPage() int32 { + if x != nil { + return x.ResultPerPage + } + return 0 +} + +func (x *SearchResult) GetCorpus() SearchResult_Corpus { + if x != nil { + return x.Corpus + } + return SearchResult_UNIVERSAL +} + +func (x *SearchResult) GetResult() *SearchResponse { + if x != nil { + return x.Result + } + return nil +} + +func (x *SearchResult) GetResultMap() map[string]*SearchResponse { + if x != nil { + return x.ResultMap + } + return nil +} + +type SearchResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Count int32 `protobuf:"varint,16,opt,name=count,proto3" json:"count,omitempty"` + IsOk bool `protobuf:"varint,17,opt,name=isOk,proto3" json:"isOk,omitempty"` + Padding []byte `protobuf:"bytes,18,opt,name=padding,proto3" json:"padding,omitempty"` +} + +func (x *SearchResponse) Reset() { + *x = SearchResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_hello_service_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SearchResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SearchResponse) ProtoMessage() {} + +func (x *SearchResponse) ProtoReflect() protoreflect.Message { + mi := &file_hello_service_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SearchResponse.ProtoReflect.Descriptor instead. +func (*SearchResponse) Descriptor() ([]byte, []int) { + return file_hello_service_proto_rawDescGZIP(), []int{3} +} + +func (x *SearchResponse) GetCount() int32 { + if x != nil { + return x.Count + } + return 0 +} + +func (x *SearchResponse) GetIsOk() bool { + if x != nil { + return x.IsOk + } + return false +} + +func (x *SearchResponse) GetPadding() []byte { + if x != nil { + return x.Padding + } + return nil +} + +var File_hello_service_proto protoreflect.FileDescriptor + +var file_hello_service_proto_rawDesc = []byte{ + 0x0a, 0x13, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x57, 0x0a, 0x0c, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x64, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x61, 0x67, + 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x65, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, + 0x70, 0x61, 0x67, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x61, 0x67, + 0x65, 0x73, 0x18, 0x66, 0x20, 0x03, 0x28, 0x05, 0x52, 0x04, 0x61, 0x67, 0x65, 0x73, 0x22, 0x26, + 0x0a, 0x0a, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, 0x0a, 0x07, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x8e, 0x03, 0x0a, 0x0c, 0x53, 0x65, 0x61, 0x72, 0x63, + 0x68, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, 0x1f, 0x0a, + 0x0b, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x26, + 0x0a, 0x0f, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x70, 0x61, 0x67, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x50, + 0x65, 0x72, 0x50, 0x61, 0x67, 0x65, 0x12, 0x2c, 0x0a, 0x06, 0x63, 0x6f, 0x72, 0x70, 0x75, 0x73, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, + 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2e, 0x43, 0x6f, 0x72, 0x70, 0x75, 0x73, 0x52, 0x06, 0x63, 0x6f, + 0x72, 0x70, 0x75, 0x73, 0x12, 0x27, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x3a, 0x0a, + 0x09, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x4d, 0x61, 0x70, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x1c, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2e, + 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x4d, 0x61, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, + 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x4d, 0x61, 0x70, 0x1a, 0x4d, 0x0a, 0x0e, 0x52, 0x65, 0x73, + 0x75, 0x6c, 0x74, 0x4d, 0x61, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, + 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x25, 0x0a, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x53, + 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x3d, 0x0a, 0x06, 0x43, 0x6f, 0x72, 0x70, + 0x75, 0x73, 0x12, 0x0d, 0x0a, 0x09, 0x55, 0x4e, 0x49, 0x56, 0x45, 0x52, 0x53, 0x41, 0x4c, 0x10, + 0x00, 0x12, 0x07, 0x0a, 0x03, 0x57, 0x45, 0x42, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x49, 0x4d, + 0x41, 0x47, 0x45, 0x53, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x52, 0x55, 0x4e, 0x4e, 0x49, 0x4e, + 0x47, 0x10, 0x02, 0x1a, 0x02, 0x10, 0x01, 0x22, 0x5a, 0x0a, 0x0e, 0x53, 0x65, 0x61, 0x72, 0x63, + 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x18, 0x10, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, + 0x12, 0x0a, 0x04, 0x69, 0x73, 0x4f, 0x6b, 0x18, 0x11, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, + 0x73, 0x4f, 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x18, 0x12, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x4a, 0x04, 0x08, + 0x01, 0x10, 0x10, 0x32, 0x33, 0x0a, 0x07, 0x47, 0x72, 0x65, 0x65, 0x74, 0x65, 0x72, 0x12, 0x28, + 0x0a, 0x08, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12, 0x0d, 0x2e, 0x48, 0x65, 0x6c, + 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0b, 0x2e, 0x48, 0x65, 0x6c, 0x6c, + 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, 0x0e, 0x5a, 0x0c, 0x2e, 0x2f, 0x68, 0x65, + 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_hello_service_proto_rawDescOnce sync.Once + file_hello_service_proto_rawDescData = file_hello_service_proto_rawDesc +) + +func file_hello_service_proto_rawDescGZIP() []byte { + file_hello_service_proto_rawDescOnce.Do(func() { + file_hello_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_hello_service_proto_rawDescData) + }) + return file_hello_service_proto_rawDescData +} + +var file_hello_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_hello_service_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_hello_service_proto_goTypes = []interface{}{ + (SearchResult_Corpus)(0), // 0: SearchResult.Corpus + (*HelloRequest)(nil), // 1: HelloRequest + (*HelloReply)(nil), // 2: HelloReply + (*SearchResult)(nil), // 3: SearchResult + (*SearchResponse)(nil), // 4: SearchResponse + nil, // 5: SearchResult.ResultMapEntry +} +var file_hello_service_proto_depIdxs = []int32{ + 0, // 0: SearchResult.corpus:type_name -> SearchResult.Corpus + 4, // 1: SearchResult.result:type_name -> SearchResponse + 5, // 2: SearchResult.resultMap:type_name -> SearchResult.ResultMapEntry + 4, // 3: SearchResult.ResultMapEntry.value:type_name -> SearchResponse + 1, // 4: Greeter.SayHello:input_type -> HelloRequest + 2, // 5: Greeter.SayHello:output_type -> HelloReply + 5, // [5:6] is the sub-list for method output_type + 4, // [4:5] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file_hello_service_proto_init() } +func file_hello_service_proto_init() { + if File_hello_service_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_hello_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HelloRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_hello_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HelloReply); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_hello_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SearchResult); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_hello_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SearchResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_hello_service_proto_rawDesc, + NumEnums: 1, + NumMessages: 5, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_hello_service_proto_goTypes, + DependencyIndexes: file_hello_service_proto_depIdxs, + EnumInfos: file_hello_service_proto_enumTypes, + MessageInfos: file_hello_service_proto_msgTypes, + }.Build() + File_hello_service_proto = out.File + file_hello_service_proto_rawDesc = nil + file_hello_service_proto_goTypes = nil + file_hello_service_proto_depIdxs = nil +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConnInterface + +// 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.SupportPackageIsVersion6 + +// GreeterClient is the client API for Greeter service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type GreeterClient interface { + SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) +} + +type greeterClient struct { + cc grpc.ClientConnInterface +} + +func NewGreeterClient(cc grpc.ClientConnInterface) GreeterClient { + return &greeterClient{cc} +} + +func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) { + out := new(HelloReply) + err := c.cc.Invoke(ctx, "/Greeter/SayHello", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// GreeterServer is the server API for Greeter service. +type GreeterServer interface { + SayHello(context.Context, *HelloRequest) (*HelloReply, error) +} + +// UnimplementedGreeterServer can be embedded to have forward compatible implementations. +type UnimplementedGreeterServer struct { +} + +func (*UnimplementedGreeterServer) SayHello(context.Context, *HelloRequest) (*HelloReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented") +} + +func RegisterGreeterServer(s *grpc.Server, srv GreeterServer) { + s.RegisterService(&_Greeter_serviceDesc, srv) +} + +func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(HelloRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GreeterServer).SayHello(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/Greeter/SayHello", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GreeterServer).SayHello(ctx, req.(*HelloRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Greeter_serviceDesc = grpc.ServiceDesc{ + ServiceName: "Greeter", + HandlerType: (*GreeterServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "SayHello", + Handler: _Greeter_SayHello_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "hello_service.proto", +} diff --git a/internal/tests/test.key b/internal/tests/test.key new file mode 100644 index 00000000..4ef8ca19 --- /dev/null +++ b/internal/tests/test.key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEAyGF004EdKgfzTOzE52+0GRLbnrT/40AcxTG2KWd4wwdANltP +zX5NmUlH3mDJQtcLS9FzFwsIUGa3vCDCFL+b9GtM5695boykzj731amVVrv86yIL +jsYk3CtFMuEEIn7qoxfYl/P/4IJOeQN6z/yodAHYGR8QRGnjqfo6ZtPOUheo6QN/ +8O2n176KsQ67lU/854oxjFZmzAgD1gnwCxVupwQkcNB7hkKW8dhEHR9oAGnEbZnJ +vPHqftwfMMDZ/0RIwIN31g17MNREC30VLEfPqIL6+a9S77yBXvTEIGSvdKetAe68 +4KJFgLw9EBeAk320buec+IW2cYVc2ZFTt+Y9kQIDAQABAoIBAQCqu17vV3Oh/GQx +hwu+pk6tjoPSFiZxWo8o9dJgNOmQQv1TUzoLvTIhCW9S6uSRLulREIUffSb4Wozy +nna/dwNKnqJIRhsRNoS1trE0O+oinMpDDh8K54lAjx3G3DLJsZn6nLbPwfajNGPo +eC6MSJq/PVMDFJSnthFlIu/f7Vg+WKf9jLhuRiBaAU/7PWMAo2XQ3e9/U0+4jbRY +bkNd3txE/o6eaVU9TpVw8j+nFQz5AAPLiprc72OobscMdThuB7SqRZSxBtJD7e6c +Pj71Uh6sJyeku9Gzhmc3dDGH3MqR82bXpDxZK0Vbee859VHITtA296zMCERfYviX +l1SNiA6BAoGBAO5Ie+nn1mnRKT9gtvOwt9uV/Fx2wz50Ff5x/w1Yc60LBOqKfUPz +Yb1FshUXsr4GIYkPtaB5aygwkc7EA6DT8bBrnfRxHet6Lvrs0eo3BCQQ0WuSkILs +vnLGrCqVUYH35tHVQeSCzZD5zKAiTxMZ8P+wkXxHPL8O4tn0Nj3uN5gzAoGBANdH +iBJ21Sh1oZJVta4U+j8Burjt857ToSCmV1aJ/AGzo+LFWnZVPqfLgjz9HTRnE995 +/hk9Bj4ph5DZnHxYXEPk1yQURMglQp1trwEOtnLTYDHltfZgxeSlp5+ThKSLSVMg +41PnZ7XRBnMsZ7H/Me4UH2O4OvRE931+Jjc22J8rAoGAf6p0QZFGTrGS4PMHcq8n +As5sRHoZB5gYxJf9KABREdCKlMMYdFSs9ESoMibdTHRqeU3iaRVEtWa4aEibDQsh +Pf2axoHonuZ6z1Qc79kELfKY0YLYTF1deI87ZSFVZ0YT9C7HPBBc5SUBXnajWT+X +4NaQTD66rD7kihQPD8VXIgMCgYAQFSf1OStzelY3uG96MdcAHgD1D9HDa8v9xG+B +540ME3+K0XOQo42qu2lfZQlpgMnbSCHTgNuWiUO3bopiP7ek2tO3vkvlJ+NyH1+T +lKXMrj3hfGe7oD8odbewFDU0lbNEopBZFFCLJLJ2qDqW8ZmpT5eIu5qr5PsYRPRV +66MDQQKBgQDlD6s/IuO4qcYUqMrCPNylrLum0sPhilKPco17rA2noPSN3ZUMuOmM +pdPr7A2fSD0DlQBerqYR9xU5IBoFy6d4ydgg2l9yEV4Kfst6Uk4Wt2gGeK4g23D9 +rF8QXWiC0WxZrVvcZGjkkC+V7+h6N2Inx7B/Tm4fx34S4gceTc96TQ== +-----END RSA PRIVATE KEY----- diff --git a/internal/tests/test.pem b/internal/tests/test.pem new file mode 100644 index 00000000..7e3512c5 --- /dev/null +++ b/internal/tests/test.pem @@ -0,0 +1,59 @@ +-----BEGIN CERTIFICATE----- +MIIFWzCCBEOgAwIBAgISAya7q7j/K6bMXyBNh9/QlwDwMA0GCSqGSIb3DQEBCwUA +MEoxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MSMwIQYDVQQD +ExpMZXQncyBFbmNyeXB0IEF1dGhvcml0eSBYMzAeFw0yMDA0MTEwMzQ0MDBaFw0y +MDA3MTAwMzQ0MDBaMBYxFDASBgNVBAMMCyouaGlzb2NrLmNuMIIBIjANBgkqhkiG +9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyGF004EdKgfzTOzE52+0GRLbnrT/40AcxTG2 +KWd4wwdANltPzX5NmUlH3mDJQtcLS9FzFwsIUGa3vCDCFL+b9GtM5695boykzj73 +1amVVrv86yILjsYk3CtFMuEEIn7qoxfYl/P/4IJOeQN6z/yodAHYGR8QRGnjqfo6 +ZtPOUheo6QN/8O2n176KsQ67lU/854oxjFZmzAgD1gnwCxVupwQkcNB7hkKW8dhE +HR9oAGnEbZnJvPHqftwfMMDZ/0RIwIN31g17MNREC30VLEfPqIL6+a9S77yBXvTE +IGSvdKetAe684KJFgLw9EBeAk320buec+IW2cYVc2ZFTt+Y9kQIDAQABo4ICbTCC +AmkwDgYDVR0PAQH/BAQDAgWgMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcD +AjAMBgNVHRMBAf8EAjAAMB0GA1UdDgQWBBRNnY2JEuxA8WOvWIVxU08xE+pSujAf +BgNVHSMEGDAWgBSoSmpjBH3duubRObemRWXv86jsoTBvBggrBgEFBQcBAQRjMGEw +LgYIKwYBBQUHMAGGImh0dHA6Ly9vY3NwLmludC14My5sZXRzZW5jcnlwdC5vcmcw +LwYIKwYBBQUHMAKGI2h0dHA6Ly9jZXJ0LmludC14My5sZXRzZW5jcnlwdC5vcmcv +MCUGA1UdEQQeMByCDSouMS5oaXNvY2suY26CCyouaGlzb2NrLmNuMEwGA1UdIARF +MEMwCAYGZ4EMAQIBMDcGCysGAQQBgt8TAQEBMCgwJgYIKwYBBQUHAgEWGmh0dHA6 +Ly9jcHMubGV0c2VuY3J5cHQub3JnMIIBAgYKKwYBBAHWeQIEAgSB8wSB8ADuAHUA +Xqdz+d9WwOe1Nkh90EngMnqRmgyEoRIShBh1loFxRVgAAAFxZ404NAAABAMARjBE +AiAmqdQZGxJtUTCfyKI6mh2VymCUMegXNCdMdpJWDzQImAIgEhLnTIAj55MrVjK6 +WWV3Qv2I0gk0V3eyMTmrzLT1S5kAdQAHt1wb5X1o//Gwxh0jFce65ld8V5S3au68 +YToaadOiHAAAAXFnjThUAAAEAwBGMEQCIFcXE/LoKVigRA0sHniakOI0VCZwIwn5 +JD3GtGpRMUcHAiBsZXZBASo3zRkeKtLWbEfZqqru26CLZ2QPHXe2A6H8XjANBgkq +hkiG9w0BAQsFAAOCAQEAHut9Jbmui+Yrffiyuk6RKZhOHcSeCred3iQt8U+jsbHM +EuLXSfFnuTjRFLyvPdr4sTjf4ZHKwBe1fjHQVc3Qh0hw+K/2S8n6PfP/Zh8VJ9Vx +2i4tepZVkspXqR6uIgnPbm4QIQ+MEwzq73PtEI/wawE9Chj4eZ7hSSAO2D2O9qgT +wEq+Y2F57gazZgLMk4krUruDj3jDDWQda2SJ1sidVdP8UpOCqNmYHBH1y+PJZ2A9 +iDBjIFNfTvNc75UFlWvPgzf7rLKt/Sxf183CqN08LagnLg8tVUICDaJN9F3vGYjA +NkGNMZ9CwG9hj9MVAZcCiFiYhqO2gVQUzRhRmRTMzA== +-----END CERTIFICATE----- + +-----BEGIN CERTIFICATE----- +MIIEkjCCA3qgAwIBAgIQCgFBQgAAAVOFc2oLheynCDANBgkqhkiG9w0BAQsFADA/ +MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT +DkRTVCBSb290IENBIFgzMB4XDTE2MDMxNzE2NDA0NloXDTIxMDMxNzE2NDA0Nlow +SjELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUxldCdzIEVuY3J5cHQxIzAhBgNVBAMT +GkxldCdzIEVuY3J5cHQgQXV0aG9yaXR5IFgzMIIBIjANBgkqhkiG9w0BAQEFAAOC +AQ8AMIIBCgKCAQEAnNMM8FrlLke3cl03g7NoYzDq1zUmGSXhvb418XCSL7e4S0EF +q6meNQhY7LEqxGiHC6PjdeTm86dicbp5gWAf15Gan/PQeGdxyGkOlZHP/uaZ6WA8 +SMx+yk13EiSdRxta67nsHjcAHJyse6cF6s5K671B5TaYucv9bTyWaN8jKkKQDIZ0 +Z8h/pZq4UmEUEz9l6YKHy9v6Dlb2honzhT+Xhq+w3Brvaw2VFn3EK6BlspkENnWA +a6xK8xuQSXgvopZPKiAlKQTGdMDQMc2PMTiVFrqoM7hD8bEfwzB/onkxEz0tNvjj +/PIzark5McWvxI0NHWQWM6r6hCm21AvA2H3DkwIDAQABo4IBfTCCAXkwEgYDVR0T +AQH/BAgwBgEB/wIBADAOBgNVHQ8BAf8EBAMCAYYwfwYIKwYBBQUHAQEEczBxMDIG +CCsGAQUFBzABhiZodHRwOi8vaXNyZy50cnVzdGlkLm9jc3AuaWRlbnRydXN0LmNv +bTA7BggrBgEFBQcwAoYvaHR0cDovL2FwcHMuaWRlbnRydXN0LmNvbS9yb290cy9k +c3Ryb290Y2F4My5wN2MwHwYDVR0jBBgwFoAUxKexpHsscfrb4UuQdf/EFWCFiRAw +VAYDVR0gBE0wSzAIBgZngQwBAgEwPwYLKwYBBAGC3xMBAQEwMDAuBggrBgEFBQcC +ARYiaHR0cDovL2Nwcy5yb290LXgxLmxldHNlbmNyeXB0Lm9yZzA8BgNVHR8ENTAz +MDGgL6AthitodHRwOi8vY3JsLmlkZW50cnVzdC5jb20vRFNUUk9PVENBWDNDUkwu +Y3JsMB0GA1UdDgQWBBSoSmpjBH3duubRObemRWXv86jsoTANBgkqhkiG9w0BAQsF +AAOCAQEA3TPXEfNjWDjdGBX7CVW+dla5cEilaUcne8IkCJLxWh9KEik3JHRRHGJo +uM2VcGfl96S8TihRzZvoroed6ti6WqEBmtzw3Wodatg+VyOeph4EYpr/1wXKtx8/ +wApIvJSwtmVi4MFU5aMqrSDE6ea73Mj2tcMyo5jMd6jmeWUHK8so/joWUoHOUgwu +X4Po1QYz+3dszkDqMp4fklxBwXRsW10KXzPMTZ+sOPAveyxindmjkW8lGy+QsRlG +PfZ+G6Z6h7mjem0Y+iWlkYcV4PIWL1iwBi8saCbGS5jN2p8M+X+Q7UNKEkROb3N6 +KOqkqm57TH2H3eDJAkSnh6/DNFu0Qg== +-----END CERTIFICATE-----