package com.apobates.forum.event.elderly.redis;

import com.github.davidmarquis.redisq.RedisMessageQueue;
import com.github.davidmarquis.redisq.persistence.RedisOps;
import com.github.davidmarquis.redisq.producer.DefaultMessageProducer;
import java.io.Serializable;
import java.util.function.Consumer;

public interface RedisEvent<T> extends Serializable {

    default Consumer<RedisMessageQueue> use(final RedisOps redisOps){
        return (RedisMessageQueue queue)->{
            DefaultMessageProducer<T> dmq = new com.github.davidmarquis.redisq.producer.DefaultMessageProducer<>();
            dmq.setQueue(queue);
            dmq.setRedisOps(redisOps);
            dmq.create((T) this).submit();
        };
    }
}
