-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added getters in FluvioError and made example js use it (#34)
- Loading branch information
Showing
4 changed files
with
76 additions
and
17 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
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 |
---|---|---|
@@ -1,22 +1,53 @@ | ||
import("../pkg").then(async fluvioWasm => { | ||
var Fluvio = fluvioWasm.Fluvio; | ||
var Offset = fluvioWasm.Offset; | ||
const fluvio = await Fluvio.connect("ws://localhost:3000") | ||
const producer = await fluvio.topicProducer("foobar"); | ||
await producer.send("", `count`); | ||
while (true) { | ||
try { | ||
const fluvio = await Fluvio.connect("ws://localhost:3000") | ||
const producer = await fluvio.topicProducer("foobar"); | ||
await producer.send("", `count`); | ||
|
||
const consumer = await fluvio.partitionConsumer("foobar", 0); | ||
let stream = await consumer.stream(Offset.fromEnd(10)) | ||
const consumer = await fluvio.partitionConsumer("foobar", 0); | ||
let stream = await consumer.stream(Offset.fromEnd(1)) | ||
const userAgent = navigator.userAgent; | ||
|
||
let count = 0; | ||
let before = new Date(); | ||
while (count < 10) { | ||
let count = 0; | ||
let before = new Date(); | ||
while (count < 10000) { | ||
|
||
await producer.send("", `count-${count}`); | ||
let next = await stream.next(); | ||
console.log(`${next.keyString()} - ${next.valueString()}`); | ||
count++; | ||
try { | ||
await producer.send("", `${count}-${userAgent}`); | ||
let next = await stream.next(); | ||
let text = `${next.valueString()}`; | ||
console.log(text); | ||
document.body.innerHTML = | ||
`<div>${text}</div>` + | ||
document.body.innerHTML; | ||
count++; | ||
} catch (e) { | ||
console.error(e); | ||
console.error(e.message); | ||
console.error(e.stack); | ||
let text = `${e} - ${userAgent}`; | ||
document.body.innerHTML = | ||
`<div>${text}</div>` + | ||
document.body.innerHTML; | ||
break; | ||
} | ||
await sleep(50); | ||
} | ||
let after = new Date(); | ||
console.log(`The recieved ${count} in took ${after - before} ms`); | ||
} catch (e) { | ||
console.error(e); | ||
console.error(e.message); | ||
console.error(e.stack); | ||
break; | ||
} | ||
await sleep(5000); | ||
} | ||
let after = new Date(); | ||
console.log(`The recieved ${count} in took ${after - before} ms`); | ||
}); | ||
|
||
const sleep = (milliseconds) => { | ||
return new Promise(resolve => setTimeout(resolve, milliseconds)) | ||
} |
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