tools

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2020 License: Apache-2.0 Imports: 23 Imported by: 29

Documentation

Index

Constants

View Source
const (
	// InsecureEnv environment variable, if "true" NSM will work in insecure mode
	InsecureEnv = "INSECURE"
)
View Source
const (

	// MaxSymLink is maximum length of Symbolic Link
	MaxSymLink = 8192
)

Variables

This section is empty.

Functions

func DialContext

func DialContext(ctx context.Context, addr net.Addr, opts ...grpc.DialOption) (*grpc.ClientConn, error)

DialContext allows to call DialContext using net.Addr

func DialContextTCP

func DialContextTCP(ctx context.Context, address string, opts ...grpc.DialOption) (*grpc.ClientConn, error)

DialContextTCP establish TCP connection with address

func DialContextUnix

func DialContextUnix(ctx context.Context, path string, opts ...grpc.DialOption) (*grpc.ClientConn, error)

DialContextUnix establish connection with passed unix socket

func DialTCP

func DialTCP(address string, opts ...grpc.DialOption) (*grpc.ClientConn, error)

DialTCP establish TCP connection with address and set default timeout

func DialTCPInsecure

func DialTCPInsecure(address string, opts ...grpc.DialOption) (*grpc.ClientConn, error)

DialTCPInsecure establish TCP connection with address in insecure mode and set default timeout

func DialUnix

func DialUnix(path string, opts ...grpc.DialOption) (*grpc.ClientConn, error)

DialUnix establish connection with passed unix socket and set default timeout

func DialUnixInsecure

func DialUnixInsecure(path string, opts ...grpc.DialOption) (*grpc.ClientConn, error)

DialUnixInsecure establish connection with passed unix socket in insecure mode and set default timeout

func GetCurrentNS

func GetCurrentNS() (string, error)

GetCurrentNS discovers the namespace of a running process and returns in a string.

func GetCurrentPodNameFromHostname

func GetCurrentPodNameFromHostname() (string, error)

GetCurrentPodNameFromHostname returns pod name a container is running in Note: Pod name is read from `/etc/hostname`. The same approach is used in kubelet implementation. There is risk that host name may be overwritten and in that case this should be considered when referring to pod name

func InitConfig

func InitConfig(c DialConfig)

InitConfig allows init global DialConfig, should be called before any GetConfig(), otherwise do nothing

func IsInsecure

func IsInsecure() (bool, error)

IsInsecure checks environment variable INSECURE

func NewAddr

func NewAddr(network, addr string) net.Addr

NewAddr returns new net.Addr with network and address

func NewOSSignalChannel

func NewOSSignalChannel() chan os.Signal

func NewServer

func NewServer(ctx context.Context, opts ...grpc.ServerOption) *grpc.Server

NewServer checks DialConfig and calls grpc.NewServer with certain grpc.ServerOption

func NewServerInsecure

func NewServerInsecure(opts ...grpc.ServerOption) *grpc.Server

func OpenTracingDialOptions

func OpenTracingDialOptions() []grpc.DialOption

OpenTracingDialOptions returns array of grpc.DialOption that should be passed to grpc.Dial to enable opentracing

func ParseKVStringToMap

func ParseKVStringToMap(input, sep, kvsep string) map[string]string

ParseKVStringToMap parses the input string

func ReadEnvBool

func ReadEnvBool(env string, value bool) (bool, error)

ReadEnvBool reads environment variable and treat it as bool

func SocketCleanup

func SocketCleanup(listenEndpoint string) error

SocketCleanup check for the presence of a stale socket and if it finds it, removes it.

func WaitForPortAvailable

func WaitForPortAvailable(ctx context.Context, protoType, registryAddress string, idleSleep time.Duration) error

WaitForPortAvailable waits while the port will is available. Throws exception if the context is done.

Types

type DialConfig

type DialConfig struct {
	OpenTracing      bool
	SecurityProvider security.Provider
}

DialConfig represents configuration of grpc connection, one per instance

func GetConfig

func GetConfig() DialConfig

GetConfig returns instance of DialConfig

type NSUrl

type NSUrl struct {
	NsName string
	Intf   string
	Params url.Values
}

func ParseAnnotationValue

func ParseAnnotationValue(value string) ([]*NSUrl, error)

type SocketPath

type SocketPath string

Unix socket file path.

func (SocketPath) Network

func (socket SocketPath) Network() string

func (SocketPath) String

func (socket SocketPath) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL