Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
grpc-web-go-client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
grpc-web-go-client
Commits
73272f8b
Commit
73272f8b
authored
Oct 27, 2022
by
Jonah Husson
Browse files
Options
Downloads
Patches
Plain Diff
Update with timeout and locking fix
parent
ef04339f
Branches
origin-fork
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
grpcweb/transport/option.go
+2
-0
2 additions, 0 deletions
grpcweb/transport/option.go
grpcweb/transport/transport.go
+10
-4
10 additions, 4 deletions
grpcweb/transport/transport.go
with
12 additions
and
4 deletions
grpcweb/transport/option.go
+
2
−
0
View file @
73272f8b
...
@@ -22,4 +22,6 @@ type ConnectOptions struct {
...
@@ -22,4 +22,6 @@ type ConnectOptions struct {
ExpectContinueTimeout
time
.
Duration
ExpectContinueTimeout
time
.
Duration
// Skip standard tls certificate verifications
// Skip standard tls certificate verifications
TlsInsecureSkipVerify
bool
TlsInsecureSkipVerify
bool
Timeout
time
.
Duration
}
}
This diff is collapsed.
Click to expand it.
grpcweb/transport/transport.go
+
10
−
4
View file @
73272f8b
...
@@ -18,6 +18,7 @@ import (
...
@@ -18,6 +18,7 @@ import (
"strconv"
"strconv"
"strings"
"strings"
"sync"
"sync"
"time"
)
)
// UnaryTransport is the public interface for the transport package
// UnaryTransport is the public interface for the transport package
...
@@ -30,7 +31,7 @@ type UnaryTransport interface {
...
@@ -30,7 +31,7 @@ type UnaryTransport interface {
type
httpTransport
struct
{
type
httpTransport
struct
{
host
string
host
string
client
*
http
.
Client
client
*
http
.
Client
clientLock
*
sync
.
Mutex
clientLock
*
sync
.
RW
Mutex
opts
*
ConnectOptions
opts
*
ConnectOptions
header
http
.
Header
header
http
.
Header
...
@@ -68,8 +69,8 @@ func (t *httpTransport) Send(ctx context.Context, endpoint, contentType string,
...
@@ -68,8 +69,8 @@ func (t *httpTransport) Send(ctx context.Context, endpoint, contentType string,
req
.
Header
.
Add
(
"content-type"
,
contentType
)
req
.
Header
.
Add
(
"content-type"
,
contentType
)
req
.
Header
.
Add
(
"x-grpc-web"
,
"1"
)
req
.
Header
.
Add
(
"x-grpc-web"
,
"1"
)
t
.
clientLock
.
Lock
()
t
.
clientLock
.
R
Lock
()
defer
t
.
clientLock
.
Unlock
()
defer
t
.
clientLock
.
R
Unlock
()
res
,
err
:=
t
.
client
.
Do
(
req
)
res
,
err
:=
t
.
client
.
Do
(
req
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
errors
.
Wrap
(
err
,
"failed to send the API"
)
return
nil
,
nil
,
errors
.
Wrap
(
err
,
"failed to send the API"
)
...
@@ -126,6 +127,11 @@ var NewUnary = func(host string, opts *ConnectOptions) UnaryTransport {
...
@@ -126,6 +127,11 @@ var NewUnary = func(host string, opts *ConnectOptions) UnaryTransport {
transport
.
TLSClientConfig
=
&
tls
.
Config
{
RootCAs
:
certPool
,
ServerName
:
cert
.
DNSNames
[
0
]}
transport
.
TLSClientConfig
=
&
tls
.
Config
{
RootCAs
:
certPool
,
ServerName
:
cert
.
DNSNames
[
0
]}
transport
.
TLSClientConfig
.
InsecureSkipVerify
=
opts
.
TlsInsecureSkipVerify
transport
.
TLSClientConfig
.
InsecureSkipVerify
=
opts
.
TlsInsecureSkipVerify
}
}
if
opts
.
Timeout
!=
0
{
cl
.
Timeout
=
time
.
Second
}
else
{
cl
.
Timeout
=
opts
.
Timeout
}
if
opts
.
IdleConnTimeout
!=
0
{
if
opts
.
IdleConnTimeout
!=
0
{
transport
.
IdleConnTimeout
=
opts
.
IdleConnTimeout
transport
.
IdleConnTimeout
=
opts
.
IdleConnTimeout
...
@@ -145,7 +151,7 @@ var NewUnary = func(host string, opts *ConnectOptions) UnaryTransport {
...
@@ -145,7 +151,7 @@ var NewUnary = func(host string, opts *ConnectOptions) UnaryTransport {
client
:
cl
,
client
:
cl
,
opts
:
opts
,
opts
:
opts
,
header
:
make
(
http
.
Header
),
header
:
make
(
http
.
Header
),
clientLock
:
&
sync
.
Mutex
{},
clientLock
:
&
sync
.
RW
Mutex
{},
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Richard T. Carback III
@carback1
mentioned in commit
7343cd39
·
Oct 27, 2022
mentioned in commit
7343cd39
mentioned in commit 7343cd399f146fc8873d40fbdff8cf593c6b7ffd
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment