util

package
v0.0.0-...-6c868a8 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CliCertFile = "rss-client.crt"
	CliKeyFile  = "rss-client.key"
	CliCAFile   = "rss-client-ca.crt"
)

Variables

This section is empty.

Functions

func CreateMemberName

func CreateMemberName(clusterName string, member int) string

func GetCounterFromMemberName

func GetCounterFromMemberName(name string) (int, error)

func IsRetryFailure

func IsRetryFailure(err error) bool

func JsonLogObject

func JsonLogObject(logger *RssLogger, spec interface{}, text string)

func LogOutput

func LogOutput(logger *RssLogger, level logrus.Level, id string, result string)

func MemberNameFromPeerURL

func MemberNameFromPeerURL(pu string) (string, error)

func NewTLSConfig

func NewTLSConfig(certData, keyData, caData []byte) (*tls.Config, error)

func PresentIn

func PresentIn(a string, list []string) bool

PresentIn returns true if the given string is part of an array of strings

func Retry

func Retry(interval time.Duration, maxRetries int, f ConditionFunc) error

Retry retries f every interval until after maxRetries. The interval won't be affected by how long f takes. For example, if interval is 3s, f takes 1s, another f will be called 2s later. However, if f takes longer than interval, it will be delayed.

Types

type ColorScheme

type ColorScheme struct {
	InfoLevelStyle  string
	WarnLevelStyle  string
	ErrorLevelStyle string
	FatalLevelStyle string
	PanicLevelStyle string
	DebugLevelStyle string
	PrefixStyle     string
	TimestampStyle  string
}

type ConditionFunc

type ConditionFunc func() (bool, error)

type Member

type Member struct {
	Name string
	// Kubernetes namespace this member runs in.
	Namespace string

	SEQ        uint64
	Failures   uint64
	Online     bool
	AppPrimary bool
	AppRunning bool
	AppFailed  bool

	SecurePeer   bool
	SecureClient bool
}

func (*Member) Addr

func (m *Member) Addr() string

func (*Member) ClientURL

func (m *Member) ClientURL() string

ClientURL is the client URL for this member

func (*Member) Copy

func (m *Member) Copy() *Member

func (Member) IsEqual

func (m Member) IsEqual(other Member) bool

func (*Member) ListenClientURL

func (m *Member) ListenClientURL() string

func (*Member) ListenPeerURL

func (m *Member) ListenPeerURL() string

func (*Member) Offline

func (m *Member) Offline()

func (*Member) PeerURL

func (m *Member) PeerURL() string

func (*Member) Restore

func (m *Member) Restore(last *Member)

func (*Member) String

func (m *Member) String() string

type MemberSet

type MemberSet map[string]*Member

func NewMemberSet

func NewMemberSet(ms ...*Member) MemberSet

func (MemberSet) ActiveMembers

func (ms MemberSet) ActiveMembers() int32

func (MemberSet) Add

func (ms MemberSet) Add(m *Member)

func (MemberSet) AppMembers

func (ms MemberSet) AppMembers() int32

func (MemberSet) AppPrimaries

func (ms MemberSet) AppPrimaries() int32

func (MemberSet) ClientURLs

func (ms MemberSet) ClientURLs() []string

func (MemberSet) Copy

func (ms MemberSet) Copy() MemberSet

func (MemberSet) Diff

func (ms MemberSet) Diff(other MemberSet) MemberSet

the set of all members of s1 that are not members of s2

func (MemberSet) DiffExtended

func (ms MemberSet) DiffExtended(other MemberSet) MemberSet

func (MemberSet) InActiveMembers

func (ms MemberSet) InActiveMembers() int32

func (MemberSet) IsEqual

func (ms MemberSet) IsEqual(other MemberSet) bool

IsEqual tells whether two member sets are equal by checking - they have the same set of members and member equality are judged by Name only.

func (MemberSet) PeerURLPairs

func (ms MemberSet) PeerURLPairs() []string

func (MemberSet) PickOne

func (ms MemberSet) PickOne() *Member

func (MemberSet) Reconcile

func (ms MemberSet) Reconcile(running MemberSet, max int32) (MemberSet, error)

func (MemberSet) Remove

func (ms MemberSet) Remove(name string)

func (MemberSet) Size

func (ms MemberSet) Size() int32

func (MemberSet) String

func (ms MemberSet) String() string

type RetryError

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

func (*RetryError) Error

func (e *RetryError) Error() string

type RssLogger

type RssLogger struct {
	*logrus.Entry
}

func GetLogger

func GetLogger(component string) *RssLogger

func (*RssLogger) Debug

func (entry *RssLogger) Debug(args ...interface{})

func (*RssLogger) Debugf

func (entry *RssLogger) Debugf(format string, args ...interface{})

func (*RssLogger) V

func (entry *RssLogger) V(level int) *RssLogger

func (*RssLogger) WithField

func (entry *RssLogger) WithField(name, value string) *RssLogger

type TextFormatter

type TextFormatter struct {
	// Set to true to bypass checking for a TTY before outputting colors.
	ForceColors bool

	// Force disabling colors. For a TTY colors are enabled by default.
	DisableColors bool

	// Force formatted layout, even for non-TTY output.
	ForceFormatting bool

	// Disable timestamp logging. useful when output is redirected to logging
	// system that already adds timestamps.
	DisableTimestamp bool

	// Disable the conversion of the log levels to uppercase
	DisableUppercase bool

	// Enable logging the full timestamp when a TTY is attached instead of just
	// the time passed since beginning of execution.
	FullTimestamp bool

	// Timestamp format to use for display when a full timestamp is printed.
	TimestampFormat string

	// The fields are sorted by default for a consistent output. For applications
	// that log extremely frequently and don't use the JSON formatter this may not
	// be desired.
	DisableSorting bool

	// Wrap empty fields in quotes if true.
	QuoteEmptyFields bool

	// Can be set to the override the default quoting character "
	// with something else. For example: ', or `.
	QuoteCharacter string

	// Pad msg field with spaces on the right for display.
	// The value for this parameter will be the size of padding.
	// Its default value is zero, which means no padding will be applied for msg.
	SpacePadding int

	sync.Once
	// contains filtered or unexported fields
}

func (*TextFormatter) Format

func (f *TextFormatter) Format(entry *logrus.Entry) ([]byte, error)

func (*TextFormatter) SetColorScheme

func (f *TextFormatter) SetColorScheme(colorScheme *ColorScheme)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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