Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions actor/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func TestRestartsMaxRestarts(t *testing.T) {
}
}, "foo", WithMaxRestarts(restarts))

for i := 0; i < 2; i++ {
for i := range 2 {
e.Send(pid, payload{i})
}
<-e.Poison(pid).Done()
Expand Down Expand Up @@ -198,7 +198,7 @@ func TestSendMsgRaceCon(t *testing.T) {
}
}, "test")

for i := 0; i < 100; i++ {
for range 100 {
wg.Add(1)
e.Send(pid, []byte("f"))
wg.Done()
Expand All @@ -211,7 +211,7 @@ func TestSpawn(t *testing.T) {
require.NoError(t, err)
wg := sync.WaitGroup{}

for i := 0; i < 10; i++ {
for i := range 10 {
wg.Add(1)
go func(i int) {
tag := strconv.Itoa(i)
Expand Down Expand Up @@ -279,7 +279,7 @@ func TestStop(t *testing.T) {
)
e, err := NewEngine(NewEngineConfig())
require.NoError(t, err)
for i := 0; i < 4; i++ {
for i := range 4 {
wg.Add(1)
tag := strconv.Itoa(i)
pid := e.SpawnFunc(func(c *Context) {
Expand Down Expand Up @@ -340,7 +340,7 @@ func TestPoison(t *testing.T) {
)
e, err := NewEngine(NewEngineConfig())
require.NoError(t, err)
for i := 0; i < 4; i++ {
for i := range 4 {
wg.Add(1)
tag := strconv.Itoa(i)
pid := e.SpawnFunc(func(c *Context) {
Expand Down Expand Up @@ -382,7 +382,7 @@ func TestRequestResponse(t *testing.T) {

})
t.Run("should not timeout", func(t *testing.T) {
for i := 0; i < 200; i++ {
for range 200 {
resp := e.Request(a, responseEvent{d: time.Microsecond * 1}, time.Millisecond*800)
res, err := resp.Result()
assert.NoError(t, err)
Expand Down Expand Up @@ -466,15 +466,15 @@ func (r *TestReceiver) Receive(ctx *Context) {
func TestMultipleStops(t *testing.T) {
e, err := NewEngine(NewEngineConfig())
require.NoError(t, err)
for i := 0; i < 1000; i++ {
for range 1000 {
done := make(chan struct{})
pid := e.SpawnFunc(func(ctx *Context) {
switch ctx.Message().(type) {
case Stopped:
close(done)
}
}, "test")
for j := 0; j < 10; j++ {
for range 10 {
e.Stop(pid)
}
<-done
Expand Down
2 changes: 1 addition & 1 deletion actor/inbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestInboxSendAndProcess(t *testing.T) {
}

func TestInboxSendAndProcessMany(t *testing.T) {
for i := 0; i < 100000; i++ {
for range 100000 {
inbox := NewInbox(10)
processedMessages := make(chan Envelope, 10)
mockProc := MockProcesser{
Expand Down
2 changes: 1 addition & 1 deletion actor/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (p *process) Invoke(msgs []Envelope) {
}
}()

for i := 0; i < len(msgs); i++ {
for i := range msgs {
nproc++
msg := msgs[i]
if pill, ok := msg.Msg.(poisonPill); ok {
Expand Down
9 changes: 3 additions & 6 deletions cluster/util.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package cluster

import (
"slices"

"github.com/anthdm/hollywood/actor"
)

Expand Down Expand Up @@ -37,10 +39,5 @@ func (m *Member) Equals(other *Member) bool {
// TODO: Maybe relocate this function.
// HasKind returns true whether the Member has the given kind registered.
func (m *Member) HasKind(kind string) bool {
for _, k := range m.Kinds {
if k == kind {
return true
}
}
return false
return slices.Contains(m.Kinds, kind)
}
2 changes: 1 addition & 1 deletion examples/helloworld/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func main() {
}

pid := engine.Spawn(newFoo, "my_actor")
for i := 0; i < 5; i++ {
for range 5 {
engine.Send(pid, &message{data: "hello world!"})
}

Expand Down
2 changes: 1 addition & 1 deletion examples/metrics/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func main() {
barPID = e.Spawn(newBar, "bar", actor.WithMiddleware(barmetrics.WithMetrics()))
)

for i := 0; i < 10; i++ {
for range 10 {
e.Send(fooPID, Message{data: "message to foo"})
e.Send(barPID, Message{data: "message to bar"})
time.Sleep(time.Second)
Expand Down
2 changes: 1 addition & 1 deletion examples/tcpserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (handler) Receive(c *actor.Context) {
case []byte:
fmt.Println("got message to handle:", string(msg))
case actor.Stopped:
for i := 0; i < 3; i++ {
for i := range 3 {
fmt.Printf("\r handler stopping in %d", 3-i)
time.Sleep(time.Second)
}
Expand Down
65 changes: 33 additions & 32 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,58 +1,59 @@
module github.com/anthdm/hollywood

go 1.22.12

toolchain go1.24.0
go 1.26.1

require (
github.com/DataDog/gostackparse v0.7.0
github.com/grandcat/zeroconf v1.0.0
github.com/hashicorp/consul/api v1.31.2
github.com/planetscale/vtprotobuf v0.5.0
github.com/prometheus/client_golang v1.18.0
github.com/stretchr/testify v1.8.4
google.golang.org/grpc v1.60.1
google.golang.org/protobuf v1.32.0
storj.io/drpc v0.0.33
github.com/hashicorp/consul/api v1.33.4
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10
github.com/prometheus/client_golang v1.23.2
github.com/stretchr/testify v1.11.1
google.golang.org/grpc v1.79.2
google.golang.org/protobuf v1.36.11
storj.io/drpc v0.0.34
)

require (
github.com/armon/go-metrics v0.4.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/fatih/color v1.18.0 // indirect
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-metrics v0.5.4 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/serf v0.10.1 // indirect
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/serf v0.10.2 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/miekg/dns v1.1.41 // indirect
github.com/miekg/dns v1.1.72 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.67.5 // indirect
github.com/prometheus/procfs v0.20.1 // indirect
go.yaml.in/yaml/v2 v2.4.4 // indirect
golang.org/x/mod v0.33.0 // indirect
golang.org/x/sync v0.19.0 // indirect
golang.org/x/tools v0.42.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260226221140-a57be14db171 // indirect
)

require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/zeebo/errs v1.2.2 // indirect
github.com/zeebo/xxh3 v1.0.2
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8
golang.org/x/net v0.34.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/text v0.21.0 // indirect
github.com/zeebo/errs v1.4.0 // indirect
github.com/zeebo/xxh3 v1.1.0
golang.org/x/exp v0.0.0-20260218203240-3dfff04db8fa
golang.org/x/net v0.51.0 // indirect
golang.org/x/sys v0.41.0 // indirect
golang.org/x/text v0.34.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading