Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2021-02-28 01:45:22 +03:00
parent bca1d3570f
commit b5c7da9b7e
6 changed files with 38 additions and 27 deletions

3
go.mod
View File

@ -24,7 +24,7 @@ require (
github.com/unistack-org/micro-config-env/v3 v3.2.4 github.com/unistack-org/micro-config-env/v3 v3.2.4
github.com/unistack-org/micro-config-vault/v3 v3.2.4 github.com/unistack-org/micro-config-vault/v3 v3.2.4
github.com/unistack-org/micro-metrics-prometheus/v3 v3.1.1 github.com/unistack-org/micro-metrics-prometheus/v3 v3.1.1
github.com/unistack-org/micro-proto v0.0.1 github.com/unistack-org/micro-proto v0.0.2-0.20210227213711-77c7563bd01e
github.com/unistack-org/micro-router-register/v3 v3.2.2 github.com/unistack-org/micro-router-register/v3 v3.2.2
github.com/unistack-org/micro-server-grpc/v3 v3.2.3 github.com/unistack-org/micro-server-grpc/v3 v3.2.3
github.com/unistack-org/micro-server-http/v3 v3.2.6 github.com/unistack-org/micro-server-http/v3 v3.2.6
@ -42,3 +42,4 @@ require (
//replace github.com/unistack-org/micro-server-http/v3 => ../micro-server-http //replace github.com/unistack-org/micro-server-http/v3 => ../micro-server-http
//replace github.com/unistack-org/micro-client-http/v3 => ../micro-client-http //replace github.com/unistack-org/micro-client-http/v3 => ../micro-client-http
//replace github.com/unistack-org/micro/v3 => ../micro //replace github.com/unistack-org/micro/v3 => ../micro
//replace github.com/unistack-org/micro-proto => ../micro-proto

4
go.sum
View File

@ -467,8 +467,8 @@ github.com/unistack-org/micro-config-vault/v3 v3.2.4 h1:HUOsVbQoki8YdISUVk3jzTgK
github.com/unistack-org/micro-config-vault/v3 v3.2.4/go.mod h1:Xbj5R5psic0Dyuh7SrJqvFv0hSIHYKHx91p96rn/lxk= github.com/unistack-org/micro-config-vault/v3 v3.2.4/go.mod h1:Xbj5R5psic0Dyuh7SrJqvFv0hSIHYKHx91p96rn/lxk=
github.com/unistack-org/micro-metrics-prometheus/v3 v3.1.1 h1:AZVQ8l1p1pIUyImQo/if/5t1g9C9du9ulMRqATSmgGo= github.com/unistack-org/micro-metrics-prometheus/v3 v3.1.1 h1:AZVQ8l1p1pIUyImQo/if/5t1g9C9du9ulMRqATSmgGo=
github.com/unistack-org/micro-metrics-prometheus/v3 v3.1.1/go.mod h1:QfquVeYZ2+BqBQ5bv1+uFAeWFiacvwanRDy3nGVqo3c= github.com/unistack-org/micro-metrics-prometheus/v3 v3.1.1/go.mod h1:QfquVeYZ2+BqBQ5bv1+uFAeWFiacvwanRDy3nGVqo3c=
github.com/unistack-org/micro-proto v0.0.1 h1:1d9O8d3/ZITQPwIQCvZ+2OCDjVP0iaX+gv5klbwkE/I= github.com/unistack-org/micro-proto v0.0.2-0.20210227213711-77c7563bd01e h1:hQJ3V0QggeFdU5967wO5v6oWnaK42wUnG4UU4zWcyu4=
github.com/unistack-org/micro-proto v0.0.1/go.mod h1:GYO53DWmeldRIo90cAdQx8bLr/WJMxW62W4ja74p1Ac= github.com/unistack-org/micro-proto v0.0.2-0.20210227213711-77c7563bd01e/go.mod h1:GYO53DWmeldRIo90cAdQx8bLr/WJMxW62W4ja74p1Ac=
github.com/unistack-org/micro-router-register/v3 v3.2.2 h1:lYCymDHkJfhZWYQ4+Sb7Fu+NlqoysQCnpJytHGhdnws= github.com/unistack-org/micro-router-register/v3 v3.2.2 h1:lYCymDHkJfhZWYQ4+Sb7Fu+NlqoysQCnpJytHGhdnws=
github.com/unistack-org/micro-router-register/v3 v3.2.2/go.mod h1:Y9Qtlg4NHqq5rR6X6Jm+04LoSJMi7/OOCm2mRueZYTE= github.com/unistack-org/micro-router-register/v3 v3.2.2/go.mod h1:Y9Qtlg4NHqq5rR6X6Jm+04LoSJMi7/OOCm2mRueZYTE=
github.com/unistack-org/micro-server-grpc/v3 v3.2.3 h1:Q6zBB4ipgI6yptC0b7jyXULuRQ4s7sLfSmEbUWYOBUQ= github.com/unistack-org/micro-server-grpc/v3 v3.2.3 h1:Q6zBB4ipgI6yptC0b7jyXULuRQ4s7sLfSmEbUWYOBUQ=

View File

@ -1,3 +1,5 @@
package http package http
//go:generate protoc -I./proto -I. -I/home/vtolstov/.cache/go-path/pkg/mod/github.com/unistack-org/micro-proto@v0.0.1 --go_out=paths=source_relative:./proto --micro_out=components=micro|http,debug=true,paths=source_relative:./proto proto/test.proto ///go:generate protoc -I./proto -I. -I/home/vtolstov/.cache/go-path/pkg/mod/github.com/unistack-org/micro-proto@v0.0.1 --go_out=paths=source_relative:./proto --micro_out=components=micro|http,debug=true,paths=source_relative:./proto proto/test.proto
//go:generate protoc -I./proto -I. -I/home/vtolstov/devel/projects/unistack/micro/micro-proto --go_out=paths=source_relative:./proto --micro_out=components=micro|http,debug=true,paths=source_relative:./proto proto/test.proto

View File

@ -390,29 +390,30 @@ var file_test_proto_rawDesc = []byte{
0x0a, 0x08, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x73, 0x70, 0x31, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x73, 0x0a, 0x08, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x73, 0x70, 0x31, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x73,
0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x72, 0x73, 0x70, 0x22, 0x19, 0x0a, 0x05, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x72, 0x73, 0x70, 0x22, 0x19, 0x0a, 0x05,
0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x01, 0x20, 0x01, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x32, 0x94, 0x02, 0x0a, 0x04, 0x54, 0x65, 0x73, 0x74, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x32, 0xaf, 0x02, 0x0a, 0x04, 0x54, 0x65, 0x73, 0x74,
0x12, 0x7c, 0x0a, 0x04, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x0d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x12, 0x84, 0x01, 0x0a, 0x04, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x0d, 0x2e, 0x74, 0x65, 0x73, 0x74,
0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x0d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x43, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x0d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e,
0x61, 0x6c, 0x6c, 0x52, 0x73, 0x70, 0x22, 0x56, 0x92, 0x41, 0x34, 0x2a, 0x04, 0x43, 0x61, 0x6c, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x73, 0x70, 0x22, 0x5e, 0x92, 0x41, 0x34, 0x2a, 0x04, 0x43, 0x61,
0x6c, 0x4a, 0x2c, 0x0a, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x21, 0x0a, 0x0e, 0x6c, 0x6c, 0x4a, 0x2c, 0x0a, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x21, 0x0a,
0x45, 0x72, 0x72, 0x6f, 0x72, 0x20, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0f, 0x0e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x20, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x0a, 0x0d, 0x1a, 0x0b, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x82, 0x0f, 0x0a, 0x0d, 0x1a, 0x0b, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72,
0xd3, 0xe4, 0x93, 0x02, 0x19, 0x22, 0x14, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x19, 0x22, 0x14, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x65, 0x73, 0x74,
0x63, 0x61, 0x6c, 0x6c, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x7d, 0x3a, 0x01, 0x2a, 0x12, 0x8d, 0x2f, 0x63, 0x61, 0x6c, 0x6c, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x7d, 0x3a, 0x01, 0x2a, 0xba,
0x01, 0x0a, 0x09, 0x43, 0x61, 0x6c, 0x6c, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x0e, 0x2e, 0x74, 0xea, 0xff, 0xf9, 0x01, 0x02, 0x08, 0x05, 0x12, 0x8d, 0x01, 0x0a, 0x09, 0x43, 0x61, 0x6c, 0x6c,
0x65, 0x73, 0x74, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x31, 0x1a, 0x0e, 0x2e, 0x74, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x0e, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x43, 0x61, 0x6c,
0x65, 0x73, 0x74, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x73, 0x70, 0x31, 0x22, 0x60, 0x92, 0x41, 0x6c, 0x52, 0x65, 0x71, 0x31, 0x1a, 0x0e, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x43, 0x61, 0x6c,
0x39, 0x2a, 0x09, 0x43, 0x61, 0x6c, 0x6c, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4a, 0x2c, 0x0a, 0x07, 0x6c, 0x52, 0x73, 0x70, 0x31, 0x22, 0x60, 0x92, 0x41, 0x39, 0x2a, 0x09, 0x43, 0x61, 0x6c, 0x6c,
0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x21, 0x0a, 0x0e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4a, 0x2c, 0x0a, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74,
0x20, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0f, 0x0a, 0x0d, 0x1a, 0x0b, 0x2e, 0x12, 0x21, 0x0a, 0x0e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x20, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x74, 0x65, 0x73, 0x74, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1e, 0x73, 0x65, 0x12, 0x0f, 0x0a, 0x0d, 0x1a, 0x0b, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x45, 0x72,
0x22, 0x19, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x63, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x6f, 0x72, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1e, 0x22, 0x19, 0x2f, 0x76, 0x31, 0x2f, 0x74,
0x72, 0x72, 0x6f, 0x72, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x7d, 0x3a, 0x01, 0x2a, 0x42, 0x3a, 0x65, 0x73, 0x74, 0x2f, 0x63, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x2f, 0x7b, 0x6e,
0x5a, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x75, 0x6e, 0x69, 0x61, 0x6d, 0x65, 0x7d, 0x3a, 0x01, 0x2a, 0x1a, 0x10, 0xba, 0xea, 0xff, 0xf9, 0x01, 0x0a, 0x12,
0x73, 0x74, 0x61, 0x63, 0x6b, 0x2d, 0x6f, 0x72, 0x67, 0x2f, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2d, 0x03, 0x6f, 0x6e, 0x65, 0x12, 0x03, 0x74, 0x77, 0x6f, 0x42, 0x3a, 0x5a, 0x38, 0x67, 0x69, 0x74,
0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x68, 0x74, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x75, 0x6e, 0x69, 0x73, 0x74, 0x61, 0x63, 0x6b,
0x70, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x2d, 0x6f, 0x72, 0x67, 0x2f, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2d, 0x74, 0x65, 0x73, 0x74, 0x73,
0x6f, 0x33, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x68, 0x74, 0x74, 0x70, 0x2f, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (

View File

@ -9,6 +9,7 @@ import "openapiv2/annotations.proto";
import "google/protobuf/wrappers.proto"; import "google/protobuf/wrappers.proto";
service Test { service Test {
option (micro.api.micro_service) = { client_wrappers: ["one","two"]; };
rpc Call(CallReq) returns (CallRsp) { rpc Call(CallReq) returns (CallRsp) {
option (micro.openapiv2.openapiv2_operation) = { option (micro.openapiv2.openapiv2_operation) = {
operation_id: "Call"; operation_id: "Call";
@ -25,6 +26,7 @@ service Test {
} }
}; };
option (micro.api.http) = { post: "/v1/test/call/{name}"; body: "*"; }; option (micro.api.http) = { post: "/v1/test/call/{name}"; body: "*"; };
option (micro.api.micro_method) = { timeout: 5; };
}; };
rpc CallError(CallReq1) returns (CallRsp1) { rpc CallError(CallReq1) returns (CallRsp1) {
option (micro.openapiv2.openapiv2_operation) = { option (micro.openapiv2.openapiv2_operation) = {

View File

@ -8,6 +8,7 @@ import (
api "github.com/unistack-org/micro/v3/api" api "github.com/unistack-org/micro/v3/api"
client "github.com/unistack-org/micro/v3/client" client "github.com/unistack-org/micro/v3/client"
server "github.com/unistack-org/micro/v3/server" server "github.com/unistack-org/micro/v3/server"
time "time"
) )
type testClient struct { type testClient struct {
@ -28,6 +29,7 @@ func (c *testClient) Call(ctx context.Context, req *CallReq, opts ...client.Call
v3.Path("/v1/test/call/{name}"), v3.Path("/v1/test/call/{name}"),
v3.Body("*"), v3.Body("*"),
) )
opts = append(opts, client.WithRequestTimeout(time.Second*5))
rsp := &CallRsp{} rsp := &CallRsp{}
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Test.Call", req), rsp, opts...) err := c.c.Call(ctx, c.c.NewRequest(c.name, "Test.Call", req), rsp, opts...)
if err != nil { if err != nil {
@ -58,6 +60,9 @@ type testServer struct {
} }
func (h *testServer) Call(ctx context.Context, req *CallReq, rsp *CallRsp) error { func (h *testServer) Call(ctx context.Context, req *CallReq, rsp *CallRsp) error {
var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(ctx, time.Second*5)
defer cancel()
return h.TestServer.Call(ctx, req, rsp) return h.TestServer.Call(ctx, req, rsp)
} }