inproc

package
v0.7.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package inproc 提供进程内的内存连接:协议分流把识别好的连接直接交给本机 Web 服务监听, 不经过本机回环套接字,也不必让 Web 服务多监听一个端口、再用 PROXY 协议传递访客地址。

Web 服务监听运行时用 Listen 按监听 key 登记一个 net.Listener;分流规则用 Dial 取得连接的一端, 另一端从该 Listener 的 Accept 返回,对端地址是访客真实地址,Web 服务看到的与直接接入的连接一致。 连接由两条单向 net.Pipe 组成,保留半关闭(CloseWrite)与读写截止时间。

Index

Constants

This section is empty.

Variables

View Source
var ErrNoListener = errors.New("目标 Web 监听未运行")

ErrNoListener 表示目标监听未在运行(未启用、启动失败或已停止)。

Functions

func Dial

func Dial(ctx context.Context, key string, client, local net.Addr) (net.Conn, error)

Dial 连接到 key 对应的监听,返回调用方持有的一端。client 为访客地址,作为监听一侧看到的对端地址; local 为监听一侧看到的本地地址,nil 时用监听自身的地址。监听一侧尚未 Accept 时阻塞,直到 ctx 取消或监听关闭。

func Has

func Has(key string) bool

Has 判断 key 对应的监听是否正在运行。

Types

type Listener

type Listener struct {
	// contains filtered or unexported fields
}

Listener 接收 Dial 送来的连接,实现 net.Listener。

func Listen

func Listen(key string, addr net.Addr) (*Listener, error)

Listen 以 key 登记监听。同一 key 已被占用时返回错误;addr 为 Accept 出的连接上报的本地地址(通常是该监听的主地址)。

func (*Listener) Accept

func (l *Listener) Accept() (net.Conn, error)

Accept 实现 net.Listener。

func (*Listener) Addr

func (l *Listener) Addr() net.Addr

Addr 实现 net.Listener。

func (*Listener) Close

func (l *Listener) Close() error

Close 实现 net.Listener,并撤销登记;等待中的 Dial 立即失败。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL