utils

package
v0.0.0-...-7a5359b Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteInSlice

func DeleteInSlice(s interface{}, index int) interface{}

DeleteInSlice delete an element from a Slice with an index. return the original parameter as the result instead if it is not a slice.

func FormatToDNS1123

func FormatToDNS1123(name string) string

FormatToDNS1123 converts the object name to lower case and replaces the underscore

func GoWithRecover

func GoWithRecover(handler func(), recoverHandler func(r interface{}))

GoWithRecover go task with goroutine and recover

func RemovePort

func RemovePort(addressWithPort string) string

RemovePort removing the port part of a service name is necessary due to istio requirement. 127.0.0.1:10000 -> 127.0.0.1

func ResolveServiceName

func ResolveServiceName(configuratorPath string) string

ResolveServiceName ... configuratorPath: e.g. /dubbo/config/dubbo/foo.configurators

func SetupSignalHandler

func SetupSignalHandler() (stopCh <-chan struct{})

SetupSignalHandler registered for SIGTERM and SIGINT. A stop channel is returned which is closed on one of these signals. If a second signal is caught, the program is terminated with exit code 1.

func StringToDuration

func StringToDuration(s string, repeat int64) *ptypes.Duration

StringToDuration converts the time string to protobuf Duration e.g. 2s => ptypes.Duration{Seconds: 2} 20ms => ptypes.Duration{Nanos: 20000000} 2 => ptypes.Duration{Nanos: 2000000} 2000 => ptypes.Duration{Seconds: 2}

func ToInt32

func ToInt32(portStr string) int32

ToInt32 Convert a string variable to integer with 32 bit size.

func ToUint32

func ToUint32(portStr string) uint32

ToUint32 Convert a string variable to integer with 32 bit size.

Types

type Components

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

Components ...

func (*Components) Add

func (c *Components) Add(r Runnable)

Add a new Runnable to Components. It panics if the Components is already started.

func (*Components) Start

func (c *Components) Start(stopCh <-chan struct{}) error

Start Components.

type Runnable

type Runnable interface {
	Start(<-chan struct{}) error
}

Runnable allows a component to be started.

type WorkerPool

type WorkerPool interface {
	Schedule(task func())

	ScheduleAlways(task func())

	ScheduleAuto(task func())
}

WorkerPool workerPool interface

func NewWorkerPool

func NewWorkerPool(size int) WorkerPool

NewWorkerPool build workpool object

Jump to

Keyboard shortcuts

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