Skip to content

multi: server connection status #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 22, 2022

Conversation

ellemouton
Copy link
Member

Add server connection status info so that a caller of the Server can get informed about changes in the Server's connection. The 3 statuses differ from the Client connection statuses. They are as follows:

  • ServerConnStatusNotConnected: the server is not connected to the mailbox. This means it is either the mailbox is down or that the server is busy re-connecting to it.
  • ServerConnStatusInUse: A client is currently connected to the server
  • ServerConnStatusIdle: the server is connected to the mailbox and ready to accept a connection but there is no client currently connected.

Copy link
Member

@guggero guggero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, changes look good to me 🎉
Only two questions around naming and test coverage.

ConnStatusNotConnected ConnStatus = "Not Connected"
// ClientConnStatusNotConnected means that the client is not connected
// at all. This is likely due to the mailbox server being down.
ClientConnStatusNotConnected ClientConnStatus = "Not Connected"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make these constants a bit less clunky, should we just use ClientNotConnected, ClientSessionNotFound? Or ClientStatusNotConnected, ClientStatusSessionNotFound?

// ServerConnStatusNotConnected means that the server is currently not
// connected to a mailbox. This is either because the session is
// restarting or because the mailbox server is down.
ServerConnStatusNotConnected ServerConnStatus = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, drop both ConnStatus or just Conn in the constant names since it's probably quite obviously a connection?

@@ -74,7 +74,7 @@ func (s *serverHarness) start() error {
)

mailboxServer, err := mailbox.NewServer(
s.serverHost, connData, grpc.WithTransportCredentials(
s.serverHost, connData, nil, grpc.WithTransportCredentials(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a check to some of our LNC itests that cover these new status callbacks?

Rename the ConnStatus type to ClientConnStatus so that we can add a
Server specific Connection status type in a future commit and not
confuse the two.
In this commit, the ServerConnStatus type is added. It allows a caller
to extract the connection status of the server.
@ellemouton
Copy link
Member Author

thanks @guggero :) updated the names and added a new commit testing both the server and client status in the itests :)

@ellemouton ellemouton requested a review from guggero August 22, 2022 13:59
Copy link
Member

@guggero guggero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, LGTM 💯

// ConnStatus is a description of the connection status of the client.
type ConnStatus string
// ClientStatus is a description of the connection status of the client.
type ClientStatus string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -119,3 +161,20 @@ func testLargeResponse(t *harnessTest) {
require.NoError(t.t, err)
require.Equal(t.t, len(req)*10, len(resp.Resp))
}

func assertServerStatus(t *harnessTest, status mailbox.ServerStatus) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 😎

@guggero guggero merged commit c072f70 into lightninglabs:master Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants