context

package
v0.0.0-...-3231407 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	P2pLookupCacheTtl      = 500 * time.Millisecond
	P2pLookupNotFoundValue = "PEER_NOT_FOUND"
)

Cache constants.

View Source
const (
	CorrelationIdCtxKey = "correlation_id"
	DigestCtxKey        = "digest"
	FileChunkCtxKey     = "file_chunk"
	BlobUrlCtxKey       = "blob_url"
	BlobRangeCtxKey     = "blob_range"
	NamespaceCtxKey     = "namespace"
	ReferenceCtxKey     = "reference"
	RefTypeCtxKey       = "ref_type"
	LoggerCtxKey        = "logger"
)

Context keys.

View Source
const (
	P2PHeaderKey         = "X-MS-Cluster-P2P-RequestFromPeer"
	CorrelationHeaderKey = "X-MS-Cluster-P2P-CorrelationId"
	NodeHeaderKey        = "X-MS-Cluster-P2P-Node"
)

Request headers.

View Source
const (
	PeerResolutionStartLog     = "peer resolution start"
	PeerResolutionStopLog      = "peer resolution stop"
	PeerNotFoundLog            = "peer not found"
	PeerResolutionExhaustedLog = "peer resolution exhausted"
	PeerRequestErrorLog        = "peer request error"
)

Log messages.

View Source
const (
	KeyTTL = 30 * time.Minute
)

P2P network.

Variables

View Source
var (
	NodeName, _ = os.Hostname()
	Namespace   = "peerd-ns"

	// KubeConfigPath is the path of the kubeconfig file, which is used if run in an environment outside a pod.
	KubeConfigPath = "/opt/peerd/kubeconfig"
)

Functions

func BlobUrl

func BlobUrl(c *gin.Context) string

BlobUrl extracts the blob URL from the incoming request URL.

func FillCorrelationId

func FillCorrelationId(c *gin.Context)

func IsRequestFromAPeer

func IsRequestFromAPeer(c *gin.Context) bool

IsRequestFromAPeer indicates if the current request is from a peer.

func Logger

func Logger(c *gin.Context) zerolog.Logger

Logger gets the logger with request specific fields.

func Merge

func Merge[T any](cs ...<-chan T) <-chan T

Merge merges multiple input channels into a single output channel. It starts a goroutine for each input channel and sends the values from each input channel to the output channel. Once all input channels are closed, it closes the output channel. The function returns the output channel.

func RangeStartIndex

func RangeStartIndex(rangeValue string) (int64, error)

RangeStartIndex returns the start index of a byte range specified in the given range header value. It expects the range value to be in the format "bytes=startIndex-endIndex".

func SetOutboundHeaders

func SetOutboundHeaders(r *http.Request, c *gin.Context)

SetOutboundHeaders sets the mandatory headers for all outbound requests.

Types

This section is empty.

Jump to

Keyboard shortcuts

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