SPEC-7: Rename 'ts' to 'origin_server_ts'

This commit is contained in:
Mark Haines 2014-10-17 17:12:25 +01:00
parent 456017e0ae
commit f5cf7ac25b
16 changed files with 42 additions and 42 deletions

View File

@ -58,8 +58,8 @@ class EventFactory(object):
random_string(10), self.hs.hostname random_string(10), self.hs.hostname
) )
if "ts" not in kwargs: if "origin_server_ts" not in kwargs:
kwargs["ts"] = int(self.clock.time_msec()) kwargs["origin_server_ts"] = int(self.clock.time_msec())
# The "age" key is a delta timestamp that should be converted into an # The "age" key is a delta timestamp that should be converted into an
# absolute timestamp the minute we see it. # absolute timestamp the minute we see it.

View File

@ -96,7 +96,7 @@ class PduCodec(object):
if k not in ["event_id", "room_id", "type", "prev_events"] if k not in ["event_id", "room_id", "type", "prev_events"]
}) })
if "ts" not in kwargs: if "origin_server_ts" not in kwargs:
kwargs["ts"] = int(self.clock.time_msec()) kwargs["origin_server_ts"] = int(self.clock.time_msec())
return Pdu(**kwargs) return Pdu(**kwargs)

View File

@ -157,7 +157,7 @@ class TransactionActions(object):
transaction.prev_ids = yield self.store.prep_send_transaction( transaction.prev_ids = yield self.store.prep_send_transaction(
transaction.transaction_id, transaction.transaction_id,
transaction.destination, transaction.destination,
transaction.ts, transaction.origin_server_ts,
[(p["pdu_id"], p["origin"]) for p in transaction.pdus] [(p["pdu_id"], p["origin"]) for p in transaction.pdus]
) )

View File

