nri/pkg/stub
Antonio Ojea 9ff59cc2ac don't exit on close
It is not a good practice for a library to unilaterally decide to
terminate the entire program and, since it is imported, is super hard to
debug for nri plugins authors that only see the program exit without any
obvious reason.

Instead of exiting the plugin will return the error so plugins author
can decide to retry on the output of the Run() method.

for i := 0; i < maxRetries; i++ {
	err = plugin.nriPlugin.Run(ctx)
	if errors.Is(err, ttrpc.ErrServerClosed ) {
		time.Sleep(retryInterval)
		continue
	}

	if err != nil {
		return
	}
}

Change-Id: Ic72612d4e8421a2eb301d33dda760765461929d7
Signed-off-by: Antonio Ojea <aojea@google.com>
2025-05-22 10:29:04 +00:00
..
stub.go don't exit on close 2025-05-22 10:29:04 +00:00