client

package
v0.0.6 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAddress

func GetAddress(addressList []string) string

Types

type Client

type Client interface {
	SetOptions(any)
	SetPoolOptions(any)
	Call(string, any, any, bool) error
	BatchAppend(string, any, any, bool) *error
	BatchCall() error
}

func NewClient

func NewClient[T Protocol](p T) Client

type Http

type Http struct {
	Name      string
	Protocol  string
	Address   string
	Discovery discovery.Driver
}

func (*Http) NewClient

func (p *Http) NewClient() Client

type HttpClient

type HttpClient struct {
	Name        string
	Protocol    string
	Address     string
	Discovery   discovery.Driver
	AddressList []string
	RequestList []*common.SingleRequest
}

func NewHttpClient

func NewHttpClient(name string, protocol string, address string, dc discovery.Driver) *HttpClient

func (*HttpClient) BatchAppend

func (c *HttpClient) BatchAppend(method string, params any, result any, isNotify bool) *error

func (*HttpClient) BatchCall

func (c *HttpClient) BatchCall() error

func (*HttpClient) Call

func (c *HttpClient) Call(method string, params any, result any, isNotify bool) error

func (*HttpClient) GetAddress

func (c *HttpClient) GetAddress() (string, error)

func (*HttpClient) SetAddressList

func (c *HttpClient) SetAddressList()

func (*HttpClient) SetOptions

func (c *HttpClient) SetOptions(httpOptions any)

func (*HttpClient) SetPoolOptions

func (c *HttpClient) SetPoolOptions(httpOptions any)

type Pool

type Pool struct {
	Name              string
	Discovery         discovery.Driver
	Address           string
	ActiveAddressList []string
	Lock              sync.Mutex
	Options           PoolOptions
	ActiveTotal       int
	Conns             chan net.Conn
}

func NewPool

func NewPool(name, address string, dc discovery.Driver, option PoolOptions) *Pool

func (*Pool) ActiveAddress

func (p *Pool) ActiveAddress() (int, error)

func (*Pool) Borrow

func (p *Pool) Borrow() (net.Conn, error)

func (*Pool) BorrowAfterRemove

func (p *Pool) BorrowAfterRemove(conn net.Conn) (net.Conn, error)

func (*Pool) Connect

func (p *Pool) Connect(address string) (net.Conn, error)

func (*Pool) Create

func (p *Pool) Create() (net.Conn, error)

func (*Pool) Release

func (p *Pool) Release(conn net.Conn)

func (*Pool) Remove

func (p *Pool) Remove(conn net.Conn)

func (*Pool) SetOptions

func (p *Pool) SetOptions(options PoolOptions)

type PoolOptions

type PoolOptions struct {
	MinIdle   int
	MaxActive int
}

type Protocol

type Protocol interface {
	NewClient() Client
}

type Tcp

type Tcp struct {
	Name      string
	Protocol  string
	Address   string
	Discovery discovery.Driver
}

func (*Tcp) NewClient

func (p *Tcp) NewClient() Client

type TcpClient

type TcpClient struct {
	Name        string
	Protocol    string
	Address     string
	Discovery   discovery.Driver
	RequestList []*common.SingleRequest
	Options     TcpOptions
	Pool        *Pool
}

func NewTcpClient

func NewTcpClient(name string, protocol string, address string, dc discovery.Driver) *TcpClient

func (*TcpClient) BatchAppend

func (c *TcpClient) BatchAppend(method string, params any, result any, isNotify bool) *error

func (*TcpClient) BatchCall

func (c *TcpClient) BatchCall() error

func (*TcpClient) Call

func (c *TcpClient) Call(method string, params any, result any, isNotify bool) error

func (*TcpClient) SetOptions

func (c *TcpClient) SetOptions(tcpOptions any)

func (*TcpClient) SetPoolOptions

func (c *TcpClient) SetPoolOptions(poolOption any)

type TcpOptions

type TcpOptions struct {
	ReqAddEof     string //请求时添加eof字符
	RespCheckEof  string //自定义结束符
	RespMaxLength int64
	RespAddSuffix string //有时结束符和实际数据混合,需要把数据补上
}

Jump to

Keyboard shortcuts

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