5 Commits
v4 ... v3.8.0

Author SHA1 Message Date
5758c7dfd5 Merge pull request #31 from unistack-org/fix
fix drpc method passing
2022-03-21 12:55:40 +03:00
de02d636ad fix drpc method passing
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-03-21 12:53:33 +03:00
6f4e54a876 fix drpc method passing
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-03-21 12:48:06 +03:00
dependabot[bot]
47c8975a12 chore(deps): bump storj.io/drpc from 0.0.29 to 0.0.30 (#30)
Bumps [storj.io/drpc](https://github.com/storj/drpc) from 0.0.29 to 0.0.30.
- [Release notes](https://github.com/storj/drpc/releases)
- [Commits](https://github.com/storj/drpc/compare/v0.0.29...v0.0.30)

---
updated-dependencies:
- dependency-name: storj.io/drpc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-19 12:01:22 +03:00
1228768700 update go version
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-03-07 13:44:59 +03:00
8 changed files with 19 additions and 20 deletions

View File

@@ -12,7 +12,7 @@ jobs:
- name: setup - name: setup
uses: actions/setup-go@v2 uses: actions/setup-go@v2
with: with:
go-version: 1.16 go-version: 1.17
- name: checkout - name: checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: cache - name: cache

View File

@@ -47,7 +47,7 @@ jobs:
- name: setup - name: setup
uses: actions/setup-go@v2 uses: actions/setup-go@v2
with: with:
go-version: 1.16 go-version: 1.17
# Initializes the CodeQL tools for scanning. # Initializes the CodeQL tools for scanning.
- name: init - name: init
uses: github/codeql-action/init@v1 uses: github/codeql-action/init@v1

View File

@@ -12,7 +12,7 @@ jobs:
- name: setup - name: setup
uses: actions/setup-go@v2 uses: actions/setup-go@v2
with: with:
go-version: 1.16 go-version: 1.17
- name: checkout - name: checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: cache - name: cache

View File

@@ -30,6 +30,9 @@ type drpcClient struct {
func (d *drpcClient) call(ctx context.Context, addr string, req client.Request, rsp interface{}, opts client.CallOptions) error { func (d *drpcClient) call(ctx context.Context, addr string, req client.Request, rsp interface{}, opts client.CallOptions) error {
var header map[string]string var header map[string]string
if strings.HasPrefix(addr, "http") {
addr = addr[strings.Index(addr, ":")+3:]
}
if md, ok := metadata.FromOutgoingContext(ctx); ok { if md, ok := metadata.FromOutgoingContext(ctx); ok {
header = make(map[string]string, len(md)) header = make(map[string]string, len(md))
@@ -90,6 +93,7 @@ func (d *drpcClient) call(ctx context.Context, addr string, req client.Request,
*/ */
ch := make(chan error, 1) ch := make(chan error, 1)
_ = dialCtx _ = dialCtx
// rc, err := net.DialContext(ctx, "tcp", addr) // rc, err := net.DialContext(ctx, "tcp", addr)
rc, err := net.Dial("tcp", addr) rc, err := net.Dial("tcp", addr)
if err != nil { if err != nil {

2
go.mod
View File

@@ -4,5 +4,5 @@ go 1.16
require ( require (
go.unistack.org/micro/v3 v3.8.21 go.unistack.org/micro/v3 v3.8.21
storj.io/drpc v0.0.29 storj.io/drpc v0.0.30
) )

4
go.sum
View File

@@ -153,5 +153,5 @@ gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 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= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
storj.io/drpc v0.0.29 h1:Ihd4ls/JQFr0lctefie3iu+3QM4duccCKr9uMzf4sKY= storj.io/drpc v0.0.30 h1:jqPe4T9KEu3CDBI05A2hCMgMSHLtd/E0N0yTF9QreIE=
storj.io/drpc v0.0.29/go.mod h1:6rcOyR/QQkSTX/9L5ZGtlZaE2PtXTTZl8d+ulSeeYEg= storj.io/drpc v0.0.30/go.mod h1:6rcOyR/QQkSTX/9L5ZGtlZaE2PtXTTZl8d+ulSeeYEg=

View File

@@ -18,24 +18,19 @@ type drpcRequest struct {
} }
// service Struct.Method /service.Struct/Method // service Struct.Method /service.Struct/Method
func methodToDRPC(service, method string) string { func methodToDRPC(service string, method string) string {
// no method or already grpc method // no method or already drpc method
if len(method) == 0 || method[0] == '/' { if len(method) == 0 || method[0] == '/' {
return method return method
} }
// assume method is Foo.Bar idx := strings.LastIndex(method, ".")
mParts := strings.Split(method, ".") if len(method) < 3 || idx < 2 {
if len(mParts) != 2 { return fmt.Sprintf("/%s.%s", strings.Title(service), method)
return method
} }
drpcService := method[:idx]
if len(service) == 0 { drpcMethod := method[idx+1:]
return fmt.Sprintf("/%s/%s", mParts[0], mParts[1]) return fmt.Sprintf("/%s/%s", drpcService, drpcMethod)
}
// return /pkg.Foo/Bar
return fmt.Sprintf("/%s.%s/%s", strings.Title(service), mParts[0], mParts[1])
} }
func newDRPCRequest(service, method string, request interface{}, contentType string, reqOpts ...client.RequestOption) client.Request { func newDRPCRequest(service, method string, request interface{}, contentType string, reqOpts ...client.RequestOption) client.Request {

View File

@@ -12,7 +12,7 @@ func TestMethodToDRPC(t *testing.T) {
}{ }{
{ {
"helloworld", "helloworld",
"Greeter.SayHello", "Greeter/SayHello",
"/Helloworld.Greeter/SayHello", "/Helloworld.Greeter/SayHello",
}, },
{ {