Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
comms
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor 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
xx network
comms
Commits
498028a0
Commit
498028a0
authored
Aug 22, 2022
by
Jonah Husson
Browse files
Options
Downloads
Patches
Plain Diff
Comment fixes, formatting changes
parent
beaf1822
Branches
Branches containing commit
Tags
Tags containing commit
3 merge requests
!39
Merge release into master
,
!32
Project/channels
,
!31
Abstract connections from hosts, add capability to use webgrpc hosts
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
connect/connection.go
+8
-0
8 additions, 0 deletions
connect/connection.go
connect/grpcConn.go
+3
-0
3 additions, 0 deletions
connect/grpcConn.go
connect/host.go
+6
-3
6 additions, 3 deletions
connect/host.go
connect/webConn.go
+2
-0
2 additions, 0 deletions
connect/webConn.go
with
19 additions
and
3 deletions
connect/connection.go
+
8
−
0
View file @
498028a0
...
...
@@ -12,11 +12,19 @@ const (
// Connection is an interface designed to sit between hosts and connections
// to allow use of grpcweb clients.
type
Connection
interface
{
// GetWebConn returns the grpcweb ClientConn for use in browsers.
// It panics if called on a grpc client.
GetWebConn
()
*
grpcweb
.
ClientConn
// GetGrpcConn returns the grpc ClientConn for standard use.
// It panics if called on a grpcweb client.
GetGrpcConn
()
*
grpc
.
ClientConn
// Connect initiates a connection with the host using connection logic
// supplied by the underlying class.
Connect
()
error
// IsWeb returns true if the connection uses grpcweb
IsWeb
()
bool
// Close closes the underlying connection
Close
()
error
clientConnHelpers
...
...
This diff is collapsed.
Click to expand it.
connect/grpcConn.go
+
3
−
0
View file @
498028a0
...
...
@@ -113,6 +113,7 @@ func (gc *grpcConn) connectGrpcHelper() (err error) {
return
}
// Close calls the internal Close function on the grpcConn
func
(
gc
*
grpcConn
)
Close
()
error
{
if
gc
.
grpcConn
==
nil
{
return
nil
...
...
@@ -138,6 +139,8 @@ func (gc *grpcConn) disconnect() {
}
}
// isAlive returns true if the grpcConn is non-nil and alive
// must already be under the connectionMux
func
(
gc
*
grpcConn
)
isAlive
()
bool
{
if
gc
.
grpcConn
==
nil
{
return
false
...
...
This diff is collapsed.
Click to expand it.
connect/host.go
+
6
−
3
View file @
498028a0
...
...
@@ -81,17 +81,20 @@ type Host struct {
}
// NewHost creates a new host object which will use GRPC.
func
NewHost
(
id
*
id
.
ID
,
address
string
,
cert
[]
byte
,
params
HostParams
)
(
host
*
Host
,
err
error
)
{
func
NewHost
(
id
*
id
.
ID
,
address
string
,
cert
[]
byte
,
params
HostParams
)
(
host
*
Host
,
err
error
)
{
return
newHost
(
id
,
address
,
cert
,
params
,
false
)
}
// NewHostWeb creates a new host object which will use the grpcweb library.
func
NewHostWeb
(
id
*
id
.
ID
,
address
string
,
cert
[]
byte
,
params
HostParams
)
(
host
*
Host
,
err
error
)
{
func
NewHostWeb
(
id
*
id
.
ID
,
address
string
,
cert
[]
byte
,
params
HostParams
)
(
host
*
Host
,
err
error
)
{
return
newHost
(
id
,
address
,
cert
,
params
,
true
)
}
// newHost is a helper which creates a new Host object
func
newHost
(
id
*
id
.
ID
,
address
string
,
cert
[]
byte
,
params
HostParams
,
isWeb
bool
)
(
host
*
Host
,
err
error
)
{
func
newHost
(
id
*
id
.
ID
,
address
string
,
cert
[]
byte
,
params
HostParams
,
isWeb
bool
)
(
host
*
Host
,
err
error
)
{
windowSize
:=
int32
(
0
)
...
...
This diff is collapsed.
Click to expand it.
connect/webConn.go
+
2
−
0
View file @
498028a0
...
...
@@ -130,6 +130,8 @@ func (wc *webConn) disconnect() {
}
// isAlive returns true if the webConn is non-nil and alive
// must already be under the connectionMux
func
(
wc
*
webConn
)
isAlive
()
bool
{
// TODO this cannot be determined until grpcweb clients have a persistent connection
if
wc
.
webConn
==
nil
{
...
...
This diff is collapsed.
Click to expand it.
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