Documentation ¶
Overview ¶
Package rruntime contains useful runtime or meta functions, including caller (function, filename, line) introspection and context.Context serialization/deserialization
Index ¶
- Variables
- func DeserializeCtx(ser []byte) (context.Context, context.CancelFunc, error)
- func GetCallerDetails(stackSkip int) (string, string, int)
- func GetMyFileName() string
- func GetMyFuncName() string
- func GetMyLineNumber() int
- func SerializeCtx(ctx context.Context, opts ...SerializeOpts) ([]byte, error)
- type SerializeOpts
Constants ¶
This section is empty.
Variables ¶
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
Functions ¶
func DeserializeCtx ¶ added in v0.3.1
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 ¶
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 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