utils

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package utils provides generic utility routines used within FSM.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEnv

func GetEnv(envVar string, defaultValue string) string

GetEnv is a convenience wrapper for os.Getenv() with additional default value return when empty or unset

func GetIPFromContext

func GetIPFromContext(ctx context.Context) net.Addr

GetIPFromContext obtains the IP address of the caller from the context.

func GetLastChunkOfSlashed

func GetLastChunkOfSlashed(s string) string

GetLastChunkOfSlashed splits a string by slash and returns the last chunk.

func GrpcServe

func GrpcServe(ctx context.Context, grpcServer *grpc.Server, lis net.Listener, cancel context.CancelFunc, serverType string, errorCh chan interface{})

GrpcServe starts the gRPC server passed.

func Hash added in v1.0.1

func Hash(bytes []byte) uint64

Hash calculates an FNV-1 hash from a given byte array

func HashFromString

func HashFromString(s string) (uint64, error)

HashFromString calculates an FNV-1 hash from a given string, returns it as a uint64 and error, if any

func IP2Int added in v1.0.1

func IP2Int(ip net.IP) *big.Int

IP2Int converts ip addr to int.

func Int2IP16 added in v1.0.1

func Int2IP16(nn uint64) net.IP

Int2IP16 converts uint64 to ipv6.

func Int2IP4 added in v1.0.1

func Int2IP4(nn uint32) net.IP

Int2IP4 converts uint32 to ipv4.

func NewGrpc

func NewGrpc(serverType string, port int, certPem, keyPem, rootCertPem []byte) (*grpc.Server, net.Listener, error)

NewGrpc creates a new gRPC server

func PrettyJSON

func PrettyJSON(js []byte, prefix string) ([]byte, error)

PrettyJSON Unmarshals and Marshall again with Indent so it is human readable

func SvcAccountToK8sSvcAccount

func SvcAccountToK8sSvcAccount(svcAccount *corev1.ServiceAccount) identity.K8sServiceAccount

SvcAccountToK8sSvcAccount converts a Kubernetes service to a MeshService.

func ValidateClient

ValidateClient ensures that the connected client is authorized to connect to the gRPC server.

Types

This section is empty.

Directories

Path Synopsis
Package cidr calculates CIDR network
Package cidr calculates CIDR network

Jump to

Keyboard shortcuts

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