package
0.0.0-20230303081844-6a5c134c44e7
Repository: https://github.com/hiank/think.git
Documentation: pkg.go.dev
# README
Easy client-server
Client
- operate a
box.Message
m
useAuto
- unmarshal
m
then get a key for foundConn
to sendm
- cannot found the
Conn
, create one - ...
taskConn
Conn use Tasker to sequential execute Dial
and Send box.Message
- first Task is try dial
- when dial closed
newTaskConn(ctx context.Context, dial Dial, doneHook func()) Conn
to make a new taskConn
exception enumeration:
-
context passed canceled: doneHook will respond
-
dial error
liteConn & initialize
带缓存的Conn
,无阻塞发送消息。需前置执行initialize
,以执行连接(连接设置为第一个任务,完成前所有期望发送的消息都会被缓存起来,等待任务的顺序执行)。initialize
还会开启一个循环Recv
的goroutine,这个Recv
时完成连接后得到的Conn
,而非本身。本身持有的Recv
为未实现api,因为此调用非异步安全,因此不提供外部访问。循环读取函数作为initialize
参数传入。
liteConn: Conn used by connset
Conn
with message cache.- non-blocking
Send
(userun.Tasker
). - delay connecting (by
initialize
). - respond after closing (by
initialize
),connset
use this feature to remove reference. Recv
unimplemented.initialize
will start loopRecv after connect success.
initialize: initialize an empty *liteConn
param:
ctx context.Context
: root context, for liteConn's tasker and connectlc *liteConn
: target *liteConnconnect Connect
: use to get a new connloopRecv func(Receiver, box.Token)
: loop recv message from newly obtained conn until recv any errordoneHook
: last executed after conn *liteConn closed
# Packages
No description provided by the author
# Functions
No description provided by the author
NewMessage new a not empty message.
No description provided by the author
WithMessageBytes bytes for decode to *anypb.Any it would panic when given bts was not *anypb.Any buff.
WithMessageToken set given Token to message.
WithMessageValue value for encode when v is not a *anypb.Any, packing it to *anypb.Any first.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author