Channel API¶
Not intended for direct client use.
-
class
tgdb.channel.
ExceptionHandleResult
(value)¶ How to handle exceptions.
-
class
tgdb.channel.
LinkState
(value)¶ Socket link state.
-
class
tgdb.channel.
ProtocolType
(value)¶ Types of protocol.
-
class
tgdb.channel.
ResendMode
(value)¶ The resend mode when disconnected.
-
class
tgdb.channel.
Status
(value)¶ Connection status to the server.
-
class
tgdb.channel.
TGChannel
¶ Represents a request-reply session.
Handles all initialization, tear down, and request-reply.
-
abstract property
authtoken
¶ Gets the authentication token that the server gave to us.
-
abstract property
clientid
¶ Gets this client’s identifier.
-
abstract
connect
()¶ Connect this channel to the server.
-
classmethod
createChannel
(urlpath: str, username=None, password=None, dbName: str = None, props: tgdb.utils.TGProperties = None)¶ Creates a channel instance.
- Parameters
urlPath – The URL for the database to connect to. When running on localhost, it should look like tcp://localhost:8222 for an insecure connection.
username – The user’s name of the database to use to connect to the database.
password – The user’s password for the database server.
dbName – The database name to connect to.
props – The properties to set up the connection with, contains any additional properties.
- Returns
The connection object requested.
-
abstract
createSocket
() → tgdb.channel.TGSocket¶ Creates and returns a default socket.
-
abstract
disconnect
()¶ Disconnect from the server.
-
abstract
handleException
(e: Exception) → tgdb.channel.ExceptionHandleResult¶ Handles the exception.
- Parameters
e – The exception to handle.
- Returns
Returns how the exception was handled.
-
inError
()¶ Whether the channel is in an error.
-
property
isClosed
¶ Whether the channel is closed.
- Returns
True if the channel is closed.
-
property
isConnected
¶ Whether the channel is connected.
-
abstract property
linkstate
¶ Gets whether the channel is connected, or any reason that it is not.
-
abstract property
outboxaddr
¶ Gets the server-side address.
-
abstract property
properties
¶ Gets the properties for this channel.
-
abstract property
protocolversions
¶ Gets the protocol version for both the client and server.
-
abstract
readMessage
() → tgdb.pdu.TGMessage¶ Reads the message on the socket.
-
abstract
send
(msg: tgdb.pdu.TGMessage, response: tgdb.channel.TGChannelResponseWaiter = None) → tgdb.pdu.TGMessage¶ Sends a message and waits for a response.
-
abstract property
sessionid
¶ Gets the session id for this session.
-
abstract
start
()¶ Starts the thread responsible for reading.
-
abstract
stop
(stopmethod=<TGChannelStopMethod.Graceful: 0>, msg=None)¶ Stop the listening thread.
-
abstract property
waiters
¶ The waiters currently active.
- Returns
A dictionary with keys representing the request identifier and values of that channel response waiter.
-
abstract property
-
class
tgdb.channel.
TGChannelResponseWaiter
¶ Keeps track of a single request/response from the server.
-
class
WaiterStatus
(value)¶ An enumeration.
-
abstract
awaiting
(status: tgdb.channel.TGChannelResponseWaiter.WaiterStatus)¶ Thread-safe checking of a status.
-
abstract property
isBlocking
¶ Is this waiter blocking?
- Returns
True if this waiter blocks the thread, else False.
-
abstract property
reply
¶ Gets the thread-safe reply
-
abstract property
requestid
¶ The request id corresponding to the response that this waiter is for.
-
abstract property
status
¶ Gets the status of this ChannelResponseWaiter
-
class
-
class
tgdb.channel.
TGChannelStopMethod
(value)¶ Way that the channel was stopped.
-
class
tgdb.channel.
TGChannelUrl
¶ Represents a parsed URL.
-
abstract property
host
¶ The host for this URL.
-
classmethod
parseUrl
(url)¶ Parse the URL and return a corresponding instance.
-
abstract property
port
¶ The pot for this URL.
-
abstract property
properties
¶ Any properties specified.
-
abstract property
protocol
¶ Gets the protol corresponding with this URL
-
abstract property
url
¶ The full URL string.
-
abstract property
user
¶ The user for this URL.
-
abstract property
-
class
tgdb.channel.
TGSocket
¶ Represents a single lower-level socket.
-
abstract
close
()¶ Disconnect from the server.
-
abstract
connect
()¶ Connect to the server.
-
abstract property
handle
¶ Gets the lower-level socket.
-
abstract property
inboxaddr
¶ Gets the client-side address.
-
abstract
recvMsg
() → tgdb.pdu.TGMessage¶ Reads a message from.
-
abstract
send
(msg: tgdb.pdu.TGMessage) → int¶ Send a message, returning the number of bytes sent.
-
tryRead
() → tgdb.pdu.TGMessage¶ Try to read a message.
- Returns
None if no message was available, otherwise the message that was available.
-
abstract