// NetworkStreamGetConnections streams the network connections via GET request.
965191
func NetworkStreamGetConnections(context *gin.Context) {
	rateLimit, convertErr := util.ConvertStringToTimeDuration(context.Param("rateLimit"))
	context.Stream(func(w io.Writer) bool {
		if convertErr != nil {
			return false
		}
		time.Sleep(rateLimit * time.Second)
		body, err := network.ServiceGetConnections()
		return util.StreamHandleResponse(context, body, err, "NetworkStreamGetConnections")
	})
}
749092
func GetClientConnectionWithCreds(ctx context.Context, addr string, port int, creds credentials.TransportCredentials) (*grpc.ClientConn, error) {
	grpcDialOpts := []grpc.DialOption{
		grpc.WithTimeout(grpcDialDefaultTimeout),
	}
	if creds != nil {
		grpcDialOpts = append(grpcDialOpts, grpc.WithTransportCredentials(creds))
	} else {
		grpcDialOpts = append(grpcDialOpts, grpc.WithInsecure())
	}

	conn, err := grpc.DialContext(ctx, fmt.Sprintf("%v:%v", addr, port), grpcDialOpts...)
	if err != nil {
		return nil, err
	}
	return conn, nil
}
922657
func (s *Session) UserConnections() (conn []*UserConnection, err error) {
	response, err := s.RequestWithBucketID("GET", EndpointUserConnections("@me"), nil, EndpointUserConnections("@me"))
	if err != nil {
		return nil, err
	}

	err = unmarshal(response, &conn)
	if err != nil {
		return
	}

	return
}
596257
func (c *Client) GetNetworks() (nets []Network, err error) {
	var netMap map[string]Network
	if err := c.get(`network/list`, &netMap); err != nil {
		return nil, err
	}

	for _, net := range netMap {
		nets = append(nets, net)
	}
	sort.Sort(networks(nets))
	return nets, nil
}
1354505
func (b *Bundler) GetStreamDescs() map[string]*logpb.LogStreamDescriptor {
	b.streamsLock.Lock()
	defer b.streamsLock.Unlock()

	if len(b.streams) == 0 {
		return nil
	}

	streams := make(map[string]*logpb.LogStreamDescriptor, len(b.streams))
	for k, s := range b.streams {
		streams[k] = s.streamDesc()
	}
	return streams
}
1284775
func getConn(d *Daemon, w http.ResponseWriter, r *http.Request) *HttpErr {
	vars := mux.Vars(r)

	containerId := vars["id"]
	con := d.connections.Get(containerId)

	if con == nil {
		return &HttpErr{http.StatusNotFound, containerId}
	}

	data, err := json.Marshal(con.(*Connection))

	if err != nil {
		return &HttpErr{http.StatusInternalServerError, err.Error()}
	}

	w.Header().Set("Content-Type", "application/json; charset=utf-8")
	w.Write(data)

	return nil
}
266743
func (client *Client) GetConnection() (Connection, error) {
	request := newOpClientRequest(opClientRequestConnection, nil)
	client.opRequests <- request
	response := <-request.response
	switch response.(type) {
	case error:
		return nil, response.(error)
	case Connection:
		return response.(Connection), nil
	}
	panic("unreachable")
}
853063
func GetClientConnection(ctx context.Context, addr string, port int) (*grpc.ClientConn, error) {
	return GetClientConnectionWithCreds(ctx, addr, port, nil)
}
603031
func (s *Server) GetConnections() []Connection {
	// first call of Range to get the total length, we don't want to use append or manually grow the list here for many reasons.
	length := s.GetTotalConnections()
	conns := make([]Connection, length, length)
	i := 0
	// second call of Range.
	s.connections.Range(func(k, v interface{}) bool {
		conn, ok := v.(*connection)
		if !ok {
			// if for some reason (should never happen), the value is not stored as *connection
			// then stop the iteration and don't continue insertion of the result connections
			// in order to avoid any issues while end-dev will try to iterate a nil entry.
			return false
		}
		conns[i] = conn
		i++
		return true
	})

	return conns
}
30449
func (daemon *Daemon) getNetworkStats(c *container.Container) (map[string]types.NetworkStats, error) {
	return make(map[string]types.NetworkStats), nil
}
539858
func (c *channelPool) getConns() chan *idleConn {
	c.mu.Lock()
	conns := c.conns
	c.mu.Unlock()
	return conns
}
133452
func (c *Client) GetNetwork() (*Network, error) {
	network := &Network{}
	return network, c.Get("/", network)
}
93824
func (d *logDrain) getConnection(forceNew bool) (net.Conn, error) {
	// If we have a connection, it's not old, and we're not focing a new one...
	if d.conn != nil && !forceNew {
		// then return the existing connection
		return d.conn, nil
	}
	// If ANY of those conditions weren't met, it's time for a new connection.
	// If we have an existing one, close it and nil it out, too for good measure.
	if d.conn != nil {
		if err := d.conn.Close(); err != nil {
			log.Println("drain: Error closing connection.  Drain may be leaking connections.", err)
		}
		d.conn = nil
	}
	// Try a few times...
	var err error
	for attempt := 1; attempt <= maxFailedConns; attempt++ {
		d.conn, err = net.DialTimeout(d.proto, d.uri, dialTimeout)
		if err == nil {
			// We got our connection...
			// Make it good for only so long.  See comment above on connRefreshInterval.
			err = d.conn.SetWriteDeadline(time.Now().Add(connRefreshInterval))
			if err != nil {
				return nil, err
			}
			// Break out of the loop and return
			return d.conn, nil
		}
	}
	// Multiple attempts to dial have failed.  Whatever the problem is, we shouldn't expect that
	// it will resolve itself quickly.
	log.Printf("drain: Experienced %d consecutive failed connection attempts; muting drain for %s.", maxFailedConns, mutePeriod)
	// Immediately "mute" the drain.  This will prevent us from wasting resources repeatedly dialing
	// and failing while the message queue gets backed up.  This will give the network a break and
	// allow us to empty the queue.
	d.muted = true
	// Unmute the drain when the mute interval has elapsed
	go func() {
		time.Sleep(mutePeriod)
		d.muted = false
	}()
	// Return the error from the last failed connection attempt
	return nil, err
}
473434
func (c *Client) ListConnections() (rec []ConnectionInfo, err error) {
	req, err := newGETRequest(c, "connections")
	if err != nil {
		return []ConnectionInfo{}, err
	}

	if err = executeAndParseRequest(c, req, &rec); err != nil {
		return []ConnectionInfo{}, err
	}

	return rec, nil
}
1158920
func (l *Client) GetStreams(stream string) ([]*Stream, error) {
	res := ApiResp{}
	data := []*Stream{}

	// make the request
	err := l.Get(parseLyticsURL(routeSchemaStreams, nil), nil, nil, &res, &data)
	if err != nil {
		return data, err
	}

	return data, nil
}
90773
func (s *Server) getInboundGatewayConnections(a *[]*client) {
	s.gateway.RLock()
	for _, gwc := range s.gateway.in {
		*a = append(*a, gwc)
	}
	s.gateway.RUnlock()
}
1282277
func (s *PresenceService) GetTunnelConnections(clusterName string, opts ...services.MarshalOption) ([]services.TunnelConnection, error) {
	if clusterName == "" {
		return nil, trace.BadParameter("missing cluster name")
	}
	startKey := backend.Key(tunnelConnectionsPrefix, clusterName)
	result, err := s.GetRange(context.TODO(), startKey, backend.RangeEnd(startKey), backend.NoLimit)
	if err != nil {
		return nil, trace.Wrap(err)
	}
	conns := make([]services.TunnelConnection, len(result.Items))
	for i, item := range result.Items {
		conn, err := services.UnmarshalTunnelConnection(item.Value,
			services.AddOptions(opts, services.WithResourceID(item.ID), services.WithExpires(item.Expires))...)
		if err != nil {
			return nil, trace.Wrap(err)
		}
		conns[i] = conn
	}

	return conns, nil
}