@ -421,7 +421,7 @@ class ReplicationLayer(object):
return Transaction( return Transaction(
origin=self.server_name, origin=self.server_name,
pdus=pdus, pdus=pdus,
ts=int(self._clock.time_msec()), origin_server_ts=int(self._clock.time_msec()),
destination=None, destination=None,
) )
@ -589,7 +589,7 @@ class _TransactionQueue(object):
logger.debug("TX [%s] Persisting transaction...", destination) logger.debug("TX [%s] Persisting transaction...", destination)
transaction = Transaction.create_new( transaction = Transaction.create_new(
ts=self._clock.time_msec(), origin_server_ts=self._clock.time_msec(),
transaction_id=str(self._next_txn_id), transaction_id=str(self._next_txn_id),
origin=self.server_name, origin=self.server_name,
destination=destination, destination=destination,

View File

@ -40,7 +40,7 @@ class Pdu(JsonEncodedObject):
{ {
"pdu_id": "78c", "pdu_id": "78c",
"ts": 1404835423000, "origin_server_ts": 1404835423000,
"origin": "bar", "origin": "bar",
"prev_ids": [ "prev_ids": [
["23b", "foo"], ["23b", "foo"],
@ -55,7 +55,7 @@ class Pdu(JsonEncodedObject):
"pdu_id", "pdu_id",
"context", "context",
"origin", "origin",
"ts", "origin_server_ts",
"pdu_type", "pdu_type",
"destinations", "destinations",
"transaction_id", "transaction_id",
@ -82,7 +82,7 @@ class Pdu(JsonEncodedObject):
"pdu_id", "pdu_id",
"context", "context",
"origin", "origin",
"ts", "origin_server_ts",
"pdu_type", "pdu_type",
"content", "content",
] ]
@ -186,7 +186,7 @@ class Transaction(JsonEncodedObject):
"transaction_id", "transaction_id",
"origin", "origin",
"destination", "destination",
"ts", "origin_server_ts",
"previous_ids", "previous_ids",
"pdus", "pdus",
"edus", "edus",
@ -203,7 +203,7 @@ class Transaction(JsonEncodedObject):
"transaction_id", "transaction_id",
"origin", "origin",
"destination", "destination",
"ts", "origin_server_ts",
"pdus", "pdus",
] ]
@ -225,10 +225,10 @@ class Transaction(JsonEncodedObject):
@staticmethod @staticmethod
def create_new(pdus, **kwargs): def create_new(pdus, **kwargs):
""" Used to create a new transaction. Will auto fill out """ Used to create a new transaction. Will auto fill out
transaction_id and ts keys. transaction_id and origin_server_ts keys.
""" """
if "ts" not in kwargs: if "origin_server_ts" not in kwargs:
raise KeyError("Require 'ts' to construct a Transaction") raise KeyError("Require 'origin_server_ts' to construct a Transaction")
if "transaction_id" not in kwargs: if "transaction_id" not in kwargs:
raise KeyError( raise KeyError(
"Require 'transaction_id' to construct a Transaction" "Require 'transaction_id' to construct a Transaction"

View File

@ -361,7 +361,7 @@ class SQLBaseStore(object):
if "age_ts" not in d: if "age_ts" not in d:
# For compatibility # For compatibility
d["age_ts"] = d["ts"] if "ts" in d else 0 d["age_ts"] = d["origin_server_ts"] if "origin_server_ts" in d else 0
return self.event_factory.create_event( return self.event_factory.create_event(
etype=d["type"], etype=d["type"],

View File

@ -789,7 +789,7 @@ class PdusTable(Table):
"origin", "origin",
"context", "context",
"pdu_type", "pdu_type",
"ts", "origin_server_ts",
"depth", "depth",
"is_state", "is_state",
"content_json", "content_json",

View File

@ -18,7 +18,7 @@ CREATE TABLE IF NOT EXISTS pdus(
origin TEXT, origin TEXT,
context TEXT, context TEXT,
pdu_type TEXT, pdu_type TEXT,
ts INTEGER, origin_server_ts INTEGER,
depth INTEGER DEFAULT 0 NOT NULL, depth INTEGER DEFAULT 0 NOT NULL,
is_state BOOL, is_state BOOL,
content_json TEXT, content_json TEXT,

View File

@ -16,7 +16,7 @@
CREATE TABLE IF NOT EXISTS received_transactions( CREATE TABLE IF NOT EXISTS received_transactions(
transaction_id TEXT, transaction_id TEXT,
origin TEXT, origin TEXT,
ts INTEGER, origin_server_ts INTEGER,
response_code INTEGER, response_code INTEGER,
response_json TEXT, response_json TEXT,
has_been_referenced BOOL default 0, -- Whether thishas been referenced by a prev_tx has_been_referenced BOOL default 0, -- Whether thishas been referenced by a prev_tx
@ -35,7 +35,7 @@ CREATE TABLE IF NOT EXISTS sent_transactions(
destination TEXT, destination TEXT,
response_code INTEGER DEFAULT 0, response_code INTEGER DEFAULT 0,
response_json TEXT, response_json TEXT,
ts INTEGER origin_server_ts INTEGER
); );
CREATE INDEX IF NOT EXISTS sent_transaction_dest ON sent_transactions(destination); CREATE INDEX IF NOT EXISTS sent_transaction_dest ON sent_transactions(destination);

View File

@ -87,7 +87,7 @@ class TransactionStore(SQLBaseStore):
txn.execute(query, (code, response_json, transaction_id, origin)) txn.execute(query, (code, response_json, transaction_id, origin))
def prep_send_transaction(self, transaction_id, destination, ts, pdu_list): def prep_send_transaction(self, transaction_id, destination, origin_server_ts, pdu_list):
"""Persists an outgoing transaction and calculates the values for the """Persists an outgoing transaction and calculates the values for the
previous transaction id list. previous transaction id list.
@ -97,7 +97,7 @@ class TransactionStore(SQLBaseStore):
Args: Args:
transaction_id (str) transaction_id (str)
destination (str) destination (str)
ts (int) origin_server_ts (int)
pdu_list (list) pdu_list (list)
Returns: Returns:
@ -106,10 +106,10 @@ class TransactionStore(SQLBaseStore):
return self.runInteraction( return self.runInteraction(
self._prep_send_transaction, self._prep_send_transaction,
transaction_id, destination, ts, pdu_list transaction_id, destination, origin_server_ts, pdu_list
) )
def _prep_send_transaction(self, txn, transaction_id, destination, ts, def _prep_send_transaction(self, txn, transaction_id, destination, origin_server_ts,
pdu_list): pdu_list):
# First we find out what the prev_txs should be. # First we find out what the prev_txs should be.
@ -131,7 +131,7 @@ class TransactionStore(SQLBaseStore):
None, None,
transaction_id=transaction_id, transaction_id=transaction_id,
destination=destination, destination=destination,
ts=ts, origin_server_ts=origin_server_ts,
response_code=0, response_code=0,
response_json=None response_json=None
)) ))
@ -251,7 +251,7 @@ class ReceivedTransactionsTable(Table):
fields = [ fields = [
"transaction_id", "transaction_id",
"origin", "origin",
"ts", "origin_server_ts",
"response_code", "response_code",
"response_json", "response_json",
"has_been_referenced", "has_been_referenced",
@ -267,7 +267,7 @@ class SentTransactions(Table):
"id", "id",
"transaction_id", "transaction_id",
"destination", "destination",
"ts", "origin_server_ts",
"response_code", "response_code",
"response_json", "response_json",
] ]

View File

@ -99,7 +99,7 @@ class FederationTestCase(unittest.TestCase):
origin="red", origin="red",
context="my-context", context="my-context",
pdu_type="m.topic", pdu_type="m.topic",
ts=123456789000, origin_server_ts=123456789000,
depth=1, depth=1,
is_state=True, is_state=True,
content_json='{"topic":"The topic"}', content_json='{"topic":"The topic"}',
@ -134,7 +134,7 @@ class FederationTestCase(unittest.TestCase):
origin="red", origin="red",
context="my-context", context="my-context",
pdu_type="m.text", pdu_type="m.text",
ts=123456789001, origin_server_ts=123456789001,
depth=1, depth=1,
content_json='{"text":"Here is the message"}', content_json='{"text":"Here is the message"}',
) )
@ -158,7 +158,7 @@ class FederationTestCase(unittest.TestCase):
origin="red", origin="red",
destinations=["remote"], destinations=["remote"],
context="my-context", context="my-context",
ts=123456789002, origin_server_ts=123456789002,
pdu_type="m.test", pdu_type="m.test",
content={"testing": "content here"}, content={"testing": "content here"},
depth=1, depth=1,
@ -170,14 +170,14 @@ class FederationTestCase(unittest.TestCase):
"remote", "remote",
path="/_matrix/federation/v1/send/1000000/", path="/_matrix/federation/v1/send/1000000/",
data={ data={
"ts": 1000000, "origin_server_ts": 1000000,
"origin": "test", "origin": "test",
"pdus": [ "pdus": [
{ {
"origin": "red", "origin": "red",
"pdu_id": "abc123def456", "pdu_id": "abc123def456",
"prev_pdus": [], "prev_pdus": [],
"ts": 123456789002, "origin_server_ts": 123456789002,
"context": "my-context", "context": "my-context",
"pdu_type": "m.test", "pdu_type": "m.test",
"is_state": False, "is_state": False,
@ -207,7 +207,7 @@ class FederationTestCase(unittest.TestCase):
path="/_matrix/federation/v1/send/1000000/", path="/_matrix/federation/v1/send/1000000/",
data={ data={
"origin": "test", "origin": "test",
"ts": 1000000, "origin_server_ts": 1000000,
"pdus": [], "pdus": [],
"edus": [ "edus": [
{ {
@ -234,7 +234,7 @@ class FederationTestCase(unittest.TestCase):
"/_matrix/federation/v1/send/1001000/", "/_matrix/federation/v1/send/1001000/",
"""{ """{
"origin": "remote", "origin": "remote",
"ts": 1001000, "origin_server_ts": 1001000,
"pdus": [], "pdus": [],
"edus": [ "edus": [
{ {

View File

@ -68,7 +68,7 @@ class PduCodecTestCase(unittest.TestCase):
context="rooooom", context="rooooom",
pdu_type="m.room.message", pdu_type="m.room.message",
origin="bar.com", origin="bar.com",
ts=12345, origin_server_ts=12345,
depth=5, depth=5,
prev_pdus=[("alice", "bob.com")], prev_pdus=[("alice", "bob.com")],
is_state=False, is_state=False,
@ -123,7 +123,7 @@ class PduCodecTestCase(unittest.TestCase):
context="rooooom", context="rooooom",
pdu_type="m.room.topic", pdu_type="m.room.topic",
origin="bar.com", origin="bar.com",
ts=12345, origin_server_ts=12345,
depth=5, depth=5,
prev_pdus=[("alice", "bob.com")], prev_pdus=[("alice", "bob.com")],
is_state=True, is_state=True,

View File

@ -68,7 +68,7 @@ class FederationTestCase(unittest.TestCase):
pdu_type=MessageEvent.TYPE, pdu_type=MessageEvent.TYPE,
context="foo", context="foo",
content={"msgtype": u"fooo"}, content={"msgtype": u"fooo"},
ts=0, origin_server_ts=0,
pdu_id="a", pdu_id="a",
origin="b", origin="b",
) )
@ -95,7 +95,7 @@ class FederationTestCase(unittest.TestCase):
target_host=self.hostname, target_host=self.hostname,
context=room_id, context=room_id,
content={}, content={},
ts=0, origin_server_ts=0,
pdu_id="a", pdu_id="a",
origin="b", origin="b",
) )
@ -127,7 +127,7 @@ class FederationTestCase(unittest.TestCase):
state_key="@red:not%s" % self.hostname, state_key="@red:not%s" % self.hostname,
context=room_id, context=room_id,
content={}, content={},
ts=0, origin_server_ts=0,
pdu_id="a", pdu_id="a",
origin="b", origin="b",
) )

View File

@ -39,7 +39,7 @@ ONLINE = PresenceState.ONLINE
def _expect_edu(destination, edu_type, content, origin="test"): def _expect_edu(destination, edu_type, content, origin="test"):
return { return {
"origin": origin, "origin": origin,
"ts": 1000000, "origin_server_ts": 1000000,
"pdus": [], "pdus": [],
"edus": [ "edus": [
{ {

View File

@ -29,7 +29,7 @@ from synapse.handlers.typing import TypingNotificationHandler
def _expect_edu(destination, edu_type, content, origin="test"): def _expect_edu(destination, edu_type, content, origin="test"):
return { return {
"origin": origin, "origin": origin,
"ts": 1000000, "origin_server_ts": 1000000,
"pdus": [], "pdus": [],
"edus": [ "edus": [
{ {

View File

@ -599,7 +599,7 @@ def new_fake_pdu(pdu_id, context, pdu_type, state_key, prev_state_id,
prev_state_id=prev_state_id, prev_state_id=prev_state_id,
origin="example.com", origin="example.com",
context="context", context="context",
ts=1405353060021, origin_server_ts=1405353060021,
depth=depth, depth=depth,
content_json="{}", content_json="{}",
unrecognized_keys="{}", unrecognized_keys="{}",