Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: Add type-safe queues #50

Closed
mikestefanello opened this issue Jun 18, 2024 · 1 comment
Closed

Idea: Add type-safe queues #50

mikestefanello opened this issue Jun 18, 2024 · 1 comment

Comments

@mikestefanello
Copy link

One thing in particular that I've found to be a little annoying to deal with is the lack of type-safety. You can put any byte slice in to jobs.Create() or Send() which means potential run-time errors and no IDE support. You also have to manually deal with serialization on both the caller and receiver side for every single queue. I had the same issue with asynq.

Adding type-safety is possible. I put together a very basic POC that I believe will work. Each queue would have to be declared with the type you intend to receive and process.

Is this something you would be interested in? If not, since it's a rather large refactor, I completely understand.

@markuswustenberg
Copy link
Member

I thought about this when designing the queue, and I ended up using a byte slice because I couldn't figure out beforehand how people would use this. It's always possible to delegate much of the (de)serialization to helpers.

But I think it could be interesting to explore this from an approach of not changing the existing implementation, but instead adding it on top, like a TypedQueue or something like that, with essentially the same interface. Then people would be free to choose from the low-level interface or the higher-level generics version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants