net

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Type 组件类型
	Type = "net"
	// RemoteAddrKey 远程地址键
	RemoteAddrKey = "remoteAddr"
	// PingData 心跳数据
	PingData = "ping"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientHandler

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

type Config

type Config struct {
	// 通信协议,可以是tcp、udp、ip4:1、ip6:ipv6-icmp、ip6:58、unix、unixgram,以及net包支持的协议类型。默认tcp协议
	Protocol string
	// 服务器的地址,格式为host:port
	Server string
	// 读取超时,用于设置读取数据的超时时间,单位为秒,可以为0表示不设置超时
	ReadTimeout int
}

Config endpoint组件的配置

type Endpoint

type Endpoint struct {
	// 嵌入endpoint.BaseEndpoint,继承其方法
	endpoint.BaseEndpoint
	// 配置
	Config Config
	// rulego配置
	RuleConfig types.Config
	// contains filtered or unexported fields
}

Endpoint net endpoint组件 支持通过正则表达式把匹配的消息路由到指定路由

func (*Endpoint) AddRouter

func (ep *Endpoint) AddRouter(router *endpoint.Router, params ...interface{}) (string, error)

func (*Endpoint) Close

func (ep *Endpoint) Close() error

func (*Endpoint) Destroy

func (ep *Endpoint) Destroy()

Destroy 销毁

func (*Endpoint) Id

func (ep *Endpoint) Id() string

func (*Endpoint) Init

func (ep *Endpoint) Init(ruleConfig types.Config, configuration types.Configuration) error

Init 初始化

func (*Endpoint) New

func (ep *Endpoint) New() types.Node

func (*Endpoint) Printf

func (ep *Endpoint) Printf(format string, v ...interface{})

func (*Endpoint) RemoveRouter

func (ep *Endpoint) RemoveRouter(routerId string, params ...interface{}) error

func (*Endpoint) Start

func (ep *Endpoint) Start() error

func (*Endpoint) Type

func (ep *Endpoint) Type() string

Type 组件类型

type RegexpRouter

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

RegexpRouter 正则表达式路由

type RequestMessage

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

RequestMessage 请求消息

func (*RequestMessage) Body

func (r *RequestMessage) Body() []byte

func (*RequestMessage) Conn

func (r *RequestMessage) Conn() net.Conn

func (RequestMessage) From

func (r RequestMessage) From() string

From 返回客户端Addr

func (*RequestMessage) GetError

func (r *RequestMessage) GetError() error

func (*RequestMessage) GetMsg

func (r *RequestMessage) GetMsg() *types.RuleMsg

func (*RequestMessage) GetParam

func (r *RequestMessage) GetParam(key string) string

func (*RequestMessage) Headers

func (r *RequestMessage) Headers() textproto.MIMEHeader

func (*RequestMessage) SetBody

func (r *RequestMessage) SetBody(body []byte)

func (*RequestMessage) SetError

func (r *RequestMessage) SetError(err error)

func (*RequestMessage) SetMsg

func (r *RequestMessage) SetMsg(msg *types.RuleMsg)

func (*RequestMessage) SetStatusCode

func (r *RequestMessage) SetStatusCode(statusCode int)

SetStatusCode 不提供设置响应状态码

type ResponseMessage

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

ResponseMessage 响应消息

func (*ResponseMessage) Body

func (r *ResponseMessage) Body() []byte

func (*ResponseMessage) From

func (r *ResponseMessage) From() string

func (*ResponseMessage) GetError

func (r *ResponseMessage) GetError() error

func (*ResponseMessage) GetMsg

func (r *ResponseMessage) GetMsg() *types.RuleMsg

func (*ResponseMessage) GetParam

func (r *ResponseMessage) GetParam(key string) string

func (*ResponseMessage) Headers

func (r *ResponseMessage) Headers() textproto.MIMEHeader

func (*ResponseMessage) SetBody

func (r *ResponseMessage) SetBody(body []byte)

func (*ResponseMessage) SetError

func (r *ResponseMessage) SetError(err error)

func (*ResponseMessage) SetMsg

func (r *ResponseMessage) SetMsg(msg *types.RuleMsg)

func (*ResponseMessage) SetStatusCode

func (r *ResponseMessage) SetStatusCode(statusCode int)

Jump to

Keyboard shortcuts

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