iotcs.messaging.client.device.persistence module¶
-
class
iotcs.messaging.client.device.persistence.
BatchByPersistence
¶ Bases:
object
A class for persisting DeviceFunction.BatchBy policy data.
See
BatchBySize
SeeBatchByTime
SeeBatchByCost
Return an instance of BatchByPersistence.
Raises: StateException
if persistence is not enabled.-
CREATE_TABLE_SQL
= 'CREATE TABLE IF NOT EXISTS BATCH_BY (TIMESTAMP BIGINT NOT NULL,ENDPOINT_ID VARCHAR(256) NOT NULL,MESSAGE_ID VARCHAR(256) NOT NULL,MESSAGE BLOB, PRIMARY KEY (MESSAGE_ID))'¶
-
DBNAME
= None¶
-
DBREADLOCK
= None¶
-
DBWRITELOCK
= None¶
-
DELETE_SQL
= 'DELETE FROM BATCH_BY WHERE MESSAGE_ID = ?'¶
-
ENDPOINT_ID_INDEX_SQL
= 'CREATE INDEX IF NOT EXISTS endpoint_id ON BATCH_BY (ENDPOINT_ID)'¶
-
LOAD_MESSAGE_SQL
= 'SELECT MESSAGE FROM BATCH_BY WHERE ENDPOINT_ID = ? ORDER BY TIMESTAMP'¶
-
LOAD_TABLE_SQL
= 'SELECT TIMESTAMP,ENDPOINT_ID,MESSAGE_ID,MESSAGE FROM BATCH_BY WHERE ENDPOINT_ID = ? ORDER BY TIMESTAMP'¶
-
SAVE_SQL
= 'INSERT INTO BATCH_BY (TIMESTAMP,ENDPOINT_ID,MESSAGE_ID,MESSAGE) VALUES (?, ?, ?, ?)'¶
-
TABLE_NAME
= 'BATCH_BY'¶
-
delete
(messages)¶ Delete the given collection of messages from persistent storage.
None empty collections are supported, just ignored. None entries in the collection are ignored. This method will block until the job is complete.
Parameters: message – The messages to delete
-
classmethod
getInstance
()¶
-
classmethod
isEnabled
()¶
-
load
(endpointId)¶ Return a list of persisted messages associated with endpointId.
Parameters: endpointId – Id of the subsystem that the caller want to load messages for Returns: a list messages that were persisted for given subsystem. Should not return None (it would be an error to do so) but None returns are treated as empty.
-
save
(messages, endpointId)¶ Save the given collection of messages to persistent storage.
None or empty collections are supported, just ignored. None entries in the collection are ignored. This method will block until the job is complete.
Parameters: - messages – The messages to save
- endpointId – Id of the subsystem that the messages belongs to
-
-
class
iotcs.messaging.client.device.persistence.
MessagePersistence
¶ Bases:
object
A class for persisting
message
messages.Return an instance of MessagePersistence.
Raises: StateException
if persistence is not enabled.-
CREATE_TABLE_SQL
= 'CREATE TABLE IF NOT EXISTS MESSAGE_PERSISTENT_STORE (TIMESTAMP BIGINT NOT NULL,UUID VARCHAR(256) NOT NULL,ENDPOINT_ID VARCHAR(256) NOT NULL,MESSAGE BLOB, PRIMARY KEY (UUID))'¶
-
DBNAME
= None¶
-
DBREADLOCK
= None¶
-
DBWRITELOCK
= None¶
-
DELETE_SQL
= 'DELETE FROM MESSAGE_PERSISTENT_STORE WHERE UUID = ?'¶
-
ENDPOINT_ID_INDEX_SQL
= 'CREATE INDEX IF NOT EXISTS endpoint_id ON MESSAGE_PERSISTENT_STORE (ENDPOINT_ID)'¶
-
LOAD_MESSAGE_SQL
= 'SELECT MESSAGE FROM MESSAGE_PERSISTENT_STORE WHERE ENDPOINT_ID = ? ORDER BY TIMESTAMP'¶
-
LOAD_TABLE_SQL
= 'SELECT TIMESTAMP,UUID,ENDPOINT_ID,MESSAGE FROM MESSAGE_PERSISTENT_STORE WHERE ENDPOINT_ID = ? ORDER BY TIMESTAMP'¶
-
SAVE_SQL
= 'INSERT INTO MESSAGE_PERSISTENT_STORE (TIMESTAMP,UUID,ENDPOINT_ID,MESSAGE) VALUES (?, ?, ?, ?)'¶
-
TABLE_NAME
= 'MESSAGE_PERSISTENT_STORE'¶
-
delete
(messages)¶ Delete the given collection of messages from persistent storage.
None empty collections are supported, just ignored. None entries in the collection are ignored. This method will block until the job is complete.
Parameters: message – The messages to delete
-
classmethod
getInstance
()¶
-
classmethod
isEnabled
()¶
-
load
(endpointId)¶ Return a list of persisted messages associated with endpointId.
Parameters: endpointId – Id of the subsystem that the caller want to load messages for Returns: a list messages that were persisted for given subsystem. Should not return None (it would be an error to do so) but None returns are treated as empty.
-
save
(messages, endpointId)¶ Save the given collection of messages to persistent storage.
None or empty collections are supported, just ignored. None entries in the collection are ignored. This method will block until the job is complete.
Parameters: - message – The messages to save
- endpointId – Id of the subsystem that the messages belongs to
-