g0debug

package
v0.4.171 Latest Latest
Warning

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

Go to latest
Published: May 12, 2024 License: ISC Imports: 9 Imported by: 0

Documentation

Overview

Package g0debug provides troubleshooting types for Go threads and thread-groups

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GoErrorDump

func GoErrorDump(goError parl.GoError) (s string)

GoErrorDump prints everything about parl.GoError

  • parl.GoError: type: *g0.GoError
  • err: pnet.InterfaceAddrs netInterface.Addrs route ip+net: invalid network interface at pnet.InterfaceAddrs()-interface.go:30
  • t: 2023-05-10 15:53:07.885969000-07:00
  • errContext: GeLocalChan
  • goroutine: 72_func:g5.(*Netlink).streamReaderThread()-netlink.go:156_cre:g5.(*Netlink).ReaderThread()-netlink.go:79

Types

type ThreadLogger

type ThreadLogger struct {
	// contains filtered or unexported fields
}

ThreadLogger waits for a GoGroup, SubGo or SubGroup to terminate while printing information on threads that have yet to exit every second.

  • Because the GoGroup owner needs to continue consuming the GoGroup’s error channel, ThreadLogger has built-in threading
  • the returned sync.WaitGroup pointer should be used to ensure main does not exit prematurely. The WaitGroup ends when the GoGroup ends and ThreadLogger ceases output

func NewThreadLogger

func NewThreadLogger(goGen parl.GoGen, logFn ...func(format string, a ...interface{})) (threadLogger *ThreadLogger)

NewThreadLogger wraps a GoGen thread-group in a debug listener

  • parl.AggregateThread is enabled for the thread-group
  • ThreadLogger listens for thread-group Cancel
  • Wait method ensures process does not exit prior to ThreadLogger complete
  • logFn is an optional logging function, default parl.Log to stderr

Usage:

main() {
  var threadGroup = g0.NewGoGroup(context.Background())
  defer threadGroup.Wait()
  defer g0.NewThreadLogger(threadGroup).Log().Wait()
  defer threadGroup.Cancel()
  …
 threadGroup.Cancel()

func (*ThreadLogger) Log

func (t *ThreadLogger) Log() (t2 *ThreadLogger)

Log preares the threadgroup for logging on Cancel

func (*ThreadLogger) Wait

func (t *ThreadLogger) Wait()

Jump to

Keyboard shortcuts

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