Skip to content

Library to easily enqueue and consume messages from Amazon SQS, 100% type safe

License

Notifications You must be signed in to change notification settings

simodima/squeue

Repository files navigation

S-queue mascot

squeue is a Golang library designed to facilitate interactions with Amazon SQS queues, providing 100% type-safety powered by Golang generics.


codecov Go Report Card Go Reference

Key Features

Driver-based Implementation

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.

Type Safety

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.

Channel of Messages

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

About

Library to easily enqueue and consume messages from Amazon SQS, 100% type safe

Topics

Resources

License

Stars

Watchers

Forks

Languages