Skip to content

Commit e4d3ff9

Browse files
committed
Rename Close to CloseWrite and CloseConnection to Close
1 parent ff29487 commit e4d3ff9

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

pkg/netceptor/conn.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,16 +416,16 @@ func (c *Conn) Write(b []byte) (n int, err error) {
416416
return c.qs.Write(b)
417417
}
418418

419-
// Close closes the writer side of the connection.
420-
func (c *Conn) Close() error {
419+
// CloseWrite closes the writer side of the connection.
420+
func (c *Conn) CloseWrite() error {
421421
c.doneOnce.Do(func() {
422422
close(c.doneChan)
423423
})
424424

425425
return c.qs.Close()
426426
}
427427

428-
func (c *Conn) CloseConnection() error {
428+
func (c *Conn) Close() error {
429429
c.pc.cancel()
430430
c.doneOnce.Do(func() {
431431
close(c.doneChan)

pkg/workceptor/remote_work.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ func (rw *remoteUnit) connectToRemote(ctx context.Context) (net.Conn, *bufio.Rea
6262
ctxChild, _ := context.WithTimeout(ctx, 5*time.Second)
6363
hello, err := utils.ReadStringContext(ctxChild, reader, '\n')
6464
if err != nil {
65-
conn.CloseConnection()
65+
_ = conn.Close()
6666

6767
return nil, nil, err
6868
}
6969
if !strings.Contains(hello, red.RemoteNode) {
70-
conn.CloseConnection()
70+
_ = conn.Close()
7171

7272
return nil, nil, fmt.Errorf("while expecting node ID %s, got message: %s", red.RemoteNode,
7373
strings.TrimRight(hello, "\n"))
@@ -144,7 +144,7 @@ func (rw *remoteUnit) getConnectionAndRun(ctx context.Context, firstTimeSync boo
144144

145145
// startRemoteUnit makes a single attempt to start a remote unit.
146146
func (rw *remoteUnit) startRemoteUnit(ctx context.Context, conn net.Conn, reader *bufio.Reader) error {
147-
defer conn.(interface{ CloseConnection() error }).CloseConnection()
147+
defer conn.Close()
148148
red := rw.UnredactedStatus().ExtraData.(*remoteExtraData)
149149
workSubmitCmd := make(map[string]interface{})
150150
for k, v := range red.RemoteParams {
@@ -195,7 +195,7 @@ func (rw *remoteUnit) startRemoteUnit(ctx context.Context, conn net.Conn, reader
195195
if err != nil {
196196
return fmt.Errorf("error sending stdin file: %s", err)
197197
}
198-
err = conn.Close()
198+
err = conn.(interface{ CloseWrite() error }).CloseWrite()
199199
if err != nil {
200200
return fmt.Errorf("error closing stdin file: %s", err)
201201
}
@@ -220,7 +220,7 @@ func (rw *remoteUnit) startRemoteUnit(ctx context.Context, conn net.Conn, reader
220220
func (rw *remoteUnit) cancelOrReleaseRemoteUnit(ctx context.Context, conn net.Conn, reader *bufio.Reader,
221221
release bool, force bool,
222222
) error {
223-
defer conn.(interface{ CloseConnection() error }).CloseConnection()
223+
defer conn.Close()
224224
red := rw.Status().ExtraData.(*remoteExtraData)
225225
var workCmd string
226226
if release {
@@ -277,7 +277,7 @@ func (rw *remoteUnit) monitorRemoteStatus(mw *utils.JobContext, forRelease bool)
277277
conn, reader := rw.getConnection(mw)
278278
defer func() {
279279
if conn != nil {
280-
conn.(interface{ CloseConnection() error }).CloseConnection()
280+
conn.Close()
281281
}
282282
}()
283283
if conn == nil {
@@ -294,15 +294,15 @@ func (rw *remoteUnit) monitorRemoteStatus(mw *utils.JobContext, forRelease bool)
294294
_, err := conn.Write([]byte(fmt.Sprintf("work status %s\n", remoteUnitID)))
295295
if err != nil {
296296
logger.Debug("Write error sending to %s: %s\n", remoteUnitID, err)
297-
_ = conn.(interface{ CloseConnection() error }).CloseConnection()
297+
_ = conn.Close()
298298
conn = nil
299299

300300
continue
301301
}
302302
status, err := utils.ReadStringContext(mw, reader, '\n')
303303
if err != nil {
304304
logger.Debug("Read error reading from %s: %s\n", remoteNode, err)
305-
_ = conn.(interface{ CloseConnection() error }).CloseConnection()
305+
_ = conn.Close()
306306
conn = nil
307307

308308
continue
@@ -401,7 +401,7 @@ func (rw *remoteUnit) monitorRemoteStdout(mw *utils.JobContext) {
401401
conn, reader := rw.getConnection(mw)
402402
defer func() {
403403
if conn != nil {
404-
_ = conn.(interface{ CloseConnection() error }).CloseConnection()
404+
_ = conn.Close()
405405
}
406406
}()
407407
if conn == nil {
@@ -461,7 +461,7 @@ func (rw *remoteUnit) monitorRemoteStdout(mw *utils.JobContext) {
461461
if ok {
462462
cr.CancelRead()
463463
}
464-
_ = conn.(interface{ CloseConnection() error }).CloseConnection()
464+
_ = conn.Close()
465465

466466
return
467467
}

0 commit comments

Comments
 (0)