squeue is a Golang library designed to facilitate interactions with Amazon SQS queues, providing 100% type-safety powered by Golang generics.
squeue abstracts the internal driver implementation through its interface, allowing for seamless integration of various drivers to suit different development environments and needs.
Currently implemented drivers:
- In-Memory
- Amazon SQS
You can easily deploy the Amazon SQS driver in any staging or production environment and use the In-Memory driver for lightweight testing.
The library uses an opinionated JSON format for serializing and deserializing messages. To achieve 100% type safety, simply provide a message type that implements the Golang json.Marshaler
and json.Unmarshaler
interfaces. This way, you maintain direct control over the raw data serialization and deserialization.
Consuming messages is straightforward—just loop through a channel of messages:
messages, _ := sub.Consume(ctx, "queue")
for m := range messages {
go func(message squeue.Message[*my.Message]) {
// Do your magic...
}(m)
}
Examples
For more detailed documentation, please refer to the internal/examples/
directory.
In-Memory Driver
go run internal/examples/memory/main.go
Amazon SQS Driver
go run internal/examples/sqs/consumer/consumer.go
# Open another shell
go run internal/examples/sqs/producer/producer.go