mirror of
https://github.com/nabbar/golib.git
synced 2025-11-02 03:52:36 +08:00
Package AWS
Add feature to change http timeout directly in httpcli store in aws client Add copy/MPUCopy function Update mpu to allow copy with MPU Package Cobra Fix println by fmt.Fprint to os.stdout Package Crypt Refactor package to use instance of crypt instead of a global crypt unique instance Allow to gen key/nonce Add io stream reader/writer instead of only buffer slice encoder decoder Package file/bandwidth Add new subpackage bandwith to limit a amount of byte read/write for a duraction Use file/progress function increment/reset Allow to add custom function increment / reset Package IOUtils Remove useless file error.go, tempFile.go (replaced by package file) Move fileDescriptor to a subpackage fileDescriptor: allow to change nb of FD for linux/windows os Move Buffer ReadCloser to a new subpackage: allow to add close function to buffer, and expose read / write io interface Add sub package multiplexer to allow send/receive multiple io stream into on io stream Package Socket Rework to expose io stream instead of buffer Fix minor bugs Other: Bump dependencies Update code following bump dependencies
This commit is contained in:
@@ -113,30 +113,27 @@ func (o *cltx) dial(ctx context.Context) (net.Conn, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func (o *cltx) Do(ctx context.Context, request io.Reader) (io.Reader, error) {
|
||||
func (o *cltx) Do(ctx context.Context, request io.Reader, fct libsck.Response) error {
|
||||
if o == nil {
|
||||
return nil, ErrInvalidInstance
|
||||
return ErrInvalidInstance
|
||||
}
|
||||
|
||||
var (
|
||||
e error
|
||||
|
||||
lc net.Addr
|
||||
rm net.Addr
|
||||
|
||||
e error
|
||||
lc net.Addr
|
||||
rm net.Addr
|
||||
cnn net.Conn
|
||||
buf = o.buffRead()
|
||||
)
|
||||
|
||||
o.fctInfo(nil, nil, libsck.ConnectionDial)
|
||||
if cnn, e = o.dial(ctx); e != nil {
|
||||
o.fctError(e)
|
||||
return nil, e
|
||||
return e
|
||||
}
|
||||
|
||||
defer func() {
|
||||
e := cnn.Close()
|
||||
o.fctError(e)
|
||||
err := cnn.Close()
|
||||
o.fctError(err)
|
||||
}()
|
||||
|
||||
lc = cnn.LocalAddr()
|
||||
@@ -149,24 +146,26 @@ func (o *cltx) Do(ctx context.Context, request io.Reader) (io.Reader, error) {
|
||||
o.fctInfo(lc, rm, libsck.ConnectionWrite)
|
||||
if _, e = io.Copy(cnn, request); e != nil {
|
||||
o.fctError(e)
|
||||
return nil, e
|
||||
return e
|
||||
}
|
||||
}
|
||||
|
||||
o.fctInfo(lc, rm, libsck.ConnectionCloseWrite)
|
||||
if e = cnn.(*net.UnixConn).CloseWrite(); e != nil {
|
||||
o.fctError(e)
|
||||
return nil, e
|
||||
return e
|
||||
}
|
||||
|
||||
o.fctInfo(lc, rm, libsck.ConnectionRead)
|
||||
if _, e = io.Copy(buf, cnn); e != nil {
|
||||
o.fctError(e)
|
||||
return nil, e
|
||||
o.fctInfo(lc, rm, libsck.ConnectionHandler)
|
||||
if fct != nil {
|
||||
fct(cnn)
|
||||
}
|
||||
|
||||
o.fctInfo(lc, rm, libsck.ConnectionCloseRead)
|
||||
o.fctError(cnn.(*net.UnixConn).CloseRead())
|
||||
if e = cnn.(*net.UnixConn).CloseRead(); e != nil {
|
||||
o.fctError(e)
|
||||
return e
|
||||
}
|
||||
|
||||
return buf, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user