Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
691b7eb
chore: wip
peter-svensson Feb 2, 2024
88e6e76
chore: wip
peter-svensson Feb 5, 2024
74c7485
chore: wip
peter-svensson Feb 5, 2024
f075555
chore: wip
peter-svensson Feb 5, 2024
d8703e5
chore: refactor
peter-svensson Feb 5, 2024
83f565f
chore: wip
peter-svensson Feb 5, 2024
ca20e64
chore: wip
peter-svensson Feb 5, 2024
a28e719
chore: wip
peter-svensson Feb 5, 2024
37552de
chore: wip, integration test
peter-svensson Feb 5, 2024
74b12a8
chore: integration test
peter-svensson Feb 5, 2024
0f2e848
chore: handler for type mapping
peter-svensson Feb 6, 2024
19e6674
chore: handler
peter-svensson Feb 6, 2024
0db2fd0
chore: renaming event funcs and add spans and metrics
peter-svensson Feb 7, 2024
b61dfe4
chore: remove publishable event
peter-svensson Feb 7, 2024
55c6b22
chore: remove comment about multiple channels
peter-svensson Feb 7, 2024
2ac1bd4
chore: remove redundant code
peter-svensson Feb 9, 2024
29b462f
chore: remove method from connection
peter-svensson Feb 9, 2024
c1f6457
chore: naming
peter-svensson Feb 9, 2024
254abdd
chore: moved funcs
peter-svensson Feb 9, 2024
155e191
chore: moved publish from connection
peter-svensson Feb 9, 2024
7d85c02
chore: move around tests
peter-svensson Feb 9, 2024
edf5b55
chore: tests
peter-svensson Feb 9, 2024
364eff7
chore: amqp url for integration tests
peter-svensson Feb 9, 2024
ab3c75f
chore: license headers
peter-svensson Feb 9, 2024
b6bd3e6
chore: expose admin port
peter-svensson Feb 9, 2024
0fc5638
chore: correct error returned on failure to parse JSON
peter-svensson Feb 10, 2024
e896afe
chore: test pre-commit
peter-svensson Feb 10, 2024
d512894
chore: tests
peter-svensson Feb 10, 2024
2b95a8c
chore: more tests
peter-svensson Feb 11, 2024
0c8df6f
chore: test metrics
peter-svensson Feb 13, 2024
93303ab
chore: updated some docs
peter-svensson Feb 13, 2024
e67b596
chore: naming for anonymous functions changed
peter-svensson Feb 13, 2024
664317f
chore: merged
peter-svensson Nov 20, 2024
9de95df
chore: split notification channels
peter-svensson Nov 20, 2024
47b058d
chore(doc): updated example docs
peter-svensson Nov 20, 2024
04ca5c0
chore: update integration test
peter-svensson Nov 20, 2024
108daa1
chore: fix integration test race condition
peter-svensson Nov 21, 2024
39f85a7
chore: updates
peter-svensson Nov 26, 2024
446c3c9
chore: cleanup
peter-svensson Nov 26, 2024
e4c5f26
chore: cleanup after rebase
peter-svensson Apr 11, 2025
fa20076
feat: update queue declaration and parameters
peter-svensson Apr 11, 2025
344dc68
refactor: rename QueueBindingConfig to ConsumerConfig
peter-svensson Apr 11, 2025
b5b2944
fix: update queue and exchange types to use constants
peter-svensson Apr 16, 2025
56c522a
chore: update Go version in go.mod to 1.23
peter-svensson Apr 16, 2025
37c345f
feat(mock): add Close method to MockAmqpChannel
peter-svensson Apr 16, 2025
e0fa366
fix: increase message TTL values in tests and consumer setup
peter-svensson Apr 16, 2025
3215cf7
refactor: standardize consumerConfig struct usage
peter-svensson Apr 16, 2025
98b7475
feat: integrate typemapper for improved type handling
peter-svensson Apr 17, 2025
e07eb56
feat: update publisher setup to simplify arguments
peter-svensson May 15, 2025
9ac31c0
chore: update copyright year to 2025 across files
peter-svensson Jun 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ jobs:
runs-on: ubuntu-latest
services:
rabbitmq:
image: rabbitmq
image: rabbitmq:management
env:
RABBITMQ_DEFAULT_USER: user
RABBITMQ_DEFAULT_PASS: password
ports:
- 5672:5672
- 15672:15672
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
Expand All @@ -27,7 +28,7 @@ jobs:
check-latest: true
- name: Tests
run: |
go test -p 1 -mod=readonly -race -v -tags integration -coverprofile=coverage.txt -covermode=atomic -coverpkg=$(go list ./... | tr '\n' , | sed 's/,$//') ./...
go test -p 1 -mod=readonly -race -v --tags=integration -coverprofile=coverage.txt -covermode=atomic -coverpkg=$(go list ./... | tr '\n' , | sed 's/,$//') ./...
go tool cover -func=coverage.txt
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.envrc
.idea
*.iml
.testCoverage.txt
Expand Down
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,19 @@ repos:
- id: go-test-mod
- id: go-fumpt
- id: golangci-lint-mod
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.4
hooks:
- id: insert-license
files: \.go$
args:
- --license-filepath
- LICENSE
- --comment-style
- //
- --use-current-year
- repo: https://github.com/sparetimecoders/pre-commit-check-signed
rev: v0.0.1
hooks:
- id: check-signed-commit
name: check-signed-commit
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 sparetimecoders
Copyright (c) 2025 sparetimecoders

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ rabbitmq-server:
--env RABBITMQ_DEFAULT_USER=user \
--env RABBITMQ_DEFAULT_PASS=password \
--env RABBITMQ_DEFAULT_VHOST=test \
--pull always rabbitmq:3-management
--pull always rabbitmq:4-management

