Default EndPoint implementation, basically just an address and port.
| 180 | |
| 181 | @total_ordering |
| 182 | class DefaultEndPoint(EndPoint): |
| 183 | """ |
| 184 | Default EndPoint implementation, basically just an address and port. |
| 185 | """ |
| 186 | |
| 187 | def __init__(self, address, port=9042): |
| 188 | self._address = address |
| 189 | self._port = port |
| 190 | |
| 191 | @property |
| 192 | def address(self): |
| 193 | return self._address |
| 194 | |
| 195 | @property |
| 196 | def port(self): |
| 197 | return self._port |
| 198 | |
| 199 | def resolve(self): |
| 200 | return self._address, self._port |
| 201 | |
| 202 | def __eq__(self, other): |
| 203 | return isinstance(other, DefaultEndPoint) and \ |
| 204 | self.address == other.address and self.port == other.port |
| 205 | |
| 206 | def __hash__(self): |
| 207 | return hash((self.address, self.port)) |
| 208 | |
| 209 | def __lt__(self, other): |
| 210 | return (self.address, self.port) < (other.address, other.port) |
| 211 | |
| 212 | def __str__(self): |
| 213 | return str("%s:%d" % (self.address, self.port)) |
| 214 | |
| 215 | def __repr__(self): |
| 216 | return "<%s: %s:%d>" % (self.__class__.__name__, self.address, self.port) |
| 217 | |
| 218 | |
| 219 | class DefaultEndPointFactory(EndPointFactory): |
no outgoing calls