utopia_queue

Creator: coderz1093

Last updated:

0 purchases

utopia_queue Image
utopia_queue Images

Languages

Categories

Add to Cart

Description:

utopia queue

Utopia Queue #
Utopia queue is a powerful queue library. It is designed to be simple and easy to learn and use. It is built on top of redis.
It is super helpful to build background workers to handle long running tasks. For example in your API server, you can use a emails queue to handle sending emails in the background.
Usage #
In main.dart, you can start a server as the following.
import 'package:utopia_queue/utopia_queue.dart';

void main(List<String> arguments) async {
final connection = await ConnectionRedis.init('localhost', 6379);
final Server server = Server(connection, queue: 'myqueue');

server.job().inject('message').action((Message message) {
print(message.toMap());
// Do something with the message
});
server.start();
}

copied to clipboard
To send a message to the queue, use the following code.
import 'dart:io';
import 'dart:math';

import 'package:utopia_queue/utopia_queue.dart';

void sendMessage() async {
final connection = await ConnectionRedis.init('localhost', 6379);
final client = Client(connection, queue: 'myqueue');
await client
.enqueue({'user': Random().nextInt(20), 'name': 'Damodar Lohani'});
print('enqueued');
}
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.