Skip to content

Commit

Permalink
Merge branch 'release/v0.5.0'
Browse files Browse the repository at this point in the history
* release/v0.5.0:
  Revert "Update license header"
  Update license header
  Fix a data race issue. Refactor encodeEvent function in cluster_events.go
  • Loading branch information
buraksezer committed Feb 5, 2024
2 parents 8f7dde1 + e773606 commit 6b05c5d
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions events/cluster_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@
package events

import (
"bytes"
"encoding/json"
"fmt"
"reflect"
"strconv"
"strings"

"github.com/buraksezer/olric/internal/bufpool"
"github.com/buraksezer/olric/internal/util"
)

var pool = bufpool.New()

const (
ClusterEventsChannel = "cluster.events"
KindNodeJoinEvent = "node-join-event"
Expand All @@ -41,9 +39,7 @@ type Event interface {

// encodeEvents encodes given interface to its JSON representation and preserves the order in fields slice.
func encodeEvent(data interface{}, fields []string, valueExtractor func(r reflect.Value, field string) (interface{}, error)) (string, error) {
buf := pool.Get()
defer pool.Put(buf)

buf := bytes.NewBuffer(nil)
buf.WriteString("{")
r := reflect.Indirect(reflect.ValueOf(data))
for i, field := range fields {
Expand Down

0 comments on commit 6b05c5d

Please sign in to comment.