github.com/cilium/cilium@v1.16.2/pkg/hubble/peer/serviceoption/option.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright Authors of Cilium 3 4 package serviceoption 5 6 // Options stores all the configuration values for the peer service. 7 type Options struct { 8 MaxSendBufferSize int 9 WithoutTLSInfo bool 10 AddressFamilyPreference AddressFamilyPreference 11 HubblePort int 12 } 13 14 // Option customizes the peer service's configuration. 15 type Option func(o *Options) 16 17 type AddressFamily uint 18 19 const ( 20 AddressFamilyIPv4 AddressFamily = 4 21 AddressFamilyIPv6 AddressFamily = 6 22 ) 23 24 type AddressFamilyPreference []AddressFamily 25 26 var ( 27 AddressPreferIPv4 = AddressFamilyPreference{AddressFamilyIPv4, AddressFamilyIPv6} 28 AddressPreferIPv6 = AddressFamilyPreference{AddressFamilyIPv6, AddressFamilyIPv4} 29 ) 30 31 // WithMaxSendBufferSize sets the maximum size of the send buffer. When the 32 // send buffer is full, for example due to errors in the transport, the server 33 // disconnects the corresponding client. 34 // The maximum buffer size should be large enough to accommodate the burst of 35 // peer change notifications than happens on an initial call where all nodes in 36 // the cluster are notified as being added. 37 func WithMaxSendBufferSize(size int) Option { 38 return func(o *Options) { 39 o.MaxSendBufferSize = size 40 } 41 } 42 43 // WithoutTLSInfo configures the service to send peer change notifications 44 // without TLS information. This implies that TLS is disabled for the Hubble 45 // gRPC service. 46 func WithoutTLSInfo() Option { 47 return func(o *Options) { 48 o.WithoutTLSInfo = true 49 } 50 } 51 52 // WithAddressFamilyPreference configures the order in which IP addresses 53 // will be considered when sending notifications for nodes that have both IPv4 54 // and IPv6 available. 55 func WithAddressFamilyPreference(pref AddressFamilyPreference) Option { 56 return func(o *Options) { 57 o.AddressFamilyPreference = pref 58 } 59 } 60 61 // WithHubblePort configures port used in the address field of change notifications. 62 func WithHubblePort(port int) Option { 63 return func(o *Options) { 64 o.HubblePort = port 65 } 66 }