Skip to content

Commit

Permalink
upgrade goware/channel dep which adds Label option
Browse files Browse the repository at this point in the history
  • Loading branch information
pkieltyka committed Mar 30, 2024
1 parent 3877127 commit d14166e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
8 changes: 7 additions & 1 deletion ethmonitor/ethmonitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -863,14 +863,20 @@ func (m *Monitor) broadcast(events Blocks) {
}
}

func (m *Monitor) Subscribe() Subscription {
func (m *Monitor) Subscribe(optLabel ...string) Subscription {
m.mu.Lock()
defer m.mu.Unlock()

var label string
if len(optLabel) > 0 {
label = optLabel[0]
}

subscriber := &subscriber{
ch: channel.NewUnboundedChan[Blocks](10, 5000, channel.Options{
Logger: m.log,
Alerter: m.alert,
Label: label,
}),
done: make(chan struct{}),
}
Expand Down
6 changes: 3 additions & 3 deletions ethmonitor/ethmonitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ func TestMonitorBasic(t *testing.T) {
}(t)
defer monitor.Stop()

sub := monitor.Subscribe()
sub := monitor.Subscribe("TestMonitorBasic")
defer sub.Unsubscribe()

subs := []ethmonitor.Subscription{}
go func() {
for i := 0; i < 10; i++ {
s := monitor.Subscribe()
s := monitor.Subscribe(fmt.Sprintf("TestMonitorBasic/sub/%d", i))
subs = append(subs, s)
}

Expand Down Expand Up @@ -231,7 +231,7 @@ func TestMonitorWithReorgme(t *testing.T) {
}(t)
defer monitor.Stop()

sub := monitor.Subscribe()
sub := monitor.Subscribe("TestMonitorWithReorgme")
defer sub.Unsubscribe()

events := make([]*ethmonitor.Block, 0)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/goware/breaker v0.1.2
github.com/goware/cachestore v0.8.0
github.com/goware/calc v0.2.0
github.com/goware/channel v0.4.0
github.com/goware/channel v0.4.1
github.com/goware/logger v0.3.0
github.com/goware/pp v0.0.3
github.com/goware/superr v0.0.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ github.com/goware/cachestore v0.8.0 h1:NWW9nh7eXgDQfaxdhWOdopKRDc6bWH8qm5kv2w6LS
github.com/goware/cachestore v0.8.0/go.mod h1:ikiO2RmxIt4cVqEBII6yR+V4Z7pH+y8bMQHpd1MvG1Y=
github.com/goware/calc v0.2.0 h1:3B9qjXYpE0kgS4LhyklbM6X/0cOvZLdUZG7sdAuVCb4=
github.com/goware/calc v0.2.0/go.mod h1:BSQUbfS6ICW9RvSV9SikDY+t6/HQKI+CUxIpjE3VD28=
github.com/goware/channel v0.4.0 h1:MfJPLJKhZi2D+seuM2MTKQxOzzjP/zIE7yAn8y47UbA=
github.com/goware/channel v0.4.0/go.mod h1:m3JBDrah57BipyVWu8R1eBanf1YacnZRluIVSv0jF/U=
github.com/goware/channel v0.4.1 h1:N6AqSuB6ZMOrfezhpQJ2xo5Y6jlJES+m+P+JyyX9XIo=
github.com/goware/channel v0.4.1/go.mod h1:m3JBDrah57BipyVWu8R1eBanf1YacnZRluIVSv0jF/U=
github.com/goware/logger v0.3.0 h1:pdgnsqj2rSDXtfdu+UuAFuBuOapxeDYNETY39227LMM=
github.com/goware/logger v0.3.0/go.mod h1:IC34c5H56R1I4/R/d51aQhzHsjSJqkQyIHyuJxOiu0w=
github.com/goware/pp v0.0.3 h1:2Yv0IFGOpVjCDayPYzrqskCe9qmGoKBIyu6Uy//LVUU=
Expand Down

0 comments on commit d14166e

Please sign in to comment.