-
-
Notifications
You must be signed in to change notification settings - Fork 588
/
Copy pathissue-777.js
111 lines (100 loc) · 1.7 KB
/
issue-777.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
"use strict";
/*const tracer = require("dd-trace").init({
service: "moleculer", // shows up as Service in Datadog UI
url: "http://127.0.0.1:8126",
debug: true,
samplingPriority: "USER_KEEP"
});
tracer.use("http");
tracer.use("ioredis");
*/
const ServiceBroker = require("../src/service-broker");
("use strict");
const { MoleculerError } = require("../src/errors");
const _ = require("lodash");
const { inspect } = require("util");
const THROW_ERR = false;
// Create broker
const broker = new ServiceBroker({
nodeID: "node-1",
logger: console,
logLevel: "info",
//transporter: "redis://localhost:6379",
//cacher: true, //"redis://localhost:6379",
tracing: {
events: true,
stackTrace: true,
sampling: {
rate: 1
//tracesPerSecond: 1
},
exporter: [
/*{
type: "Console",
options: {
width: 100,
gaugeWidth: 30,
logger: console.info
}
},*/
/*{
type: "Datadog",
options: {
tracer
}
}*/
{
type: "Zipkin",
options: {
safetyTags: false,
baseURL: "http://127.0.0.1:9411"
}
},
{
type: "Jaeger",
options: {
safetyTags: false,
endpoint: "http://localhost:14268/api/traces"
}
}
/*{
type: "Event",
options: {
}
}*/
/*{
type: "EventLegacy"
}*/
]
}
});
broker.createService({
name: "greeter",
actions: {
hello: {
tracing: {
safetyTags: true
},
handler(ctx) {
return `Hello!`;
}
}
}
});
// Start server
broker.start().then(() => {
broker.repl();
const a = {
aa: 5,
c: "John"
};
const b = {
bb: 10,
a: a
};
a.b = b;
// Call action
setInterval(() => {
broker.call("greeter.hello", a).then(console.log).catch(console.error);
}, 5000);
});