1
0

architecture.rst 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. Synapse Architecture
  2. ====================
  3. As of the end of Oct 2014, Synapse's overall architecture looks like::
  4. synapse
  5. .-----------------------------------------------------.
  6. | Notifier |
  7. | ^ | |
  8. | | | |
  9. | .------------|------. |
  10. | | handlers/ | | |
  11. | | v | |
  12. | | Event*Handler <--------> rest/* <=> Client
  13. | | Rooms*Handler | |
  14. HSes <=> federation/* <==> FederationHandler | |
  15. | | | PresenceHandler | |
  16. | | | TypingHandler | |
  17. | | '-------------------' |
  18. | | | | |
  19. | | state/* | |
  20. | | | | |
  21. | | v v |
  22. | `--------------> storage/* |
  23. | | |
  24. '--------------------------|--------------------------'
  25. v
  26. .----.
  27. | DB |
  28. '----'
  29. * Handlers: business logic of synapse itself. Follows a set contract of BaseHandler:
  30. - BaseHandler gives us onNewRoomEvent which: (TODO: flesh this out and make it less cryptic):
  31. + handle_state(event)
  32. + auth(event)
  33. + persist_event(event)
  34. + notify notifier or federation(event)
  35. - PresenceHandler: use distributor to get EDUs out of Federation. Very
  36. lightweight logic built on the distributor
  37. - TypingHandler: use distributor to get EDUs out of Federation. Very
  38. lightweight logic built on the distributor
  39. - EventsHandler: handles the events stream...
  40. - FederationHandler: - gets PDU from Federation Layer; turns into an event;
  41. follows basehandler functionality.
  42. - RoomsHandler: does all the room logic, including members - lots of classes in
  43. RoomsHandler.
  44. - ProfileHandler: talks to the storage to store/retrieve profile info.
  45. * EventFactory: generates events of particular event types.
  46. * Notifier: Backs the events handler
  47. * REST: Interfaces handlers and events to the outside world via HTTP/JSON.
  48. Converts events back and forth from JSON.
  49. * Federation: holds the HTTP client & server to talk to other servers. Does
  50. replication to make sure there's nothing missing in the graph. Handles
  51. reliability. Handles txns.
  52. * Distributor: generic event bus. used for presence & typing only currently.
  53. Notifier could be implemented using Distributor - so far we are only using for
  54. things which actually /require/ dynamic pluggability however as it can
  55. obfuscate the actual flow of control.
  56. * Auth: helper singleton to say whether a given event is allowed to do a given
  57. thing (TODO: put this on the diagram)
  58. * State: helper singleton: does state conflict resolution. You give it an event
  59. and it tells you if it actually updates the state or not, and annotates the
  60. event up properly and handles merge conflict resolution.
  61. * Storage: abstracts the storage engine.