.PHONY: stop-rabbitmq-server
stop-rabbitmq-server:
Expand Down
56 changes: 56 additions & 0 deletions channel.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// MIT License
//
// Copyright (c) 2025 sparetimecoders
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

package goamqp

import (
"context"
"io"

amqp "github.com/rabbitmq/amqp091-go"
)

// AmqpChannel wraps the amqp.Channel to allow for mocking
type AmqpChannel interface {
io.Closer
QueueBind(queue, key, exchange string, noWait bool, args amqp.Table) error
Consume(queue, consumer string, autoAck, exclusive, noLocal, noWait bool, args amqp.Table) (<-chan amqp.Delivery, error)
ExchangeDeclare(name, kind string, durable, autoDelete, internal, noWait bool, args amqp.Table) error
PublishWithContext(ctx context.Context, exchange, key string, mandatory, immediate bool, msg amqp.Publishing) error
QueueDeclare(name string, durable, autoDelete, exclusive, noWait bool, args amqp.Table) (amqp.Queue, error)
NotifyPublish(confirm chan amqp.Confirmation) chan amqp.Confirmation
NotifyClose(c chan *amqp.Error) chan *amqp.Error
Confirm(noWait bool) error
// Qos controls how many messages or how many bytes the server will try to keep on
// the network for queueConsumers before receiving delivery acks. The intent of Qos is
// to make sure the network buffers stay full between the server and client.
// If your consumer work time is reasonably consistent and not much greater
// than two times your network round trip time, you will see significant
// throughput improvements starting with a prefetch count of 2 or slightly
// greater as described by benchmarks on RabbitMQ.
//
// http://www.rabbitmq.com/blog/2012/04/25/rabbitmq-performance-measurements-part-2/
// The default prefetchCount is 20 (and global true) and can be overridden with WithPrefetchLimit
Qos(prefetchCount, prefetchSize int, global bool) error
}

var _ AmqpChannel = &amqp.Channel{}
Loading
Loading