Use dedicated state constants for the connection, pool, poolGenerationMap, Server, and Topology types

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Done
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Currently, connection, pool, Server, and Topology all use the same set of "connected state" constants (defined in server.go). However, their state transitions are confusingly different, leading to misunderstanding about how to check connected state of those different types (and bugs).

      For example, all of those types use the connected and disconnected states, but not all use connecting, disconnecting, and initialized. There's also a bug in Topology.Connect() that prevents a Topology from ever connecting if the Connect() function encounters an error while connecting the topology. The Topology gets stuck in the connecting state, which causes all subsequent calls to Connect() to return ErrTopologyConnected. There's a similar bug in Server.Disconnect().

      Create a "connected state" state machine that uses the same state transitions for all types that need to maintain and expose connection state.

      Definition of done:

      • The connection, pool, Server, and Topology types all use the same state transitions:
        • disconnected --> connecting
        • connecting --> connected
        • connecting --> disconnected
        • connected --> disconnecting
        • disconnecting --> disconnected
      • The connection, pool, Server, and Topology types all expose their "connected state" through identical APIs (instead of directly via atomically-accessed ints).
      • Resolve bugs in Topology.Connect() and Server.Disconnect() that cause instances of those types to get stuck in the connecting and disconnecting state, respectively.
      • Remove the now-unused initialized state.

      The best first step here is to use a different set of constants for each type's "state" value.

      New definition of done:

      • Use dedicated constants for each of the connection, pool, poolGenerationMap Server, and Topology types.
      • Remove any unused states for each type.
      • Rename the "state" field in each of the above types to state.
         

            Assignee:
            Matt Dale
            Reporter:
            Matt Dale
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: