-
Notifications
You must be signed in to change notification settings - Fork 568
Description
What happened
Using log.Fatal() in init() prevents programs importing the SDK to handle an eventual error. Any initialisation routine that may encounter errors should be called explicitly, and errors should be returned.
My problem: I cannot run Telegraf (https://github.com/influxdata/telegraf) on a machine with no network adapter. I do not expect InLong to work under these circumstances, but I do not expect that importing the SDK would prevent Telegraf from starting.
What you expected to happen
I expect the SDK to fail to initialise in a way that lets my program handle it. Whether the program should stop immediately or maybe continue with the InLong related features disabled should be left to my program.
How to reproduce
Run any Go program importing the DataProxy SDK on a machine without a network adapter.
import (
"github.com/apache/inlong/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-golang/dataproxy"
)
You can repro in a Docker container.
docker run --network none ...
Sample output:
2025/05/20 17:01:56 no ip
Environment
Tested on Linux, Ubuntu 24.04 (host and container). Also encountered on Mac CI machines.
InLong version
master
InLong Component
InLong DataProxy
Are you willing to submit PR?
- Yes, I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct