Skip to content

Commit

Permalink
Use pointer for OnConnectCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
belimawr committed Oct 18, 2024
1 parent c1134b7 commit 7bac99e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions libbeat/esleg/eslegclient/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}
Expand Down
6 changes: 3 additions & 3 deletions libbeat/outputs/elasticsearch/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down

0 comments on commit 7bac99e

Please sign in to comment.