Files
zmq/options.go
zeekayandHanzo Dev cde37cf581 Go 1.27.1, and the code it can say more simply
Modules declare go 1.27.1 and the build images follow. go fix applied the
modernizers; omitzero is not applied, since it changes what the JSON says.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-16 19:37:50 -07:00

71 lines
1.5 KiB
Go

// Copyright 2025 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 a ZeroMQ socket - ONE way to configure
type Option func(s *socket)
// WithID sets socket identity
func WithID(id SocketIdentity) Option {
return func(s *socket) {
s.id = id
}
}
// WithSecurity sets security mechanism (default: NULL)
func WithSecurity(sec Security) Option {
return func(s *socket) {
if sec == nil {
sec = nullSecurity{}
}
s.sec = sec
}
}
// WithTimeout sets socket timeout
func WithTimeout(timeout time.Duration) Option {
return func(s *socket) {
s.timeout = timeout
}
}
// WithLogger is a no-op for compatibility
func WithLogger(logger any) Option {
return func(s *socket) {}
}
// WithDialerRetry is a no-op for compatibility
func WithDialerRetry(retry time.Duration) Option {
return func(s *socket) {
s.retry = retry
}
}
// WithDialerMaxRetries is a no-op for compatibility
func WithDialerMaxRetries(maxRetries int) Option {
return func(s *socket) {
s.maxRetries = maxRetries
}
}
// WithAutomaticReconnect is a no-op for compatibility
func WithAutomaticReconnect(auto bool) Option {
return func(s *socket) {
s.autoReconnect = auto
}
}
// Socket option constants - only essential ones
const (
OptionSubscribe = "SUBSCRIBE"
OptionUnsubscribe = "UNSUBSCRIBE"
OptionHWM = "HWM"
OptionIdentity = "IDENTITY"
)