@@ -214,11 +214,11 @@ type Connection struct {
214214var _ = Connector (& Connection {}) // Check compatibility with connector interface.
215215
216216type futureList struct {
217- first * Future
218- last * * Future
217+ first * future
218+ last * * future
219219}
220220
221- func (list * futureList ) findFuture (reqid uint32 , fetch bool ) * Future {
221+ func (list * futureList ) findFuture (reqid uint32 , fetch bool ) * future {
222222 root := & list .first
223223 for {
224224 fut := * root
@@ -240,7 +240,7 @@ func (list *futureList) findFuture(reqid uint32, fetch bool) *Future {
240240 }
241241}
242242
243- func (list * futureList ) addFuture (fut * Future ) {
243+ func (list * futureList ) addFuture (fut * future ) {
244244 * list .last = fut
245245 list .last = & fut .next
246246}
@@ -250,7 +250,7 @@ func (list *futureList) clear(err error, conn *Connection) {
250250 list .first = nil
251251 list .last = & list .first
252252 for fut != nil {
253- fut .SetError (err )
253+ fut .setError (err )
254254 conn .markDone (fut )
255255 fut , fut .next = fut .next , nil
256256 }
@@ -446,9 +446,9 @@ func (conn *Connection) Handle() interface{} {
446446 return conn .opts .Handle
447447}
448448
449- func (conn * Connection ) cancelFuture (fut * Future , err error ) {
449+ func (conn * Connection ) cancelFuture (fut * future , err error ) {
450450 if fut = conn .fetchFuture (fut .requestId ); fut != nil {
451- fut .SetError (err )
451+ fut .setError (err )
452452 conn .markDone (fut )
453453 }
454454}
@@ -871,7 +871,7 @@ func (conn *Connection) reader(r io.Reader, c Conn) {
871871 return
872872 }
873873
874- var fut * Future = nil
874+ var fut * future = nil
875875 if code == iproto .IPROTO_EVENT {
876876 if event , err := readWatchEvent (& buf ); err == nil {
877877 events <- event
@@ -887,8 +887,8 @@ func (conn *Connection) reader(r io.Reader, c Conn) {
887887 conn .opts .Logger .Report (LogBoxSessionPushUnsupported , conn , header )
888888 } else {
889889 if fut = conn .fetchFuture (header .RequestId ); fut != nil {
890- if err := fut .SetResponse (header , & buf ); err != nil {
891- fut .SetError (fmt .Errorf ("failed to set response: %w" , err ))
890+ if err := fut .setResponse (header , & buf ); err != nil {
891+ fut .setError (fmt .Errorf ("failed to set response: %w" , err ))
892892 }
893893 conn .markDone (fut )
894894 }
@@ -925,9 +925,9 @@ func (conn *Connection) eventer(events <-chan connWatchEvent) {
925925 }
926926}
927927
928- func (conn * Connection ) newFuture (req Request ) (fut * Future ) {
928+ func (conn * Connection ) newFuture (req Request ) (fut * future ) {
929929 ctx := req .Ctx ()
930- fut = NewFuture (req )
930+ fut = newFuture (req )
931931 if conn .rlimit != nil && conn .opts .RLimitAction == RLimitDrop {
932932 select {
933933 case conn .rlimit <- struct {}{}:
@@ -974,7 +974,7 @@ func (conn *Connection) newFuture(req Request) (fut *Future) {
974974 if ctx != nil {
975975 select {
976976 case <- ctx .Done ():
977- fut .SetError (fmt .Errorf ("context is done (request ID %d): %w" ,
977+ fut .setError (fmt .Errorf ("context is done (request ID %d): %w" ,
978978 fut .requestId , context .Cause (ctx )))
979979 shard .rmut .Unlock ()
980980 return
@@ -1007,7 +1007,7 @@ func (conn *Connection) newFuture(req Request) (fut *Future) {
10071007
10081008// This method removes a future from the internal queue if the context
10091009// is "done" before the response is come.
1010- func (conn * Connection ) contextWatchdog (fut * Future , ctx context.Context ) {
1010+ func (conn * Connection ) contextWatchdog (fut * future , ctx context.Context ) {
10111011 select {
10121012 case <- fut .WaitChan ():
10131013 case <- ctx .Done ():
@@ -1032,7 +1032,7 @@ func (conn *Connection) decrementRequestCnt() {
10321032 }
10331033}
10341034
1035- func (conn * Connection ) send (req Request , streamId uint64 ) * Future {
1035+ func (conn * Connection ) send (req Request , streamId uint64 ) * future {
10361036 conn .incrementRequestCnt ()
10371037
10381038 fut := conn .newFuture (req )
@@ -1056,7 +1056,7 @@ func (conn *Connection) send(req Request, streamId uint64) *Future {
10561056 return fut
10571057}
10581058
1059- func (conn * Connection ) putFuture (fut * Future , req Request , streamId uint64 ) {
1059+ func (conn * Connection ) putFuture (fut * future , req Request , streamId uint64 ) {
10601060 shardn := fut .requestId & (conn .opts .Concurrency - 1 )
10611061 shard := & conn .shard [shardn ]
10621062 shard .bufmut .Lock ()
@@ -1077,7 +1077,7 @@ func (conn *Connection) putFuture(fut *Future, req Request, streamId uint64) {
10771077 shard .buf .Trunc (blen )
10781078 shard .bufmut .Unlock ()
10791079 if f := conn .fetchFuture (reqid ); f == fut {
1080- fut .SetError (err )
1080+ fut .setError (err )
10811081 conn .markDone (fut )
10821082 } else if f != nil {
10831083 /* in theory, it is possible. In practice, you have
@@ -1092,7 +1092,7 @@ func (conn *Connection) putFuture(fut *Future, req Request, streamId uint64) {
10921092 // packing error is more important than connection
10931093 // error, because it is indication of programmer's
10941094 // mistake.
1095- fut .SetError (err )
1095+ fut .setError (err )
10961096 }
10971097 }
10981098 return
@@ -1109,28 +1109,28 @@ func (conn *Connection) putFuture(fut *Future, req Request, streamId uint64) {
11091109 RequestId : reqid ,
11101110 Error : ErrorNo ,
11111111 }
1112- _ = fut .SetResponse (header , nil )
1112+ _ = fut .setResponse (header , nil )
11131113 conn .markDone (fut )
11141114 }
11151115 }
11161116}
11171117
1118- func (conn * Connection ) markDone (fut * Future ) {
1118+ func (conn * Connection ) markDone (fut * future ) {
11191119 if conn .rlimit != nil {
11201120 <- conn .rlimit
11211121 }
11221122 conn .decrementRequestCnt ()
11231123}
11241124
1125- func (conn * Connection ) fetchFuture (reqid uint32 ) (fut * Future ) {
1125+ func (conn * Connection ) fetchFuture (reqid uint32 ) (fut * future ) {
11261126 shard := & conn .shard [reqid & (conn .opts .Concurrency - 1 )]
11271127 shard .rmut .Lock ()
11281128 fut = conn .getFutureImp (reqid , true )
11291129 shard .rmut .Unlock ()
11301130 return fut
11311131}
11321132
1133- func (conn * Connection ) getFutureImp (reqid uint32 , fetch bool ) * Future {
1133+ func (conn * Connection ) getFutureImp (reqid uint32 , fetch bool ) * future {
11341134 shard := & conn .shard [reqid & (conn .opts .Concurrency - 1 )]
11351135 pos := (reqid / conn .opts .Concurrency ) & (requestsMap - 1 )
11361136 // futures with even requests id belong to requests list with nil context
@@ -1168,7 +1168,7 @@ func (conn *Connection) timeouts() {
11681168 } else {
11691169 fut .next = nil
11701170 }
1171- fut .SetError (ClientError {
1171+ fut .setError (ClientError {
11721172 Code : ErrTimeouted ,
11731173 Msg : fmt .Sprintf ("client timeout for request %d" , fut .requestId ),
11741174 })
@@ -1232,11 +1232,10 @@ func (conn *Connection) nextRequestId(context bool) (requestId uint32) {
12321232//
12331233// An error is returned if the request was formed incorrectly, or failed to
12341234// create the future.
1235- func (conn * Connection ) Do (req Request ) * Future {
1235+ func (conn * Connection ) Do (req Request ) Future {
12361236 if connectedReq , ok := req .(ConnectedRequest ); ok {
12371237 if connectedReq .Conn () != conn {
1238- fut := NewFuture (req )
1239- fut .SetError (errUnknownRequest )
1238+ fut := NewFutureWithErr (req , errUnknownRequest )
12401239 return fut
12411240 }
12421241 }
0 commit comments