libraidan: Index | Files

package rruntime

import ""

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


Package Files

callstack.go context.go


var Deserialize = DeserializeCtx

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

var Serialize = SerializeCtx

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

func DeserializeCtx Uses

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 Uses

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 Uses

func GetMyFileName() string

GetMyFileName returns the caller's absolute file path

func GetMyFuncName Uses

func GetMyFuncName() string

GetMyFuncName returns the caller's function name

func GetMyLineNumber Uses

func GetMyLineNumber() int

GetMyLineNumber returns the caller's line number

func SerializeCtx Uses

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

type SerializeOpts Uses

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

Package rruntime imports 8 packages (graph). Updated 2020-07-14. Refresh now. Tools for package owners.