// DialContextFunc returns a wrapper for dial which logs with the default
// logger all opening and closing events that occur on the connections returned
// by the dial function.
481826
func DialContextFunc(dial func(context.Context, string, string) (net.Conn, error)) func(context.Context, string, string) (net.Conn, error) {
	return DialContextFuncWith(events.DefaultLogger, dial)
}
931634
func DialNameFromContext(ctx context.Context) string {
	val, ok := ctx.Value(dialerNameKey).(string)
	if !ok {
		return ""
	}
	return val
}
347444
func WrapContext(ctx context.Context) context.Context {
	var objLogger *logger.Logger
	if ctx == nil {
		ctx = context.Background()
		objLogger = logger.GetLogger()
	} else {
		objLogger = GetLogger(ctx)
	}
	return context.WithValue(ctx, logKey, objLogger)
}
1200451
func (d *Dialer) DialContext(ctx context.Context, remote ma.Multiaddr) (Conn, error) {
	// if a LocalAddr is specified, use it on the embedded dialer.
	if d.LocalAddr != nil {
		// convert our multiaddr to net.Addr friendly
		naddr, err := ToNetAddr(d.LocalAddr)
		if err != nil {
			return nil, err
		}

		// set the dialer's LocalAddr as naddr
		d.Dialer.LocalAddr = naddr
	}

	// get the net.Dial friendly arguments from the remote addr
	rnet, rnaddr, err := DialArgs(remote)
	if err != nil {
		return nil, err
	}

	// ok, Dial!
	var nconn net.Conn
	switch rnet {
	case "tcp", "tcp4", "tcp6", "udp", "udp4", "udp6", "unix":
		nconn, err = d.Dialer.DialContext(ctx, rnet, rnaddr)
		if err != nil {
			return nil, err
		}
	default:
		return nil, fmt.Errorf("unrecognized network: %s", rnet)
	}

	// get local address (pre-specified or assigned within net.Conn)
	local := d.LocalAddr
	// This block helps us avoid parsing addresses in transports (such as unix
	// sockets) that don't have local addresses when dialing out.
	if local == nil && nconn.LocalAddr().String() != "" {
		local, err = FromNetAddr(nconn.LocalAddr())
		if err != nil {
			return nil, err
		}
	}
	return wrap(nconn, local, remote), nil
}
17993
func ToContext(ctx context.Context, logger *zap.Logger) context.Context {
	return ctxzap.ToContext(ctx, logger)
}
898409
func (engine *Engine) PingContext(ctx context.Context) error {
	session := engine.NewSession()
	defer session.Close()
	return session.PingContext(ctx)
}
58729
func (p *Provider) DialContext(
	ctx context.Context,
	network, address string) (net.Conn, error) {

	switch p.mapNetwork(network) {
	case networkMemb, networkMemu:
		return p.DialMemContext(
			ctx, network, nil, &Addr{
				Name:    address,
				network: network,
			})
	default:
		if ctx == nil {
			return net.Dial(network, address)
		}
		return (&net.Dialer{}).DialContext(ctx, network, address)
	}
}
544144
func (api *Client) OpenConversationContext(ctx context.Context, params *OpenConversationParameters) (*Channel, bool, bool, error) {
	values := url.Values{
		"token":     {api.token},
		"return_im": {strconv.FormatBool(params.ReturnIM)},
	}
	if params.ChannelID != "" {
		values.Add("channel", params.ChannelID)
	}
	if params.Users != nil {
		values.Add("users", strings.Join(params.Users, ","))
	}
	response := struct {
		Channel     *Channel `json:"channel"`
		NoOp        bool     `json:"no_op"`
		AlreadyOpen bool     `json:"already_open"`
		SlackResponse
	}{}
	err := api.postMethod(ctx, "conversations.open", values, &response)
	if err != nil {
		return nil, false, false, err
	}

	return response.Channel, response.NoOp, response.AlreadyOpen, response.Err()
}
957362
func DialFuncWith(logger *events.Logger, dial func(string, string) (net.Conn, error)) func(string, string) (net.Conn, error) {
	dialContext := dialContextFunc(1, logger,
		func(ctx context.Context, network string, address string) (net.Conn, error) {
			return dial(network, address)
		},
	)
	return func(network string, address string) (net.Conn, error) {
		return dialContext(context.Background(), network, address)
	}
}
1051703
func (s *RemoteStore) getContext() (context.Context, context.CancelFunc) {
	return context.WithTimeout(context.Background(), s.timeout)
}
121540
func DialContext(ctx context.Context, urlstr string, opts ...DialOption) (*Conn, error) {
	d := &websocket.Dialer{
		ReadBufferSize:  25 * 1024 * 1024,
		WriteBufferSize: 10 * 1024 * 1024,
	}

	// connect
	conn, _, err := d.DialContext(ctx, urlstr, nil)
	if err != nil {
		return nil, err
	}

	// apply opts
	c := &Conn{
		conn: conn,
	}
	for _, o := range opts {
		o(c)
	}

	return c, nil
}
81961
func FromContext(ctx context.Context) string {
	logContext, _ := ctx.Value(logContextKey).(string)
	return logContext
}
930981
func Dial(ctx context.Context, urlstr string) (net.Conn, *bufio.Reader, Handshake, error) {
	return DefaultDialer.Dial(ctx, urlstr)
}
630400
func CallFromContext(ctx context.Context) *Call {
	if ic, ok := getInboundCall(ctx); ok {
		return &Call{ic}
	}
	return nil
}
876258
func (call *GetLIFFAllCall) WithContext(ctx context.Context) *GetLIFFAllCall {
	call.ctx = ctx
	return call
}
172861
func DialContext(ctx context.Context, rawurl string) (*Client, error) {
	u, err := url.Parse(rawurl)
	if err != nil {
		return nil, err
	}
	switch u.Scheme {
	case "http", "https":
		return DialHTTP(rawurl)
	case "ws", "wss":
		return DialWebsocket(ctx, rawurl, "")
	case "stdio":
		return DialStdIO(ctx)
	case "":
		return DialIPC(ctx, rawurl)
	default:
		return nil, fmt.Errorf("no known transport for URL scheme %q", u.Scheme)
	}
}
599359
func Dial(network, address string) (fcgi *FCGIClient, err error) {
	return DialContext(context.Background(), network, address)
}