This repository has been archived by the owner on Feb 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
options.go
195 lines (169 loc) · 9.05 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
// Copyright 2018 The Mangos Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use file except in compliance with the License.
// You may obtain a copy of the license at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package mangos
// The following are Options used by SetOption, GetOption.
const (
// OptionRaw is used to test if the socket in RAW mod. The details of
// how this varies from normal mode vary from protocol to protocol,
// but RAW mode is generally minimal protocol processing, and
// stateless. RAW mode sockets are constructed with different
// protocol constructor. Raw mode is generally used with Device()
// or similar proxy configurations.
OptionRaw = "RAW"
// OptionRecvDeadline is the time until the next Recv times out. The
// value is a time.Duration. Zero value may be passed to indicate that
// no timeout should be applied. A negative value indicates a
// non-blocking operation. By default there is no timeout.
OptionRecvDeadline = "RECV-DEADLINE"
// OptionSendDeadline is the time until the next Send times out. The
// value is a time.Duration. Zero value may be passed to indicate that
// no timeout should be applied. A negative value indicates a
// non-blocking operation. By default there is no timeout.
OptionSendDeadline = "SEND-DEADLINE"
// OptionRetryTime is used by REQ. The argument is a time.Duration.
// When a request has not been replied to within the given duration,
// the request will automatically be resent to an available peer.
// This value should be longer than the maximum possible processing
// and transport time. The value zero indicates that no automatic
// retries should be sent. The default value is one minute.
//
// Note that changing this option is only guaranteed to affect requests
// sent after the option is set. Changing the value while a request
// is outstanding may not have the desired effect.
OptionRetryTime = "RETRY-TIME"
// OptionSubscribe is used by SUB/XSUB. The argument is a []byte.
// The application will receive messages that start with this prefix.
// Multiple subscriptions may be in effect on a given socket. The
// application will not receive messages that do not match any current
// subscriptions. (If there are no subscriptions for a SUB/XSUB
// socket, then the application will not receive any messages. An
// empty prefix can be used to subscribe to all messages.)
OptionSubscribe = "SUBSCRIBE"
// OptionUnsubscribe is used by SUB/XSUB. The argument is a []byte,
// representing a previously established subscription, which will be
// removed from the socket.
OptionUnsubscribe = "UNSUBSCRIBE"
// OptionSurveyTime is used to indicate the deadline for survey
// responses, when used with a SURVEYOR socket. Messages arriving
// after this will be discarded. Additionally, this will set the
// OptionRecvDeadline when starting the survey, so that attempts to
// receive messages fail with ErrRecvTimeout when the survey is
// concluded. The value is a time.Duration. Zero can be passed to
// indicate an infinite time. Default is 1 second.
OptionSurveyTime = "SURVEY-TIME"
// OptionTLSConfig is used to supply TLS configuration details. It
// can be set using the ListenOptions or DialOptions.
// The parameter is a tls.Config pointer.
OptionTLSConfig = "TLS-CONFIG"
// OptionWriteQLen is used to set the size, in messages, of the write
// queue channel. By default, it's 128. This option cannot be set if
// Dial or Listen has been called on the socket.
OptionWriteQLen = "WRITEQ-LEN"
// OptionReadQLen is used to set the size, in messages, of the read
// queue channel. By default, it's 128. This option cannot be set if
// Dial or Listen has been called on the socket.
OptionReadQLen = "READQ-LEN"
// OptionKeepAlive is used to set TCP KeepAlive. Value is a boolean.
// Default is true.
OptionKeepAlive = "KEEPALIVE"
// OptionKeepAliveTime is used to set TCP KeepAlive time in seconds.
// Value is a time.Duration. Default is OS dependent.
// Default is true.
OptionKeepAliveTime = "KEEPALIVETIME"
// OptionNoDelay is used to configure Nagle -- when true messages are
// sent as soon as possible, otherwise some buffering may occur.
// Value is a boolean. Default is true.
OptionNoDelay = "NO-DELAY"
// OptionLinger is used to set the linger property. This is the amount
// of time to wait for send queues to drain when Close() is called.
// Close() may block for up to this long if there is unsent data, but
// will return as soon as all data is delivered to the transport.
// Value is a time.Duration. Default is one second.
OptionLinger = "LINGER"
// OptionTTL is used to set the maximum time-to-live for messages.
// Note that not all protocols can honor this at this time, but for
// those that do, if a message traverses more than this many devices,
// it will be dropped. This is used to provide protection against
// loops in the topology. The default is protocol specific.
OptionTTL = "TTL"
// OptionMaxRecvSize supplies the maximum receive size for inbound
// messages. This option exists because the wire protocol allows
// the sender to specify the size of the incoming message, and
// if the size were overly large, a bad remote actor could perform a
// remote Denial-Of-Service by requesting ridiculously large message
// sizes and then stalling on send. The default value is 1MB.
//
// A value of 0 removes the limit, but should not be used unless
// absolutely sure that the peer is trustworthy.
//
// Not all transports honor this limit. For example, this limit
// makes no sense when used with inproc.
//
// Note that the size includes any Protocol specific header. It is
// better to pick a value that is a little too big, than too small.
//
// This option is only intended to prevent gross abuse of the system,
// and not a substitute for proper application message verification.
//
// This option is type int64.
OptionMaxRecvSize = "MAX-RCV-SIZE"
// OptionReconnectTime is the initial interval used for connection
// attempts. If a connection attempt does not succeed, then ths socket
// will wait this long before trying again. An optional exponential
// backoff may cause this value to grow. See OptionMaxReconnectTime
// for more details. This is a time.Duration whose default value is
// 100msec. This option must be set before starting any dialers.
OptionReconnectTime = "RECONNECT-TIME"
// OptionMaxReconnectTime is the maximum value of the time between
// connection attempts, when an exponential backoff is used. If this
// value is zero, then exponential backoff is disabled, otherwise
// the value to wait between attempts is doubled until it hits this
// limit. This value is a time.Duration, with initial value 0.
// This option must be set before starting any dialers.
OptionMaxReconnectTime = "MAX-RECONNECT-TIME"
// OptionBestEffort enables non-blocking send operations on the
// socket. Normally (for some socket types), a socket will block if
// there are no receivers, or the receivers are unable to keep up
// with the sender. (Multicast sockets types like Bus or Star do not
// behave this way.) If this option is set, instead of blocking, the
// message will be silently discarded. The value is a boolean, and
// defaults to False.
OptionBestEffort = "BEST-EFFORT"
// OptionLocalAddr expresses a local address. For dialers, this is
// the (often random) address that was locally bound. For listeners,
// it is usually the service address. The value is a net.Addr. This
// is generally a read-only value for pipes, though it might sometimes
// be available on dialers or listeners.
OptionLocalAddr = "LOCAL-ADDR"
// OptionRemoteAddr expresses a remote address. For dialers, this is
// the service address. For listeners, its the address of the far
// end dialer. The value is a net.Addr. It is generally read-only
// and available only on pipes and dialers.
OptionRemoteAddr = "REMOTE-ADDR"
// OptionTLSConnState is used to supply TLS connection details. The
// value is a tls.ConnectionState. It is only valid when TLS is used.
// This is available on pipes that are using TLS.
OptionTLSConnState = "TLS-STATE"
// OptionHTTPRequest conveys an *http.Request. This read-only option
// only exists for Pipes using websocket connections.
OptionHTTPRequest = "HTTP-REQUEST"
// OptionDialAsynch (used on a Dialer) causes the Dial() operation
// to run in the background. Further, the Dialer will always redial,
// even if the first attempt fails. (Normally dialing is performed
// synchronously, so that if the remote peer is unavailable at first
// the caller can learn of the error and handle or report it.
// Note that mangos v1 behavior is the same as if this option is
// set to true.
OptionDialAsynch = "DIAL-ASYNCH"
)