forked from go-zeromq/zmq4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
65 lines (53 loc) · 1.34 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
// Copyright 2018 The go-zeromq Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package zmq4
import (
"time"
)
// Option configures some aspect of a ZeroMQ socket.
// (e.g. SocketIdentity, Security, ...)
type Option func(s *socket)
// WithID configures a ZeroMQ socket identity.
func WithID(id SocketIdentity) Option {
return func(s *socket) {
s.id = id
}
}
// WithSecurity configures a ZeroMQ socket to use the given security mechanism.
// If the security mechanims is nil, the NULL mechanism is used.
func WithSecurity(sec Security) Option {
return func(s *socket) {
s.sec = sec
}
}
// WithDialerRetry configures the time to wait before two failed attempts
// at dialing an endpoint.
func WithDialerRetry(retry time.Duration) Option {
return func(s *socket) {
s.retry = retry
}
}
// WithDialerTimeout sets the maximum amount of time a dial will wait
// for a connect to complete.
func WithDialerTimeout(timeout time.Duration) Option {
return func(s *socket) {
s.dialer.Timeout = timeout
}
}
/*
// TODO(sbinet)
func WithIOThreads(threads int) Option {
return nil
}
func WithSendBufferSize(size int) Option {
return nil
}
func WithRecvBufferSize(size int) Option {
return nil
}
*/
const (
OptionSubscribe = "SUBSCRIBE"
OptionUnsubscribe = "UNSUBSCRIBE"
)