Skip to content

feat: support timeouts - #3

Open
secDre4mer wants to merge 5 commits into
masterfrom
feat/timeout
Open

secDre4mer wants to merge 5 commits into
masterfrom
feat/timeout

Conversation

@secDre4mer

Copy link
Copy Markdown
Contributor

No description provided.

@secDre4mer
secDre4mer requested review from gremat and a balanced review from Copilot November 30, 2026 12:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The constructor changes break existing tls.Config callers and panic on nil options, while the configured timeout leaves source-IP discovery unbounded.

3 open issues
What changed in this PR

Adds configurable timeouts to the syslog client’s connection setup and message sends through a new constructor-options API.

Changes:

  • Introduces WithTLSConfig and WithTimeout options for both constructors.
  • Adds transport-specific timeouts, closes connections after partial write failures, and ensures unsuccessful HTTP responses are closed.
  • Migrates existing tests to options and adds an HTTP timeout test.
File Description
connectionwriter.go Implements options, connection and send timeouts, and connection/response cleanup.
client.go Accepts and forwards constructor options, with an updated usage example.
client_test.go Updates constructor calls and tests timeout errors from stalled HTTP responses.

Review effort: Balanced

Comment thread client.go
func NewClient(connectionType ConnectionType, address string, tlsconfig *tls.Config) (*Client, error) {
connWriter, err := NewConnectionWriter(connectionType, address, tlsconfig)
// - NewClient(ConnectionTLS, "172.0.0.1:514", WithTLSConfig(config), WithTimeout(10*time.Second))
func NewClient(connectionType ConnectionType, address string, opts ...Option) (*Client, error) {
Comment thread connectionwriter.go
func NewConnectionWriter(connectionType ConnectionType, address string, opts ...Option) (ConnectionWriter, error) {
var o options
for _, opt := range opts {
opt(&o)
Comment thread connectionwriter.go
return &httpWriter{
httpURL: address,
client: http.Client{Transport: transport},
client: http.Client{Transport: transport, Timeout: o.timeout},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants