annotate mod_http_stats_stream/README.markdown @ 3666:637d63b7398e

Mark some modules as Merged
author Kim Alvefur <zash@zash.se>
date Tue, 03 Sep 2019 00:54:01 +0200
parents 740870196b97
children bac3dae031ee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2480
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
1 ---
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
2 depends:
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
3 - 'mod\_http'
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
4 provides:
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
5 - http
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
6 ---
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
7
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
8 # Introduction
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
9
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
10 This module provides a streaming interface to [Prosodys internal statistics][doc:statistics] via
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
11 [Server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events).
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
12
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
13 ## Example
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
14
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
15 ```js
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
16 var evtSource = new EventSource("/stats_stream");
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
17
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
18 /*
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
19 * An event with all current statistics in the form of a JSON object.
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
20 * Normally sent only once, when first connected to the stream.
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
21 */
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
22 evtSource.addEventListener("stats-full", function(e) {
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
23 var initial_stats = JSON.parse(e.data);
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
24 console.log(initial_stats);
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
25 }, false);
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
26
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
27 /*
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
28 * An event containing only statistics that have changed since the last
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
29 * 'stats-full' or 'stats-updated' event.
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
30 */
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
31 evtSource.addEventListener("stats-updated", function(e) {
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
32 var updated_stats = JSON.parse(e.data);
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
33 console.log(updated_stats);
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
34 }, false);
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
35 ```
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
36
3643
740870196b97 mod_http_stats_stream: Make global to simplify
Kim Alvefur <zash@zash.se>
parents: 2480
diff changeset
37 # Compatibility
2480
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
38
3643
740870196b97 mod_http_stats_stream: Make global to simplify
Kim Alvefur <zash@zash.se>
parents: 2480
diff changeset
39 Prosody \>= 0.11.0