Skip to content
Snippets Groups Projects
Commit 498028a0 authored by Jonah Husson's avatar Jonah Husson
Browse files

Comment fixes, formatting changes

parent beaf1822
Branches
Tags
3 merge requests!39Merge release into master,!32Project/channels,!31Abstract connections from hosts, add capability to use webgrpc hosts
......@@ -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
......
......@@ -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
......
......@@ -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)
......
......@@ -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 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment