Skip to content

Instantly share code, notes, and snippets.

@prashantv
Created January 29, 2019 06:04
Show Gist options
  • Save prashantv/06466e39848e6516f0a706aea16bdfd8 to your computer and use it in GitHub Desktop.
Save prashantv/06466e39848e6516f0a706aea16bdfd8 to your computer and use it in GitHub Desktop.
tchannel close states / transitions
Close
close("user initiated")
close
sets state to connectionStartClose
causes checkExchanges to go to close states
readFrames:
connectionError if closeNetwork ISNT called
writeFrames:
when stopCh closes, calls closeNetwork
connectionError:
calls close
STOPS exchanges
stopHealthCheck
checkExchanges:
changes conn state based on exchanges
call close(stopCh) which will cause writeFrames to call closeNetwork
closeSendCh:
loop till pendingMethods is 0
closes stopCh [Not sure if loop required above, since we don't touch sendCh]
improvement mentioned in https://github.com/uber/tchannel-go/pull/388/commits/93ef5c112c8b321367ae52d2bd79396e2e874f31
closeNetwork:
tcpConn.Close (causes write/read to get errors)
stopHealthCheck
typically last thing called..
closeTimeout:
(don't call close again)
close timeout:
Normally:
Close
close()
causes checkExchanges to close stopCh
causes writeFrames signal
causes closeNetwork
causes tcp conn to close, and stop health check
causes readFrames to unblock
Conn error
readFrames gets error, calls
connectionError which calls
close
stops all exchanges
stopHealthCheck
checkExchanges will now close everything?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment