You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

54 lines
2.6 KiB

  1. = Server to Server =
  2. == Server to Server Stack ==
  3. To use the server to server stack, home servers should only need to interact with the Messaging layer.
  4. The server to server side of things is designed into 4 distinct layers:
  5. 1. Messaging Layer
  6. 2. Pdu Layer
  7. 3. Transaction Layer
  8. 4. Transport Layer
  9. Where the bottom (the transport layer) is what talks to the internet via HTTP, and the top (the messaging layer) talks to the rest of the Home Server with a domain specific API.
  10. 1. Messaging Layer
  11. This is what the rest of the Home Server hits to send messages, join rooms, etc. It also allows you to register callbacks for when it get's notified by lower levels that e.g. a new message has been received.
  12. It is responsible for serializing requests to send to the data layer, and to parse requests received from the data layer.
  13. 2. PDU Layer
  14. This layer handles:
  15. * duplicate pdu_id's - i.e., it makes sure we ignore them.
  16. * responding to requests for a given pdu_id
  17. * responding to requests for all metadata for a given context (i.e. room)
  18. * handling incoming pagination requests
  19. So it has to parse incoming messages to discover which are metadata and which aren't, and has to correctly clobber existing metadata where appropriate.
  20. For incoming PDUs, it has to check the PDUs it references to see if we have missed any. If we have go and ask someone (another home server) for it.
  21. 3. Transaction Layer
  22. This layer makes incoming requests idempotent. I.e., it stores which transaction id's we have seen and what our response were. If we have already seen a message with the given transaction id, we do not notify higher levels but simply respond with the previous response.
  23. transaction_id is from "GET /send/<tx_id>/"
  24. It's also responsible for batching PDUs into single transaction for sending to remote destinations, so that we only ever have one transaction in flight to a given destination at any one time.
  25. This is also responsible for answering requests for things after a given set of transactions, i.e., ask for everything after 'ver' X.
  26. 4. Transport Layer
  27. This is responsible for starting a HTTP server and hitting the correct callbacks on the Transaction layer, as well as sending both data and requests for data.
  28. == Persistence ==
  29. We persist things in a single sqlite3 database. All database queries get run on a separate, dedicated thread. This that we only ever have one query running at a time, making it a lot easier to do things in a safe manner.
  30. The queries are located in the synapse.persistence.transactions module, and the table information in the synapse.persistence.tables module.