Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.

Init AMQP k6 plugin #1

Merged
merged 19 commits into from
Jul 29, 2021
Merged

Init AMQP k6 plugin #1

merged 19 commits into from
Jul 29, 2021

Conversation

lxkuz
Copy link
Collaborator

@lxkuz lxkuz commented Jul 14, 2021

Initial AMQP functionality including:

  • Open connection
  • Declare queue
  • Bind/unbind queue to exchange
  • Inspect queue
  • Delete queue
  • Declare exchange
  • Delete exchange
  • Bind/unbind exchange to another exchange
  • Publish/listen message into the queue
  • Purge queue

@lxkuz lxkuz requested a review from simskij July 14, 2021 15:43
@lxkuz lxkuz changed the title [WIP] Init AMQP k6 plugin Init AMQP k6 plugin Jul 21, 2021
Copy link

@simskij simskij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor feedback items. All in all; looks good. 👏🏽

README.md Outdated
@@ -2,7 +2,7 @@
>
> As this is a proof of concept, it won't be supported by the k6 team.
> It may also break in the future as xk6 evolves. USE AT YOUR OWN RISK!
> Any issues with the tool should be raised [here](https://github.com/lxkuz/xk6-amqp/issues).
> Any issues with the tool should be raised [here](https://github.com/k6io/xk6-amqp/issues).
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> Any issues with the tool should be raised [here](https://github.com/k6io/xk6-amqp/issues).
> Any issues with the tool should be raised [here](https://github.com/grafana/xk6-amqp/issues).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simskij does it mean I should use github.com/grafana instead of github.com/k6io everywhere?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, correct

README.md Outdated
@@ -30,7 +30,7 @@ Then:

2. Build the binary:
```bash
$ xk6 build --with github.com/lxkuz/xk6-amqp@latest
$ xk6 build --with github.com/k6io/xk6-amqp@latest
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$ xk6 build --with github.com/k6io/xk6-amqp@latest
$ xk6 build --with github.com/grafana/xk6-amqp@latest

amqp.go Outdated
Comment on lines 117 to 118
modules.Register("k6/x/amqp/queues", &queues)
modules.Register("k6/x/amqp/exchanges", &exchanges)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
modules.Register("k6/x/amqp/queues", &queues)
modules.Register("k6/x/amqp/exchanges", &exchanges)
modules.Register("k6/x/amqp/queue", &queues)
modules.Register("k6/x/amqp/exchange", &exchanges)

Use singularis throughout unless the pluralization adds semantic value.

exchanges.go Outdated
ConnectionUrl string
}

type EchangeDeclareOptions struct {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type EchangeDeclareOptions struct {
type ExchangeDeclareOptions struct {

@lxkuz lxkuz requested a review from simskij July 21, 2021 14:00
@lxkuz
Copy link
Collaborator Author

lxkuz commented Jul 21, 2021

@simskij review comments handled

README.md Outdated
Comment on lines 60 to 67
Queues.declare({
name: queueName,
// durable: false,
// delete_when_unused: false,
// exclusive: false,
// no_wait: false,
// args: null
})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Singular form of Queue

queues.go Outdated
Comment on lines 1 to 116
Name string
Durable bool
DeleteWhenUnused bool
Exclusive bool
NoWait bool
Args amqpDriver.Table
}

type QueueBindOptions struct {
QueueName string
ExchangeName string
RoutingKey string
NoWait bool
Args amqpDriver.Table
}

type QueueUnindOptions struct {
QueueName string
ExchangeName string
RoutingKey string
Args amqpDriver.Table
}

func (queues *Queues) Declare(options DeclareOptions) (amqpDriver.Queue, error) {
ch, err := queues.Connection.Channel()
if err != nil {
return amqpDriver.Queue{}, err
}
defer ch.Close()
return ch.QueueDeclare(
options.Name,
options.Durable,
options.DeleteWhenUnused,
options.Exclusive,
options.NoWait,
options.Args,
)
}

func (queues *Queues) Inspect(name string) (amqpDriver.Queue, error) {
ch, err := queues.Connection.Channel()
if err != nil {
return amqpDriver.Queue{}, err
}
defer ch.Close()
return ch.QueueInspect(name)
}

func (queues *Queues) Delete(name string) error {
ch, err := queues.Connection.Channel()
if err != nil {
return err
}
defer ch.Close()
_, err = ch.QueueDelete(
name,
false, // ifUnused
false, // ifEmpty
false, // noWait
)
return err
}

func (queues *Queues) Bind(options QueueBindOptions) error {
ch, err := queues.Connection.Channel()
if err != nil {
return err
}
defer ch.Close()
return ch.QueueBind(
options.QueueName,
options.RoutingKey,
options.ExchangeName,
options.NoWait,
options.Args,
)
}

func (queues *Queues) Unbind(options QueueUnindOptions) error {
ch, err := queues.Connection.Channel()
if err != nil {
return err
}
defer ch.Close()
return ch.QueueUnbind(
options.QueueName,
options.RoutingKey,
options.ExchangeName,
options.Args,
)
}

func (queues *Queues) Purge(name string, noWait bool) (int, error) {
ch, err := queues.Connection.Channel()
if err != nil {
return 0, err
}
defer ch.Close()
return ch.QueuePurge(name, noWait)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Singular form of Queue

@@ -0,0 +1,100 @@
package amqp
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Singular form of Exchange

@lxkuz lxkuz requested a review from simskij July 23, 2021 13:14
@lxkuz lxkuz merged commit f4800db into main Jul 29, 2021
javaducky pushed a commit that referenced this pull request Nov 9, 2022
…ck-cypher

Feature/add messagepack cypher
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants