forked from dunglas/mercure
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dispatch connection and disconnection events (dunglas#238)
* Dispatch connection and disconnection events * Update docs/hub/config.md Co-Authored-By: Jacob Dreesen <[email protected]> Co-authored-by: Jacob Dreesen <[email protected]>
- Loading branch information
Showing
7 changed files
with
263 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ issues: | |
linters: | ||
- gochecknoglobals | ||
- funlen | ||
- godox |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,9 +19,8 @@ organization = "Les-Tilleuls.coop" | |
email = "[email protected]" | ||
[author.address.postal] | ||
city = "Lille" | ||
street = "2 rue Hegel" | ||
code = "59000" | ||
postalline= ["Bâtiment Canal"] | ||
street = "82 rue Winston Churchill" | ||
code = "59160" | ||
country = "France" | ||
%%% | ||
|
||
|
@@ -195,18 +194,18 @@ following data: | |
alternate URLs. The hub **MUST** dispatch this update to subscribers that are subscribed to both | ||
canonical or alternate URLs. | ||
|
||
* `data`: The content of the new version of this topic. | ||
* `data`: the content of the new version of this topic. | ||
|
||
* `target` (optional): Target audience of this update. This key can be present several times. See | ||
* `target` (optional): target audience of this update. This key can be present several times. See | ||
section #Authorization for further information. | ||
|
||
* `id` (optional): The topic's revision identifier: it will be used as the SSE's `id` property. | ||
If omitted, the hub **MUST** generate a valid globally unique id. It **MAY** be a UUID. Even if | ||
provided, the hub **MAY** ignore the id provided by the client and generate its own id. | ||
* `id` (optional): the topic's revision identifier: it will be used as the SSE's `id` property. If | ||
omitted, the hub **MUST** generate a valid globally unique id. It **MAY** be a UUID [@RFC4122]. | ||
Even if provided, the hub **MAY** ignore the id provided by the client and generate its own id. | ||
|
||
* `type` (optional): The SSE's `event` property (a specific event type). | ||
* `type` (optional): the SSE's `event` property (a specific event type). | ||
|
||
* `retry` (optional): The SSE's `retry` property (the reconnection time). | ||
* `retry` (optional): the SSE's `retry` property (the reconnection time). | ||
|
||
In the event of success, the HTTP response's body **MUST** be the `id` associated to this update | ||
generated by the hub and a success HTTP status code **MUST** be returned. The publisher **MUST** be | ||
|
@@ -298,7 +297,7 @@ authorized to receive updates destined for all targets. | |
|
||
To allow re-establishment in case of connection lost, events dispatched by the hub **SHOULD** | ||
include an `id` property. The value contained in this `id` property **SHOULD** be a globally unique | ||
identifier. To do so, a UUID [@!RFC4122] **MAY** be used. | ||
identifier. To do so, a UUID [@RFC4122] **MAY** be used. | ||
|
||
According to the server-sent events specification, in case of connection | ||
lost the subscriber will try to automatically re-connect. During the | ||
|
@@ -324,6 +323,45 @@ after a long disconnection time). | |
The hub **MAY** also specify the reconnection time using the `retry` key, as specified in the | ||
server-sent events format. | ||
|
||
# Subscription Events | ||
|
||
The hub **MAY** publish an update when a subscription to a topic is created or terminated. If this | ||
feature is implemented by the hub, an update **MUST** be dispatched every time that a subscription | ||
is created or terminated, and for each topic to which the client subscribes. | ||
|
||
The topic of this update **MUST** follow the pattern | ||
`https://mercure.rocks/subscriptions/{topic}/{subscriptionID}` where `topic` is the URL-encoded | ||
value of the subscribed topic and `subscriptionID` is an unique identifier for this subscription. | ||
`subscriptionID` **MAY** be a UUID [@RFC4122]. | ||
|
||
The content of the update **MUST** be a JSON-LD [@!W3C.REC-json-ld-20140116] document containing at | ||
least the following properties: | ||
|
||
* `@id`: the identifier of this update, it **MUST** be the same value as the subscription update's | ||
topic | ||
|
||
* `@type`: the fixed value `https://mercure.rocks/Subscription` | ||
|
||
* `topic`: the topic to which the subscription refers | ||
|
||
* `active`: `true` when the subscription is created, and `false` when it is terminated | ||
|
||
* `subscribe`: the subscription targets provided by the subscriber (see section #Authorization) | ||
|
||
* `publish`: the publication targets provided by the subscriber (see section #Authorization) | ||
|
||
* `address` (optional): the IP address ([@!RFC791], [@!RFC8200]) of the subscriber | ||
|
||
The JSON-LD document **MAY** contain other properties. | ||
|
||
In order to only allow authorized subscribers to receive subscription events, the subscription | ||
update **MUST** be marked as intended for subscribers providing the following targets: | ||
|
||
* the fixed value `https://mercure.rocks/targets/subscriptions` | ||
|
||
* a URL following the pattern `https://mercure.rocks/targets/subscriptions/{topic}` where topic is | ||
the URL-encoded value of the subscribed topic | ||
|
||
# Encryption | ||
|
||
Using HTTPS does not prevent the hub from accessing the update's content. Depending of the intended | ||
|