Skip to content

Define ordering across heterogeneous EndPoint implementations #1009

Description

@dkropachev

Problem

EndPoint subclasses implement __lt__ assuming the other operand has the same concrete type. Directly sorting heterogeneous endpoints can therefore fail.

from cassandra.connection import DefaultEndPoint, UnixSocketEndPoint

UnixSocketEndPoint('/tmp/cql.sock') < DefaultEndPoint('127.0.0.1')

This raises AttributeError because UnixSocketEndPoint.__lt__ reads _unix_socket_path from the DefaultEndPoint. The reverse comparison can also raise TypeError when tuple comparison reaches an integer port versus None.

The behavior predates PR #944. That PR only adds deterministic mixed ordering at the Host layer and should not broaden into a public endpoint-ordering redesign. Found while reviewing #944 (comment).

Expected behavior

Define and document one cross-type ordering contract for built-in endpoint implementations, or make heterogeneous comparison explicitly unsupported and ensure callers use a shared sort key.

Acceptance criteria

  • Comparing or sorting heterogeneous built-in endpoints does not fail unexpectedly.
  • Default, Unix socket, SNI, and Client Routes endpoints are covered.
  • Equality, hashing, and ordering remain internally consistent.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions