From 7bac99ea2a8a2b1db703cb010509d0907f710197 Mon Sep 17 00:00:00 2001 From: Tiago Queiroz Date: Tue, 8 Oct 2024 10:23:48 -0400 Subject: [PATCH] Use pointer for OnConnectCallback --- libbeat/esleg/eslegclient/connection.go | 4 ++-- libbeat/outputs/elasticsearch/client.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libbeat/esleg/eslegclient/connection.go b/libbeat/esleg/eslegclient/connection.go index 72833c40b62..310aa853e34 100644 --- a/libbeat/esleg/eslegclient/connection.go +++ b/libbeat/esleg/eslegclient/connection.go @@ -81,7 +81,7 @@ type ConnectionSettings struct { Kerberos *kerberos.Config - OnConnectCallback func(Connection) error + OnConnectCallback func(*Connection) error Observer transport.IOStatser Parameters map[string]string @@ -290,7 +290,7 @@ func (conn *Connection) Connect(ctx context.Context) error { } if conn.OnConnectCallback != nil { - if err := conn.OnConnectCallback(*conn); err != nil { + if err := conn.OnConnectCallback(conn); err != nil { return fmt.Errorf("Connection marked as failed because the onConnect callback failed: %w", err) } } diff --git a/libbeat/outputs/elasticsearch/client.go b/libbeat/outputs/elasticsearch/client.go index c40fcffc393..56f28cdbf30 100644 --- a/libbeat/outputs/elasticsearch/client.go +++ b/libbeat/outputs/elasticsearch/client.go @@ -133,12 +133,12 @@ func NewClient( return nil, err } - conn.OnConnectCallback = func(conn eslegclient.Connection) error { + conn.OnConnectCallback = func(conn *eslegclient.Connection) error { globalCallbackRegistry.mutex.Lock() defer globalCallbackRegistry.mutex.Unlock() for _, callback := range globalCallbackRegistry.callbacks { - err := callback(&conn) + err := callback(conn) if err != nil { return err } @@ -149,7 +149,7 @@ func NewClient( defer onConnect.mutex.Unlock() for _, callback := range onConnect.callbacks { - err := callback(&conn) + err := callback(conn) if err != nil { return err }