From e59ab2dbf1b9874b6672f80c01b7e7157fafd8ea Mon Sep 17 00:00:00 2001 From: diamondburned Date: Mon, 26 Oct 2020 21:48:28 -0700 Subject: [PATCH] Clarified ID uniqueness This commit clarifies the rules regarding ID uniqueness and guarantees when it comes to the backend and frontend. This piece of documentation was added into the top package section. --- cchat.go | 10 ++++++++++ repository/main.go | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/cchat.go b/cchat.go index 34f7f2d..cd7de73 100644 --- a/cchat.go +++ b/cchat.go @@ -6,6 +6,16 @@ // // Backend // +// Almost anything in the backend comes with an ID. For example, a Server must +// have an ID, or a Session must have a user ID. The backend is required to +// guarantee that IDs are somehow unique. This should already be the case for +// most chat services; for example, Discord provides IDs for guilds, channels, +// members, and more. The only time that the backend should not guarantee ID +// uniqueness is across Sessions, because it doesn't make sense to do so. In +// this case, the frontend should guarantee uniqueness instead, either by +// discarding duplicated items, overriding them, or anything reasonable and +// explicit. +// // Methods implemented by the backend that have frontend containers as arguments // can do IO. Frontends must NOT rely on individual backend states and should // always assume that they will block. diff --git a/repository/main.go b/repository/main.go index bc721fa..e4726e3 100644 --- a/repository/main.go +++ b/repository/main.go @@ -339,6 +339,17 @@ var Main = Packages{ Backend + Almost anything in the backend comes with an ID. For example, a + Server must have an ID, or a Session must have a user ID. The + backend is required to guarantee that IDs are somehow unique. This + should already be the case for most chat services; for example, + Discord provides IDs for guilds, channels, members, and more. The + only time that the backend should not guarantee ID uniqueness is + across Sessions, because it doesn't make sense to do so. In this + case, the frontend should guarantee uniqueness instead, either by + discarding duplicated items, overriding them, or anything + reasonable and explicit. + Methods implemented by the backend that have frontend containers as arguments can do IO. Frontends must NOT rely on individual backend states and should always assume that they will block.