mirror of
https://github.com/fluencelabs/examples
synced 2025-06-18 12:31:21 +00:00
counterPeerId and counterServiceId to config
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
import fs from 'fs';
|
||||
|
||||
export const configHelp = "Config structure: { port, relay, serviceId, providers, mode}\n" +
|
||||
"Where mode can be: 'random' (default) or 'round-robin'"
|
||||
export const configHelp = "Config structure: { port, relay, serviceId, providers, mode, counterServiceId?, counterPeerId?}\n" +
|
||||
"Where 'mode' can be: 'random' (default) or 'round-robin',\n" +
|
||||
"'counterServiceId' and 'counterPeerId' will use local service if undefined"
|
||||
|
||||
export function readConfig(path) {
|
||||
const rawdata = fs.readFileSync(path);
|
||||
|
@ -56,6 +56,9 @@ registerCounter(fluence, "counter", {
|
||||
}
|
||||
})
|
||||
|
||||
const counterServiceId = config.counterServiceId || 'counter'
|
||||
const counterPeerId = config.counterPeerId || fluence.getStatus().peerId
|
||||
|
||||
async function methodHandler(req, method) {
|
||||
console.log(`Receiving request '${method}'`);
|
||||
let result;
|
||||
@ -63,7 +66,7 @@ async function methodHandler(req, method) {
|
||||
result = await randomLoadBalancingEth(fluence, config.providers, method, req.map((s) => JSON.stringify(s)), config.serviceId);
|
||||
} else if (config.mode === "round-robin") {
|
||||
console.log("peerId: " + fluence.getStatus().peerId)
|
||||
result = await roundRobinEth(fluence, config.providers, method, req.map((s) => JSON.stringify(s)), config.serviceId, "counter", fluence.getStatus().peerId,
|
||||
result = await roundRobinEth(fluence, config.providers, method, req.map((s) => JSON.stringify(s)), config.serviceId, counterServiceId, counterPeerId,
|
||||
config.serviceId);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user