/********************************
 *
 * 作者:吴隆健
 * 创建时间: 2019/6/24 13:47:34
 * 
 ********************************/
#if RABBITMQ
using System;

namespace MrWu.RabbitMQ {
    /// <summary>
    /// Rabbit配置
    /// </summary>
    public class RabbitConfig {

        /// <summary>
        /// 用户名
        /// </summary>
        public string username;
        /// <summary>
        /// 密码
        /// </summary>
        public string password;

        /// <summary>
        /// 虚拟主机
        /// </summary>
        public string vhost;

        /// <summary>
        /// ip
        /// </summary>
        public string host = "127.0.0.1";

        /// <summary>
        /// 端口
        /// </summary>
        public int port = 5672;

        /// <summary>
        /// 交换机
        /// </summary>
        public ExchangeInfo[] exchanges;

        /// <summary>
        /// 队列
        /// </summary>
        public QueueInfo[] queues;

        /// <summary>
        /// 绑定信息
        /// </summary>
        public BindInfo[] binds;

        /// <summary>
        /// 是否异步确认模式
        /// </summary>
        public bool AsynConfirm = true;

        /// <summary>
        /// 构造器
        /// </summary>
        public RabbitConfig() { }

    }

    /// <summary>
    /// 交换机
    /// </summary>
    public class ExchangeInfo {
        /// <summary>
        /// 交换机名称
        /// </summary>
        public string name = string.Empty;

        /// <summary>
        /// 类型
        /// </summary>
        public string type = "direct";

        /// <summary>
        /// 持久化
        /// </summary>
        public bool durable = true;

        /// <summary>
        /// 自动删除
        /// </summary>
        public bool autodelete = false;

        /// <summary>
        /// 备用交换机 当消息无法路由是,投递到的备用交换机
        /// </summary>
        public string alternate_exchange = null;

        /// <summary>
        /// 如果存在则先删除再声明
        /// </summary>
        public bool delExists = false; 

        /// <summary>
        /// 构造器
        /// </summary>
        public ExchangeInfo() { }
    }

    /// <summary>
    /// 队列信息
    /// </summary>
    public class QueueInfo {
        /// <summary>
        /// 队列名称
        /// </summary>
        public string name;

        /// <summary>
        /// 持久化
        /// </summary>
        public bool durable = false;

        /// <summary>
        /// 独占
        /// </summary>
        public bool exclusive = false;

        /// <summary>
        /// 自动删除
        /// </summary>
        public bool autodelete = false;

        /// <summary>
        /// 启动时清空队列
        /// </summary>
        public bool startClear = false;

        /// <summary>
        /// 如果存在则先删除
        /// </summary>
        public bool delExists = false;

        /// <summary>
        /// 消息过期时间
        /// </summary>
        public int x_message_ttl = 0;

        /// <summary>
        /// 在指定的时间内没有消费者链接就会删除队列
        /// </summary>
        public int x_expires = 0;

        /// <summary>
        /// 消最大就绪的条目数
        /// </summary>
        public int x_max_length = 0;

        /// <summary>
        /// 消息最大的就绪内容大小
        /// </summary>
        public int x_max_length_bytes = 0;

        /// <summary>
        /// 当消息溢出时，删除头部消息(drop-head)/拒绝消息(reject-publish)
        /// </summary>
        public string x_overflow = null;

        /// <summary>
        /// 当消息被丢弃时，丢弃到哪个交换机中 与 x-dead-touting-key 一起使用
        /// </summary>
        public string x_dead_letter_exchange = null;

        /// <summary>
        /// 当消息被丢弃时，投递到交换机中使用的路由键
        /// </summary>
        public string x_dead_routing_key = null;

        /// <summary>
        /// 队列 优先级
        /// </summary>
        public int x_max_priority = 0;

        /// <summary>
        /// 队列模式 default / lazy . lazy 表示消息存储在磁盘中，当消费者需要的时候才加载到内存中,当消息大量积累的情况应该启用
        /// </summary>
        public string x_queue_mode = null;
    }

    /// <summary>
    /// 绑定信息
    /// </summary>
    public class BindInfo {
        /// <summary>
        /// 绑定类型 queue / exchange
        /// </summary>
        public string bindType = "queue";

        /// <summary>
        /// 目标
        /// </summary>
        public string destination;

        /// <summary>
        /// 源
        /// </summary>
        public string source;

        /// <summary>
        /// 路由键
        /// </summary>
        public string routingkey;
    }

}
#endif