server

package
v0.0.0-...-2105adc Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(conn net.Conn) *Client

func (*Client) Call

func (c *Client) Call(ctx context.Context, name string, funcPtr interface{})

type Handler

type Handler func(m *Middleware)

type Middleware

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

func NewMiddleware

func NewMiddleware(handlres ...Handler) *Middleware

func (*Middleware) Handlers

func (m *Middleware) Handlers(handlers ...Handler)

Handlers 设置中间件

func (*Middleware) Next

func (m *Middleware) Next()

func (*Middleware) Run

func (m *Middleware) Run()

type Options

type Options struct {
	ConnTimeout  int
	ReadTimeout  int
	WriteTimeout int
}

type RPCData

type RPCData struct {
	Func string        // 访问的函数
	Args []interface{} // 函数的参数
}

RPCData 定义 RPC 通信的数据格式

type Session

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

func NewSession

func NewSession(conn net.Conn) *Session

NewSession 从网络连接新建一个会话

func (*Session) Read

func (s *Session) Read() ([]byte, error)

Read 从 Session 中读数据

func (*Session) Write

func (s *Session) Write(data []byte) error

type XRpc

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

XRpc 服务列表暂时用本地内存存储

func NewXRpc

func NewXRpc() *XRpc

NewXRpc 创建服务端,维护服务列表

func (*XRpc) ListenAndServe

func (s *XRpc) ListenAndServe(addr string)

ListenAndServe 启动服务,指定坚挺地址

func (*XRpc) Register

func (s *XRpc) Register(name string, service interface{}, middlewares ...Handler)

Register 注册服务

func (*XRpc) Success

func (s *XRpc) Success()

Success 阻塞,等待链接成功

Jump to

Keyboard shortcuts

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