rruntime

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2023 License: BSD-3-Clause Imports: 8 Imported by: 1

Documentation

Overview

Package rruntime contains useful runtime or meta functions, including caller (function, filename, line) introspection and context.Context serialization/deserialization

Index

Constants

This section is empty.

Variables

View Source
var Deserialize = DeserializeCtx

Deserialize deserializes the given output of Serialize. See DeserializeCtx deprecated: use DeserializeCtx

View Source
var Serialize = SerializeCtx

Serialize serializes a given context. See SerializeCtx deprecated: use SerializeCtx

Functions

func DeserializeCtx added in v0.3.1

func DeserializeCtx(ser []byte) (context.Context, context.CancelFunc, error)

DeserializeCtx inflates the byte-array output of SerializeCtx into a context and optional CancelFunc The options specified during serialization dictate whether CancelFunc is non-nil

func GetCallerDetails

func GetCallerDetails(stackSkip int) (string, string, int)

GetCallerDetails returns a (filename, function name, line number) tuple of the current callstack the function internally skips itself, so invoking GetCallerDetails(0) returns the invoker's location similarly, invoking GetCallerDetails(1) returns the invoker's caller's location, and GetCallerDetails(-1) will always return the location of GetCallerDetails

func GetMyFileName

func GetMyFileName() string

GetMyFileName returns the caller's absolute file path

func GetMyFuncName

func GetMyFuncName() string

GetMyFuncName returns the caller's function name

func GetMyLineNumber

func GetMyLineNumber() int

GetMyLineNumber returns the caller's line number

func SerializeCtx added in v0.3.1

func SerializeCtx(ctx context.Context, opts ...SerializeOpts) ([]byte, error)

SerializeCtx serializes a given context's values, deadlines, and cancellations into a byte array If any function has been added to the context as a value, an error will be returned duplicate context keys aren't supported: the context stack is being frozen at the point of serialization. the deepest (furthest from base context) key is used. an optional parameter is used to specify serialization options. omitted options retain cancel/deadlines, but will not ignore functions

Types

type SerializeOpts added in v0.3.1

type SerializeOpts struct {
	// RetainCancel indicates whether the given context's cancel function (if any)
	// should be retained and re-inflated during deserialization.
	RetainCancel bool
	// RetainDeadline indicates whether the given context's deadline (if any)
	// should be retained and re-inflated during deserialization.
	RetainDeadline bool
	// IgnoreFunctions indicates whether functions stored in the given context's values
	// should be ignored.  Unignored functions will cause an error during serialization
	IgnoreFunctions bool
}

SerializeOpts defines options used during serialization

Jump to

Keyboard shortcuts

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