Skip to content

Commit 1b5f2a1

Browse files
committed
feat(docs/develop): ✨ Add pub/sub address reference
1 parent 5cb1f35 commit 1b5f2a1

File tree

2 files changed

+174
-0
lines changed

2 files changed

+174
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
label: Extension Development Specific
2+
# === Uncomment and adjust as needed:
3+
# position: 1
4+
# collapsible: false
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
---
2+
title: Pub/Sub Addresses
3+
description: An overview of all the standardized event bus addresses
4+
---
5+
6+
<!--
7+
Reference
8+
=========
9+
10+
=== When to use this template:
11+
When you're documenting some topic so that users (e.g., ecosystem developers)
12+
can quickly lookup a fact. These articles typically consist of a list, a
13+
definition list, a table, or some other form of "quick-to-lookup" information.
14+
15+
=== When not to use this template:
16+
Do not use a reference article to explain a concept. You should keep additional
17+
information within the reference article to a minimum so that knowledgeable users
18+
can quickly see the facts that are relevant to them. You can link to concepts and
19+
other topics to explain specific concepts, if necessary.
20+
21+
=== Writing tips:
22+
- Write in the present tense
23+
- Use neutral pronouns (they/them instead of he/she and him/her)
24+
- Be respectful to everyone
25+
- Be aware of the potential for cultural misunderstandings
26+
- Keep the amount of additional information to a minimum (focus on the facts)
27+
- If necessary, link to concept topics. Do not explain them in the article
28+
- Use a suitable form of content so that readers can quickly look up the desired
29+
information (e.g., a table, a list, a diagram, or something else)
30+
-->
31+
32+
<!-- Relevant imports: -->
33+
34+
import { Reference, Image } from '/components';
35+
36+
<!-- Short description of what information this document provides: -->
37+
38+
Server State extensions have access to various `publish`/`subscribe` methods to
39+
trigger and listen for common occurrences within the Server State server.
40+
41+
Handling such events via a Pub/Sub system allows us to handle things like
42+
logging with interchangeable plugins instead of attempting to find a "one size
43+
fits all" solution that doesn't exist.
44+
45+
<!-- Content (e.g., a table, a list, a diagram, or a definition list) -->
46+
47+
## Addresses
48+
49+
### Logging (`_LOG/`)
50+
51+
Logging resides within the `_LOG/*` address space.
52+
53+
As a payload, you can pass an array of any JSON-serializable value, but strings
54+
are preferred, if possible.
55+
56+
#### `_LOG/DEBUG`
57+
58+
**Expected payload:** `JSONSerializable[]`
59+
60+
For logging debug messages.
61+
62+
#### `_LOG/INFO`
63+
64+
**Expected payload:** `JSONSerializable[]`
65+
66+
For logging informative messages.
67+
68+
#### `_LOG/WARN`
69+
70+
**Expected payload:** `JSONSerializable[]`
71+
72+
For logging warnings.
73+
74+
#### `_LOG/ERROR`
75+
76+
**Expected payload:** `JSONSerializable[]`
77+
78+
For logging error messages.
79+
80+
### Notifications (`_NOTIFY/`)
81+
82+
Notifying a user/admin about an occurance is a common task. Server State
83+
provides a standardized interface so that users can configure Server State to
84+
notify them via a platform of their choice.
85+
86+
:::tip Time-critical notifications
87+
88+
Every address within the notifications namespace `_NOTIFY` also has a "critical"
89+
version with a `/critical` appendix.
90+
91+
"Critical" notifications should be seen as a sub-category, i.e., an extension
92+
listening for all notifications should also include critical notifications.
93+
94+
Non-critical notifications don't require immediate attention and can, therefore,
95+
be sent as a digest at a later time.
96+
97+
Critical notifications, on the other hand, should get sent to their target
98+
audience as soon as possible.
99+
100+
:::
101+
102+
#### `_NOTIFY/general`
103+
104+
**Expected payload:** `string`
105+
106+
For notifying all users about an event. **Not for time-critical notifications!**
107+
108+
#### `_NOTIFY/general/critical`
109+
110+
**Expected payload:** `string`
111+
112+
Critical variant of [`_NOTIFY/general`](#_notifygeneral)
113+
114+
#### `_NOTIFY/admin`
115+
116+
**Expected payload:** `string`
117+
118+
For notifying admins about an event. **Not for time-critical notifications!**
119+
120+
#### `_NOTIFY/admin/critical`
121+
122+
**Expected payload:** `string`
123+
124+
Critical variant of [`_NOTIFY/admin`](#_notifyadmin)
125+
126+
## Custom Message Addresses
127+
128+
With a few exceptions, addresses are "open" to everyone.
129+
130+
Therefore, if your extension needs custom addresses, you can use any address
131+
name, even if it's not pre-defined.
132+
133+
:::caution Reserved addresses
134+
135+
Your extension may not define its own `_`-prefixed addresses.
136+
137+
Apart from that, there are no "hard" restrictions.
138+
139+
:::
140+
141+
**To avoid address naming conflicts**, we strongly suggest prefixing
142+
extension-specific addresses with `EXTENSIONID/`.
143+
144+
Thus, if, for example, your extension was `ABCDEF`, your address names should
145+
match the following pattern:
146+
147+
```text title="Name pattern for plugin ABCDEF"
148+
ABCDEF/*
149+
```
150+
151+
:::info
152+
153+
We enforce this convention for officially recommended extensions.
154+
155+
:::
156+
157+
<!-- ## See also -->
158+
159+
<!--
160+
Snippets
161+
--------
162+
163+
<Reference to="../other-article">
164+
Relative Link to other article
165+
</Reference>
166+
167+
<Reference to="https://www.example.com">
168+
Example Website
169+
</Reference>
170+
-->

0 commit comments

Comments
 (0)