utils

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// This is the CloudEvent extension which holds the timeout duration of the forward client.
	ProbeEventTimeoutExtension = "timeout"

	// This is the pair of CloudEvent extensions which hold the path of probe requests.
	// The path of receiver probe requests is injected into the receiverpath extension
	// by the receiver client. The corresponding forward probe requests should include
	// the targetpath extension with the same path. For example:
	//
	// If a source is configured to sink events to:
	//   http://probe-helper-receiver.cloud-run-events-probe.svc.cluster.local/some-path-goes-here
	//
	// then, each event generated by the source and passed to the probe helper
	// receiver client will include the header 'Ce-Receiverpath: /some-path-goes-here'.
	// And in order for the probe to succeed, the corresponding forward probe should
	// be made to include the header 'Ce-Targetpath: /some-path-goes-here'.
	ProbeEventTargetPathExtension   = "targetpath"
	ProbeEventReceiverPathExtension = "receiverpath"
)

Variables

View Source
var (
	ProbeEventTargetPathHeader   = "Ce-" + strings.Title(ProbeEventTargetPathExtension)
	ProbeEventReceiverPathHeader = "Ce-" + strings.Title(ProbeEventReceiverPathExtension)
)

Functions

This section is empty.

Types

type ActionFunc

type ActionFunc func(context.Context) error

ActionFunc represents a function which is called during a liveness probe. If it returns a non-nil error, the probe is considered unsuccessful.

type LivenessChecker

type LivenessChecker struct {
	ActionFuncs []ActionFunc
}

LivenessChecker executes each of the ActionFuncs upon each liveness probe.

func (*LivenessChecker) AddActionFunc

func (c *LivenessChecker) AddActionFunc(f ActionFunc)

AddActionFunc appends an ActionFunc to the list of functions to be called by the liveness checker during each liveness probe.

func (*LivenessChecker) LivenessHandlerFunc

func (c *LivenessChecker) LivenessHandlerFunc(ctx context.Context) nethttp.HandlerFunc

LivenessHandlerFunc returns the HTTP handler for probe helper liveness checks.

type SyncReceivedEvents

type SyncReceivedEvents struct {
	sync.RWMutex
	Channels map[string]chan bool
}

SyncReceivedEvents is a synchronized wrapped around a map of channels.

func NewSyncReceivedEvents

func NewSyncReceivedEvents() *SyncReceivedEvents

func (*SyncReceivedEvents) CreateReceiverChannel

func (r *SyncReceivedEvents) CreateReceiverChannel(channelID string) (func(), error)

CreateReceiverChannel creates a receiver channel at a given index in a map of receiver channels.

func (*SyncReceivedEvents) SignalReceiverChannel

func (r *SyncReceivedEvents) SignalReceiverChannel(channelID string) error

SignalReceiverChannel sends a closing signal to a receiver channel at a given index in a map of receiver channels.

func (*SyncReceivedEvents) WaitOnReceiverChannel

func (r *SyncReceivedEvents) WaitOnReceiverChannel(ctx context.Context, channelID string) error

WaitOnReceiverChannel waits on a receiver channel at a given index until it receives something or until the context expires.

type SyncTime

type SyncTime struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

SyncTime is a synchronized wrapper around a time.

func (*SyncTime) Get

func (t *SyncTime) Get() time.Time

Get gets the timestamp's time.

func (*SyncTime) SetNow

func (t *SyncTime) SetNow()

SetNow sets the desired timestamp to the current time.

type SyncTimesMap

type SyncTimesMap struct {
	sync.RWMutex
	Times map[string]time.Time
}

SyncTimesMap is a synchronized wrapped around a map of times.

Jump to

Keyboard shortcuts

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