what

package
v0.0.0-...-d309772 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleError

func HandleError(err error)

HandleError ...

func HandlePanic

func HandlePanic(x any)

HandlePanic ...

Types

type Agent

type Agent interface {
	Connect(p *ConnectionParams) (Connection, error)

	Listen(p *ListenerParams) (Listener, error)
}

Agent 代表一个 what 客户端

func New

func New(cfg *Configuration) (Agent, error)

New 新建一个 Agent

func NewWithContext

func NewWithContext(ctx *Context) (Agent, error)

NewWithContext 新建一个 Agent

type Configuration

type Configuration struct {
	Host      string
	Port      int
	KeyID     string
	KeySecret string
	UseTLS    bool
}

Configuration ...

type Connection

type Connection interface {
	io.Closer
}

Connection ...

type ConnectionParams

type ConnectionParams struct {
	Service string
	Mode    Mode
	URL     string // a station node URL
	DoGet   bool   // for listener to get connection
	Timeout time.Duration
}

ConnectionParams ...

type Connector

type Connector interface {
	Connect(c *Context, p *ConnectionParams) (Connection, error)

	Registration() *ConnectorRegistration
}

Connector ...

type ConnectorRegistration

type ConnectorRegistration struct {
	Enabled   bool
	Priority  int
	Name      string
	Mode      Mode
	Connector Connector
	Support   func(*ConnectionParams) bool
}

ConnectorRegistration ...

type Context

type Context struct {
	Connectors []Connector
	Agent      Agent
	Config     Configuration
}

Context ...

type HypertextConnection

type HypertextConnection interface {
	Connection

	Do(req *HypertextRequest) (*HypertextResponse, error)
}

HypertextConnection ...

type HypertextConnector

type HypertextConnector struct {
}

HypertextConnector ...

func (*HypertextConnector) Connect

func (inst *HypertextConnector) Connect(c *Context, p *ConnectionParams) (Connection, error)

Connect ...

func (*HypertextConnector) Registration

func (inst *HypertextConnector) Registration() *ConnectorRegistration

Registration ...

type HypertextHeaders

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

HypertextHeaders ...

func (*HypertextHeaders) Get

func (inst *HypertextHeaders) Get(name string) string

Get ...

func (*HypertextHeaders) Set

func (inst *HypertextHeaders) Set(name, value string)

Set ...

type HypertextRequest

type HypertextRequest struct {
	Protocol string
	Method   string
	URL      string
	Headers  HypertextHeaders

	Content []byte
}

HypertextRequest ...

type HypertextResponse

type HypertextResponse struct {
	Protocol   string
	Request    *HypertextRequest
	Status     int
	Message    string
	Headers    HypertextHeaders
	Connection PktlineConnection

	Content []byte
}

HypertextResponse ...

func (*HypertextResponse) Error

func (inst *HypertextResponse) Error() error

Error 如果响应结果有误,封装成 error; 否则返回 nil

type Listener

type Listener interface {
	io.Closer

	Accept() (Connection, error)
}

Listener 代表一个 what 服务监听器

type ListenerParams

type ListenerParams struct {
	Service string
	Mode    Mode
}

ListenerParams ...

type Mode

type Mode string

Mode ... 表示连接模式

const (
	ModePktline   Mode = "pktline"
	ModeHypertext Mode = "hypertext"

	ModeSimple Mode = "simple"
	ModeBLOB   Mode = "blob"
	ModeFile   Mode = "file"
	ModeStream Mode = "stream"
)

...

func (Mode) String

func (s Mode) String() string

type PktlineConnection

type PktlineConnection interface {
	Connection

	pktline.Reader

	pktline.Writer
}

PktlineConnection ...

type PktlineConnector

type PktlineConnector struct {
}

PktlineConnector ...

func (*PktlineConnector) Connect

func (inst *PktlineConnector) Connect(c *Context, p *ConnectionParams) (Connection, error)

Connect ...

func (*PktlineConnector) Registration

func (inst *PktlineConnector) Registration() *ConnectorRegistration

Registration ...

type SimpleConnection

type SimpleConnection interface {
	Connection

	io.Reader

	io.Writer
}

SimpleConnection ...

type SimpleConnector

type SimpleConnector struct {
}

SimpleConnector ...

func (*SimpleConnector) Connect

func (inst *SimpleConnector) Connect(c *Context, p *ConnectionParams) (Connection, error)

Connect ...

func (*SimpleConnector) Registration

func (inst *SimpleConnector) Registration() *ConnectorRegistration

Registration ...

Jump to

Keyboard shortcuts

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