util

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: Apache-2.0 Imports: 25 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaulCmdTimeout = time.Minute // one minute by default

	GRPCHealthProbe = "/usr/local/bin/grpc_health_probe"
)
View Source
const (
	LogComponentField = "component"
)

Variables

This section is empty.

Functions

func ClientTLS

func ClientTLS(caCert, cert, key []byte, peerName string) (*tls.Config, error)

ClientTLS prepares the TLS configuration that can be used by a client while connecting to a server with given encoded certificate and private key. peerName must be provided when expecting the server to offer a certificate with that CommonName.

func Connect

func Connect(endpoint string, tlsConfig *tls.Config, dialOptions ...grpc.DialOption) (*grpc.ClientConn, error)

Connect is a helper function to initiate a grpc client connection to server running at endpoint using tlsConfig

func Execute

func Execute(binary string, args ...string) (string, error)

func ExecuteWithTimeout

func ExecuteWithTimeout(timeout time.Duration, binary string, args ...string) (string, error)

func GRPCServiceReadinessProbe

func GRPCServiceReadinessProbe(address string) bool

func GetURL

func GetURL(host string, port int) string

func IsSPDKTgtReady added in v1.5.0

func IsSPDKTgtReady(timeout time.Duration) bool

IsSPDKTgtReady checks if SPDK target is ready

func LoadClientTLS

func LoadClientTLS(caFile, certFile, keyFile, peerName string) (*tls.Config, error)

LoadClientTLS prepares the TLS configuration that can be used by a client while connecting to a server. peerName must be provided when expecting the server to offer a certificate with that CommonName. caFile, certFile, and keyFile are all optional.

func LoadServerTLS

func LoadServerTLS(caFile, certFile, keyFile, peerName string) (*tls.Config, error)

LoadServerTLS prepares the TLS configuration needed for a server with the given certificate files. peerName is either the name that the client is expected to have a certificate for or empty, in which case any client is allowed to connect.

func NewServer

func NewServer(endpoint string, tlsConfig *tls.Config, opts ...grpc.ServerOption) (*grpc.Server, net.Listener, error)

NewServer is a helper function to start a grpc server at the given endpoint.

func Now

func Now() string

func ParsePortRange added in v1.5.0

func ParsePortRange(portRange string) (int32, int32, error)

func PrintJSON

func PrintJSON(obj interface{}) error

func RemoveFile

func RemoveFile(file string) error

func ServerTLS

func ServerTLS(caCert, cert, key []byte, peerName string) (*tls.Config, error)

ServerTLS prepares the TLS configuration needed for a server with given encoded certficate and private key.

func SetUpLogger

func SetUpLogger(logsDir string) error

func UUID

func UUID() string

Types

type Bitmap

type Bitmap struct {
	// contains filtered or unexported fields
}

func NewBitmap

func NewBitmap(start, end int32) *Bitmap

NewBitmap allocate a bitmap range from [start, end], notice the end is included

func (*Bitmap) AllocateRange

func (b *Bitmap) AllocateRange(count int32) (int32, int32, error)

func (*Bitmap) ReleaseRange

func (b *Bitmap) ReleaseRange(start, end int32) error

type LonghornFormatter

type LonghornFormatter struct {
	*logrus.TextFormatter

	LogsDir string
	// contains filtered or unexported fields
}

func (LonghornFormatter) Format

func (l LonghornFormatter) Format(entry *logrus.Entry) ([]byte, error)

type LonghornWriter

type LonghornWriter struct {
	// contains filtered or unexported fields
}

func NewLonghornWriter

func NewLonghornWriter(name string, logsDir string) (*LonghornWriter, error)

func (LonghornWriter) Close

func (l LonghornWriter) Close() error

func (LonghornWriter) StreamLog

func (l LonghornWriter) StreamLog(done chan struct{}) (chan string, error)

func (LonghornWriter) Write

func (l LonghornWriter) Write(input []byte) (int, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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