message_bus 3.4.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,121 +0,0 @@
1
- 'use strict';
2
-
3
- class Process extends React.Component {
4
- hup() {
5
- fetch(
6
- `/message-bus/_diagnostics/hup/${this.props.hostname}/${this.props.pid}`,
7
- {
8
- method: 'POST'
9
- }
10
- );
11
- }
12
-
13
- render() {
14
- return (
15
- <tr>
16
- <td>{this.props.pid}</td>
17
- <td>{this.props.full_path}</td>
18
- <td>{this.props.hostname}</td>
19
- <td>{this.props.uptime} secs</td>
20
- <td><button onClick={this.hup.bind(this)}>HUP</button></td>
21
- </tr>
22
- );
23
- }
24
- };
25
-
26
- class DiagnosticsApp extends React.Component {
27
- constructor(props) {
28
- super(props);
29
- this.state = {processes: []};
30
- }
31
-
32
- componentDidMount() {
33
- MessageBus.start();
34
- this.ensureSubscribed();
35
- }
36
-
37
- discover() {
38
- this.ensureSubscribed();
39
-
40
- this.setState({discovering: true});
41
-
42
- var _this = this;
43
- fetch(
44
- "/message-bus/_diagnostics/discover",
45
- {
46
- method: "POST"
47
- }
48
- ).then(function() {
49
- _this.setState({discovering: false})
50
- });
51
- }
52
-
53
- ensureSubscribed() {
54
- if (this.state.subscribed) { return; }
55
-
56
- MessageBus.callbackInterval = 500;
57
-
58
- MessageBus.subscribe(
59
- "/_diagnostics/process-discovery",
60
- this.updateProcess.bind(this)
61
- );
62
-
63
- this.setState({subscribed: true});
64
- }
65
-
66
- updateProcess(data) {
67
- const _this = this;
68
- const processes = this.state.processes.filter(function(process) {
69
- return _this.processUniqueId(process) !== _this.processUniqueId(data);
70
- });
71
- this.setState({processes: processes.concat([data])});
72
- }
73
-
74
- processUniqueId(process) {
75
- return process.hostname + process.pid;
76
- }
77
-
78
- render() {
79
- let disabled = this.state.discovering ? "disabled" : null;
80
-
81
- let _this = this;
82
- let processes = this.state.processes.sort(function(a,b) {
83
- return _this.processUniqueId(a) < _this.processUniqueId(b) ? -1 : 1;
84
- });
85
-
86
- return (
87
- <div>
88
- <header>
89
- <h2>Message Bus Diagnostics</h2>
90
- </header>
91
-
92
- <div>
93
- <button onClick={this.discover.bind(this)} disabled={disabled}>Discover Processes</button>
94
-
95
- <table>
96
- <thead>
97
- <tr>
98
- <td>pid</td>
99
- <td>full_path</td>
100
- <td>hostname</td>
101
- <td>uptime</td>
102
- <td></td>
103
- </tr>
104
- </thead>
105
-
106
- <tbody>
107
- {processes.map(function(process, index){
108
- return <Process key={index} {...process} />;
109
- })}
110
- </tbody>
111
- </table>
112
- </div>
113
- </div>
114
- );
115
- }
116
- }
117
-
118
- ReactDOM.render(
119
- <DiagnosticsApp />,
120
- document.getElementById('app')
121
- );