<?php
/**
 * for queue operation
 */
namespace app\common\util\QueueHelp;

use think\facade\Log;

class Queue{
	
    function __construct($config)
    {
		//暂时只支持redis一种，之后增加其它方式改为工厂模式
		$this->redisQueue 		= new RedisQueue($config);
    }
	
	
    public function push($queue, $obj, $type='redis')
    {
        $result =  $this->redisQueue->push($queue, $obj);
		log::info('[INFO] Queue model push to  '.$type.' '.json_encode($obj).' result:'.json_encode($result));
        return $result;
    }	
	
    public function queueSize($queue, $type='redis')
    {
        $result =  $this->redisQueue->queueSize($queue);
        log::info('[INFO] Queue size: '.$queue.' '.json_encode($result));
        return $result;
    }
	
    public function pull($queue, $type='redis')
    {
        $result =  $this->redisQueue->pull($queue);
		log::info('[INFO] Queue model pull data result:'.json_encode($result));
        return $result;
    }
}