utils

package
v1.10.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2023 License: Apache-2.0 Imports: 20 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// DefaultKubeClusterDomain is the default value of KubeClusterDomain.
	DefaultKubeClusterDomain = "cluster.local"
)
View Source
const (
	// HostIPEnvVar is the environment variable to override host's chosen IP address.
	HostIPEnvVar = "DAPR_HOST_IP"
)

Variables

View Source
var (
	KubeConfigVar = "KUBE_CONFIG"
)

Functions

func ComponentLogName added in v1.10.0

func ComponentLogName(name, typ, version string) string

ComponentLogName returns the name of a component that can be used in logging.

func Contains added in v1.9.0

func Contains[T comparable](s []T, v T) bool

Contains reports whether v is present in s. Similar to https://pkg.go.dev/golang.org/x/exp/slices#Contains.

func Filter added in v1.10.0

func Filter[T any](items []T, test func(item T) bool) []T

Filter returns a new slice containing all items in the given slice that satisfy the given test.

func GetConfig

func GetConfig() *rest.Config

GetConfig gets a kubernetes rest config.

func GetEnvOrElse added in v1.9.0

func GetEnvOrElse(name, orElse string) string

GetEnvOrElse get the value from the OS environment or use the else value if variable is not present.

func GetHostAddress added in v0.8.0

func GetHostAddress() (string, error)

GetHostAddress selects a valid outbound IP address for the host.

func GetIntValOrDefault added in v1.10.0

func GetIntValOrDefault(val int, defaultValue int) int

GetIntValOrDefault returns an int value if greater than 0 OR default value.

func GetKubeClient

func GetKubeClient() *kubernetes.Clientset

GetKubeClient gets a kubernetes client.

func GetKubeClusterDomain added in v1.3.0

func GetKubeClusterDomain() (string, error)

GetKubeClusterDomain search KubeClusterDomain value from /etc/resolv.conf file.

func IsSocket added in v1.9.0

func IsSocket(f fs.FileInfo) bool

IsSocket returns if the given file is a unix socket.

func IsTruthy added in v1.8.0

func IsTruthy(val string) bool

IsTruthy returns true if a string is a truthy value. Truthy values are "y", "yes", "true", "t", "on", "1" (case-insensitive); everything else is false.

func IsYaml added in v1.8.0

func IsYaml(fileName string) bool

IsYaml checks whether the file is yaml or not.

func PopulateMetadataForBulkPublishEntry added in v1.10.0

func PopulateMetadataForBulkPublishEntry(reqMeta, entryMeta map[string]string) map[string]string

func SetEnvVariables added in v1.8.0

func SetEnvVariables(variables map[string]string) error

SetEnvVariables set variables to environment.

func SocketExists added in v1.9.0

func SocketExists(socketPath string) bool

SocketExists returns true if the file in that path is an unix socket.

func ToISO8601DateTimeString added in v0.5.0

func ToISO8601DateTimeString(dateTime time.Time) string

ToISO8601DateTimeString converts dateTime to ISO8601 Format ISO8601 Format: 2020-01-01T01:01:01.10101Z.

func UppercaseRequestMiddleware added in v1.10.0

func UppercaseRequestMiddleware(next http.Handler) http.Handler

UppercaseRequestMiddleware is a HTTP middleware that transforms the request body to uppercase

func UppercaseResponseMiddleware added in v1.10.0

func UppercaseResponseMiddleware(next http.Handler) http.Handler

UppercaseResponseMiddleware is a HTTP middleware that transforms the response body to uppercase

Types

type ByteSlicePool added in v1.10.0

type ByteSlicePool struct {
	MinCap int
	// contains filtered or unexported fields
}

ByteSlicePool is a wrapper around sync.Pool to get []byte objects with a given capacity.

func NewByteSlicePool added in v1.10.0

func NewByteSlicePool(minCap int) *ByteSlicePool

NewByteSlicePool returns a new ByteSlicePool object.

func (ByteSlicePool) Get added in v1.10.0

func (sp ByteSlicePool) Get(cap int) []byte

Get a slice from the pool. The cap parameter is used only if we need to allocate a new byte slice; there's no guarantee a slice retrieved from the pool will have enough capacity for that.

func (ByteSlicePool) Put added in v1.10.0

func (sp ByteSlicePool) Put(bs []byte)

Put a slice back in the pool.

func (ByteSlicePool) Resize added in v1.10.0

func (sp ByteSlicePool) Resize(orig []byte, size int) []byte

Resize a byte slice, making sure that it has enough capacity for a given size.

Directories

Path Synopsis
Package fasthttpadaptor provides helper functions for converting net/http request handlers to fasthttp request handlers.
Package fasthttpadaptor provides helper functions for converting net/http request handlers to fasthttp request handlers.

Jump to

Keyboard shortcuts

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