sidecar: Init mailbox after server restarts

Whenever we are are unable to receive a sidecar packet in an auto
sidecar negotiator try to init its mailbox. This will allow us to
continue reading/writting in the mailbox in cases where the server
went down and came back.
This commit is contained in:
positiveblue 2022-02-13 22:25:39 -08:00
parent df3b819e5c
commit ac3c44a966

View file

@ -314,6 +314,23 @@ func (a *SidecarNegotiator) autoSidecarReceiver(ctx context.Context,
select {
case <-retryTimer.backOff(backoffLabel):
// It is possible that we were not able to receive the
// packet because the server went down. In that case,
// we will try to init the sidecar mailbox again.
// There is no need to log/check this error. There are
// three possibilities:
//
// 1) If the error was not related with the sever being
// down, we will get an `AlreadyExists` error.
//
// 2) If the server is back, we will be able to reconnect
// successfully and receive the sidecar pkt in the next
// iteration.
//
// 3) If the server is down, we won't be able to reconnect.
_ = a.cfg.MailBox.InitSidecarMailbox(
recipientStreamID, startingPkt.ReceiverTicket,
)
continue
case <-a.quit:
return
@ -588,6 +605,21 @@ func (a *SidecarNegotiator) autoSidecarProvider(ctx context.Context,
select {
case <-retryTimer.backOff(backoffLabel):
// It is possible that we were not able to receive the
// packet because the server went down. In that case,
// we will try to init the sidecar mailbox again.
// There is no need to log/check this error. There are
// three possibilities:
//
// 1) If the error was not related with the sever being
// down, we will get an `AlreadyExists` error.
//
// 2) If the server is back, we will be able to reconnect
// successfully and receive the sidecar pkt in the next
// iteration.
//
// 3) If the server is down, we won't be able to reconnect.
_ = a.cfg.MailBox.InitAcctMailbox(streamID, acct.TraderKey)
continue
case <-a.quit:
return