github.com/gdamore/mangos@v1.4.0/options.go (about) 1 // Copyright 2016 The Mangos Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use file except in compliance with the License. 5 // You may obtain a copy of the license at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package mangos 16 17 // The following are Options used by SetOption, GetOption. 18 19 const ( 20 // OptionRaw is used to enable RAW mode processing. The details of 21 // how this varies from normal mode vary from protocol to protocol. 22 // RAW mode corresponds to AF_SP_RAW in the C variant, and must be 23 // used with Devices. In particular, RAW mode sockets are completely 24 // stateless -- any state between recv/send messages is included in 25 // the message headers. Protocol names starting with "X" default 26 // to the RAW mode of the same protocol without the leading "X". 27 // The value passed is a bool. 28 OptionRaw = "RAW" 29 30 // OptionRecvDeadline is the time until the next Recv times out. The 31 // value is a time.Duration. Zero value may be passed to indicate that 32 // no timeout should be applied. A negative value indicates a 33 // non-blocking operation. By default there is no timeout. 34 OptionRecvDeadline = "RECV-DEADLINE" 35 36 // OptionSendDeadline is the time until the next Send times out. The 37 // value is a time.Duration. Zero value may be passed to indicate that 38 // no timeout should be applied. A negative value indicates a 39 // non-blocking operation. By default there is no timeout. 40 OptionSendDeadline = "SEND-DEADLINE" 41 42 // OptionRetryTime is used by REQ. The argument is a time.Duration. 43 // When a request has not been replied to within the given duration, 44 // the request will automatically be resent to an available peer. 45 // This value should be longer than the maximum possible processing 46 // and transport time. The value zero indicates that no automatic 47 // retries should be sent. The default value is one minute. 48 // 49 // Note that changing this option is only guaranteed to affect requests 50 // sent after the option is set. Changing the value while a request 51 // is outstanding may not have the desired effect. 52 OptionRetryTime = "RETRY-TIME" 53 54 // OptionSubscribe is used by SUB/XSUB. The argument is a []byte. 55 // The application will receive messages that start with this prefix. 56 // Multiple subscriptions may be in effect on a given socket. The 57 // application will not receive messages that do not match any current 58 // subscriptions. (If there are no subscriptions for a SUB/XSUB 59 // socket, then the application will not receive any messages. An 60 // empty prefix can be used to subscribe to all messages.) 61 OptionSubscribe = "SUBSCRIBE" 62 63 // OptionUnsubscribe is used by SUB/XSUB. The argument is a []byte, 64 // representing a previously established subscription, which will be 65 // removed from the socket. 66 OptionUnsubscribe = "UNSUBSCRIBE" 67 68 // OptionSurveyTime is used to indicate the deadline for survey 69 // responses, when used with a SURVEYOR socket. Messages arriving 70 // after this will be discarded. Additionally, this will set the 71 // OptionRecvDeadline when starting the survey, so that attempts to 72 // receive messages fail with ErrRecvTimeout when the survey is 73 // concluded. The value is a time.Duration. Zero can be passed to 74 // indicate an infinite time. Default is 1 second. 75 OptionSurveyTime = "SURVEY-TIME" 76 77 // OptionTLSConfig is used to supply TLS configuration details. It 78 // can be set using the ListenOptions or DialOptions. 79 // The parameter is a tls.Config pointer. 80 OptionTLSConfig = "TLS-CONFIG" 81 82 // OptionWriteQLen is used to set the size, in messages, of the write 83 // queue channel. By default, it's 128. This option cannot be set if 84 // Dial or Listen has been called on the socket. 85 OptionWriteQLen = "WRITEQ-LEN" 86 87 // OptionReadQLen is used to set the size, in messages, of the read 88 // queue channel. By default, it's 128. This option cannot be set if 89 // Dial or Listen has been called on the socket. 90 OptionReadQLen = "READQ-LEN" 91 92 // OptionKeepAlive is used to set TCP KeepAlive. Value is a boolean. 93 // Default is true. 94 OptionKeepAlive = "KEEPALIVE" 95 96 // OptionNoDelay is used to configure Nagle -- when true messages are 97 // sent as soon as possible, otherwise some buffering may occur. 98 // Value is a boolean. Default is true. 99 OptionNoDelay = "NO-DELAY" 100 101 // OptionLinger is used to set the linger property. This is the amount 102 // of time to wait for send queues to drain when Close() is called. 103 // Close() may block for up to this long if there is unsent data, but 104 // will return as soon as all data is delivered to the transport. 105 // Value is a time.Duration. Default is one second. 106 OptionLinger = "LINGER" 107 108 // OptionTTL is used to set the maximum time-to-live for messages. 109 // Note that not all protocols can honor this at this time, but for 110 // those that do, if a message traverses more than this many devices, 111 // it will be dropped. This is used to provide protection against 112 // loops in the topology. The default is protocol specific. 113 OptionTTL = "TTL" 114 115 // OptionMaxRecvSize supplies the maximum receive size for inbound 116 // messages. This option exists because the wire protocol allows 117 // the sender to specify the size of the incoming message, and 118 // if the size were overly large, a bad remote actor could perform a 119 // remote Denial-Of-Service by requesting ridiculously large message 120 // sizes and then stalling on send. The default value is 1MB. 121 // 122 // A value of 0 removes the limit, but should not be used unless 123 // absolutely sure that the peer is trustworthy. 124 // 125 // Not all transports honor this lmit. For example, this limit 126 // makes no sense when used with inproc. 127 // 128 // Note that the size includes any Protocol specific header. It is 129 // better to pick a value that is a little too big, than too small. 130 // 131 // This option is only intended to prevent gross abuse of the system, 132 // and not a substitute for proper application message verification. 133 OptionMaxRecvSize = "MAX-RCV-SIZE" 134 135 // OptionReconnectTime is the initial interval used for connection 136 // attempts. If a connection attempt does not succeed, then ths socket 137 // will wait this long before trying again. An optional exponential 138 // backoff may cause this value to grow. See OptionMaxReconnectTime 139 // for more details. This is a time.Duration whose default value is 140 // 100msec. This option must be set before starting any dialers. 141 OptionReconnectTime = "RECONNECT-TIME" 142 143 // OptionMaxReconnectTime is the maximum value of the time between 144 // connection attempts, when an exponential backoff is used. If this 145 // value is zero, then exponential backoff is disabled, otherwise 146 // the value to wait between attempts is doubled until it hits this 147 // limit. This value is a time.Duration, with initial value 0. 148 // This option must be set before starting any dialers. 149 OptionMaxReconnectTime = "MAX-RECONNECT-TIME" 150 151 // OptionBestEffort enables non-blocking send operations on the 152 // socket. Normally (for some socket types), a socket will block if 153 // there are no receivers, or the receivers are unable to keep up 154 // with the sender. (Multicast sockets types like Bus or Star do not 155 // behave this way.) If this option is set, instead of blocking, the 156 // message will be silently discarded. The value is a boolean, and 157 // defaults to False. 158 OptionBestEffort = "BEST-EFFORT" 159 )