-
Notifications
You must be signed in to change notification settings - Fork 30
Use event loop #10
Comments
Hi, Stoykov I used the following script from eventloop branch with the latest version of go(v1.18.3) and k6(v0.33.0) and it worked. import { sleep } from "k6";
import Amqp from 'k6/x/amqp';
import Queue from 'k6/x/amqp/queue';
export default function() {
console.log("K6 amqp extension enabled, version: " + Amqp.version)
const url = "amqp://guest:guest@localhost:5672/"
Amqp.start({
connection_url: url
})
console.log("Connection opened: " + url)
const queueName = 'K6 general'
Queue.declare({
name: queueName,
// durable: false,
// delete_when_unused: false,
// exclusive: false,
// no_wait: false,
// args: null
})
console.log(queueName + " queue is ready")
var o;
var i = 0;
const listener = function(data) {
console.log(`received data by VU ${__VU}, ITER ${__ITER}: ${data} $i = ${i} `)
i++
}
o = Amqp.listen({
queue_name: queueName,
listener: listener,
auto_ack: true,
})
setTimeout(() => {
console.log("stopping", __VU, __ITER);
o.stop();
}, 7000)
var p = Amqp.publish({
queue_name: queueName,
body: "Ping from k6 vu: " + __VU + ", iter:" + __ITER,
})
p.then(() => {
console.log("then resolved")
sleep(2)
Amqp.publish({
queue_name: queueName,
body: "Second ping from k6 vu: " + __VU + ", iter:" + __ITER,
}).then(() => { console.log("second send resolved") })
}, (e) => {
console.log("reject" + e);
})
} |
@NivedithaUdatha are you confirming that the branch works? Because I already knew it works with that example ;). But the whole branch needs an upgrade and I kind of find the API not very javascripty - which is why it isn't just merged but this issue was opened. Thanks for the feedback though 🙇 |
I'm currently looking at upgrading to the latest Module API as well. |
Hello @javaducky @mstoykov ! Is there any chance we could see this branch merged into main? Thank you! |
Hi @joaovsc10, The branch at this point is way too old and needs to be redone. Also, as I mention in the original message, the API is not ... great. I would argue that the API should mostly be copied from some other JS ecosystem library if possible. But these are quite a lot of changes and both me and @javaducky have other, arguably more important in general, work that will have effects for more users. And there has been fairly little interest, given the lack of reported (or upvoted reports) of the obvious problems. Having said that, we will try to review and possibly merge any PRs that try to make this extension more stable and usable. Just likely not work on it directly for at least some more time, and I can't guarantee we will ever come back to it on its own. |
This extension does make asynchronous use of the runtime which leads to panics as shown in #6 .
In the past I did some changes to make it better but those were never commited as were either using unstable APIs or were quite bad.
The latest one uses an early version of what is currently the event loop in k6.
I would argue that the API likely need changes as well, but at least moving to using the event loop will stop the panics and make it usable.
The text was updated successfully, but these errors were encountered: