1 /* 2 * hunt-amqp-client: AMQP Client Library for D Programming Language. Support for RabbitMQ and other AMQP Server. 3 * 4 * Copyright (C) 2018-2019 HuntLabs 5 * 6 * Website: https://www.huntlabs.net 7 * 8 * Licensed under the Apache-2.0 License. 9 * 10 */ 11 module hunt.amqp.client.AmqpSenderOptions; 12 13 //import hunt.codegen.annotations.DataObject; 14 //import hunt.core.json.JsonObject; 15 16 /** 17 * Configures the AMQP Receiver. 18 */ 19 //@DataObject(generateConverter = true) 20 class AmqpSenderOptions { 21 22 private string linkName; 23 private bool dynamic; 24 private bool autoDrained ;//= true; 25 26 this() { 27 autoDrained = true; 28 } 29 30 this(AmqpSenderOptions other) { 31 this(); 32 setDynamic(other.isDynamic()); 33 setLinkName(other.getLinkName()); 34 setAutoDrained(other.isAutoDrained()); 35 } 36 37 //public AmqpSenderOptions(JsonObject json) { 38 // super(); 39 // AmqpSenderOptionsConverter.fromJson(json, this); 40 //} 41 42 //public JsonObject toJson() { 43 // JsonObject json = new JsonObject(); 44 // AmqpSenderOptionsConverter.toJson(this, json); 45 // return json; 46 //} 47 48 public string getLinkName() { 49 return linkName; 50 } 51 52 public AmqpSenderOptions setLinkName(string linkName) { 53 this.linkName = linkName; 54 return this; 55 } 56 57 /** 58 * @return whether the receiver is using a dynamic address. 59 */ 60 public bool isDynamic() { 61 return dynamic; 62 } 63 64 /** 65 * Sets whether the link remote terminus to be used should indicate it is 66 * 'dynamic', requesting the peer names it with a dynamic address. 67 * <p> 68 * The address provided by the peer can then be inspected using the 69 * {@link AmqpSender#address()} method on the {@link AmqpSender} received once opened. 70 * 71 * @param dynamic true if the link should request a dynamic terminus address 72 * @return the options 73 */ 74 public AmqpSenderOptions setDynamic(bool dynamic) { 75 this.dynamic = dynamic; 76 return this; 77 } 78 79 /** 80 * Get whether the link will automatically be marked drained after the send queue drain handler fires in drain mode. 81 * 82 * @return whether the link will automatically be drained after the send queue drain handler fires in drain mode 83 * @see #setAutoDrained(bool) 84 */ 85 public bool isAutoDrained() { 86 return autoDrained; 87 } 88 89 /** 90 * Sets whether the link is automatically marked drained after the send queue drain handler callback 91 * returns if the receiving peer requested that credit be drained. 92 * <p> 93 * {@code true} by default. 94 * 95 * @param autoDrained whether the link will automatically be drained after the send queue drain handler fires in drain mode 96 * @return the options 97 */ 98 public AmqpSenderOptions setAutoDrained(bool autoDrained) { 99 this.autoDrained = autoDrained; 100 return this; 101 } 102 }