diff --git a/actor/actor_context.go b/actor/actor_context.go index b643324e7..f354fe4ba 100644 --- a/actor/actor_context.go +++ b/actor/actor_context.go @@ -244,7 +244,7 @@ func (ctx *actorContext) AwaitFuture(f *Future, cont func(res interface{}, err e message := ctx.messageOrEnvelope // invoke the callback when the future completes f.continueWith(func(res interface{}, err error) { - // send the wrapped callaback as a continuation message to self + // send the wrapped callback as a continuation message to self ctx.self.sendSystemMessage(&continuation{ f: wrapper, message: message, @@ -354,7 +354,7 @@ func (ctx *actorContext) SpawnPrefix(props *Props, prefix string) *PID { func (ctx *actorContext) SpawnNamed(props *Props, name string) (*PID, error) { if props.guardianStrategy != nil { - panic(errors.New("Props used to spawn child cannot have GuardianStrategy")) + panic(errors.New("props used to spawn child cannot have GuardianStrategy")) } var pid *PID diff --git a/actor/actor_context_test.go b/actor/actor_context_test.go index 8438ae457..25f6425a1 100644 --- a/actor/actor_context_test.go +++ b/actor/actor_context_test.go @@ -48,8 +48,8 @@ func TestActorContext_Stop(t *testing.T) { o.AssertExpectations(t) } -func TestActorContext_SendMessage_WithSenderdMiddleware(t *testing.T) { - // Define a local context with no-op sender middlware +func TestActorContext_SendMessage_WithSenderMiddleware(t *testing.T) { + // Define a local context with no-op sender middleware mw := func(next SenderFunc) SenderFunc { return func(ctx SenderContext, target *PID, envelope *MessageEnvelope) { next(ctx, target, envelope) @@ -144,7 +144,6 @@ func TestActorContext_Respond(t *testing.T) { } func TestActorContext_Forward(t *testing.T) { - // Defined a respond actor // It simply respond the string message responder := rootContext.Spawn(PropsFromFunc(func(ctx Context) { @@ -193,7 +192,7 @@ func BenchmarkActorContext_ProcessMessageWithMiddleware(b *testing.B) { } func benchmarkActorContext_SpawnWithMiddlewareN(n int, b *testing.B) { - middlwareFn := func(next SenderFunc) SenderFunc { + middlewareFn := func(next SenderFunc) SenderFunc { return func(ctx SenderContext, pid *PID, env *MessageEnvelope) { next(ctx, pid, env) } @@ -201,7 +200,7 @@ func benchmarkActorContext_SpawnWithMiddlewareN(n int, b *testing.B) { props := PropsFromProducer(nullProducer) for i := 0; i < n; i++ { - props = props.WithSenderMiddleware(middlwareFn) + props = props.WithSenderMiddleware(middlewareFn) } parent := &actorContext{self: NewLocalPID("foo"), props: props} diff --git a/actor/actor_example_test.go b/actor/actor_example_test.go index 6ecfb45f0..632f9226d 100644 --- a/actor/actor_example_test.go +++ b/actor/actor_example_test.go @@ -10,8 +10,8 @@ import ( // Demonstrates how to create an actor using a function literal and how to send a message asynchronously func Example() { - var context *actor.RootContext = actor.EmptyRootContext - var props *actor.Props = actor.PropsFromFunc(func(c actor.Context) { + var context = actor.EmptyRootContext + var props = actor.PropsFromFunc(func(c actor.Context) { if msg, ok := c.Message().(string); ok { fmt.Println(msg) // outputs "Hello World" } diff --git a/actor/child_test.go b/actor/child_test.go index 5ba58e31e..a256b6920 100644 --- a/actor/child_test.go +++ b/actor/child_test.go @@ -66,7 +66,6 @@ func NewCreateChildThenStopActor() Actor { } func TestActorCanStopChildren(t *testing.T) { - actor := rootContext.Spawn(PropsFromProducer(NewCreateChildThenStopActor)) count := 10 for i := 0; i < count; i++ { diff --git a/actor/guardian.go b/actor/guardian.go index e61ad11d0..3f5d485e9 100644 --- a/actor/guardian.go +++ b/actor/guardian.go @@ -42,7 +42,7 @@ type guardianProcess struct { } func (g *guardianProcess) SendUserMessage(pid *PID, message interface{}) { - panic(errors.New("Guardian actor cannot receive any user messages")) + panic(errors.New("guardian actor cannot receive any user messages")) } func (g *guardianProcess) SendSystemMessage(pid *PID, message interface{}) { @@ -56,11 +56,11 @@ func (g *guardianProcess) Stop(pid *PID) { } func (g *guardianProcess) Children() []*PID { - panic(errors.New("Guardian does not hold its children PIDs")) + panic(errors.New("guardian does not hold its children PIDs")) } func (*guardianProcess) EscalateFailure(reason interface{}, message interface{}) { - panic(errors.New("Guardian cannot escalate failure")) + panic(errors.New("guardian cannot escalate failure")) } func (*guardianProcess) RestartChildren(pids ...*PID) { diff --git a/actor/messages.go b/actor/messages.go index 3a2597c69..7919516a4 100644 --- a/actor/messages.go +++ b/actor/messages.go @@ -2,7 +2,7 @@ package actor import "github.com/AsynkronIT/protoactor-go/mailbox" -// An AutoReceiveMessage is a special kind of user message that will be handled in some way automatially by the actor +// An AutoReceiveMessage is a special kind of user message that will be handled in some way automatically by the actor type AutoReceiveMessage interface { AutoReceiveMessage() } diff --git a/actor/middleware/opentracing/sendermiddleware.go b/actor/middleware/opentracing/sendermiddleware.go index f42ca1f4e..c9475414b 100644 --- a/actor/middleware/opentracing/sendermiddleware.go +++ b/actor/middleware/opentracing/sendermiddleware.go @@ -7,10 +7,8 @@ import ( ) func SenderMiddleware() actor.SenderMiddleware { - return func(next actor.SenderFunc) actor.SenderFunc { return func(c actor.SenderContext, target *actor.PID, envelope *actor.MessageEnvelope) { - span := getActiveSpan(c.Self()) if span == nil { diff --git a/actor/middleware/propagator/middlewarepropagation_test.go b/actor/middleware/propagator/middlewarepropagation_test.go index 7618b02ee..2dac30694 100644 --- a/actor/middleware/propagator/middlewarepropagation_test.go +++ b/actor/middleware/propagator/middlewarepropagation_test.go @@ -9,7 +9,6 @@ import ( ) func TestPropagator(t *testing.T) { - mutex := &sync.Mutex{} spawningCounter := 0 diff --git a/actor/props.go b/actor/props.go index 9ee500b7c..68f00c07a 100644 --- a/actor/props.go +++ b/actor/props.go @@ -142,7 +142,7 @@ func (props *Props) WithSupervisor(supervisor SupervisorStrategy) *Props { return props } -// Assign one or more middlewares to the props +// Assign one or more middleware to the props func (props *Props) WithReceiverMiddleware(middleware ...ReceiverMiddleware) *Props { props.receiverMiddleware = append(props.receiverMiddleware, middleware...) diff --git a/actor/strategy_all_for_one.go b/actor/strategy_all_for_one.go index 01ce0f83d..aa8d18e86 100644 --- a/actor/strategy_all_for_one.go +++ b/actor/strategy_all_for_one.go @@ -52,7 +52,6 @@ func (strategy *allForOneStrategy) HandleFailure(supervisor Supervisor, child *P } func (strategy *allForOneStrategy) shouldStop(rs *RestartStatistics) bool { - // supervisor says this child may not restart if strategy.maxNrOfRetries == 0 { return true diff --git a/actor/strategy_one_for_one.go b/actor/strategy_one_for_one.go index 7ec9ae750..af01e30f2 100644 --- a/actor/strategy_one_for_one.go +++ b/actor/strategy_one_for_one.go @@ -50,7 +50,6 @@ func (strategy *oneForOne) HandleFailure(supervisor Supervisor, child *PID, rs * } func (strategy *oneForOne) shouldStop(rs *RestartStatistics) bool { - // supervisor says this child may not restart if strategy.maxNrOfRetries == 0 { return true diff --git a/actor/supervision_test.go b/actor/supervision_test.go index eac248bc8..c716ee2f5 100644 --- a/actor/supervision_test.go +++ b/actor/supervision_test.go @@ -72,7 +72,6 @@ func (e *Expector) ExpectMsg(expected interface{}, t *testing.T) { } func (e *Expector) ExpectNoMsg(t *testing.T) { - select { case actual := <-e.C: at := reflect.TypeOf(actual) @@ -82,7 +81,7 @@ func (e *Expector) ExpectNoMsg(t *testing.T) { } } -func TestActorStopsAfterXRestars(t *testing.T) { +func TestActorStopsAfterXRestarts(t *testing.T) { m, e := NewObserver() props := PropsFromProducer(func() Actor { return &failingChildActor{} }).WithReceiverMiddleware(m) child := rootContext.Spawn(props) diff --git a/cli/main.go b/cli/main.go index 8c04eb8b4..e8f95338c 100644 --- a/cli/main.go +++ b/cli/main.go @@ -14,7 +14,7 @@ import ( "github.com/AsynkronIT/protoactor-go/actor" "github.com/AsynkronIT/protoactor-go/remote" - proto "github.com/gogo/protobuf/proto" + "github.com/gogo/protobuf/proto" ) // Reference imports to suppress errors if they are not otherwise used. @@ -106,6 +106,7 @@ func main() { } exit: } + func spawnEcho() { echoPID, _ = rootContext.SpawnNamed(actor.PropsFromFunc(func(ctx actor.Context) { switch msg := ctx.Message().(type) { @@ -122,6 +123,7 @@ func spawnEcho() { }), "echo") } + func watch(line string) { parts := strings.SplitN(line, " ", 2) @@ -139,6 +141,7 @@ func watch(line string) { }) } } + func tell(line string) { parts := strings.SplitN(line, " ", 4) diff --git a/cluster/cluster.go b/cluster/cluster.go index 4c76fc852..8b2d51f96 100644 --- a/cluster/cluster.go +++ b/cluster/cluster.go @@ -11,7 +11,7 @@ import ( var cfg *ClusterConfig -var rootContext *actor.RootContext = actor.EmptyRootContext +var rootContext = actor.EmptyRootContext func Start(clusterName, address string, provider ClusterProvider) { StartWithConfig(NewClusterConfig(clusterName, address, provider)) diff --git a/cluster/consul/consul_provider.go b/cluster/consul/consul_provider.go index 93602f623..370133f9d 100644 --- a/cluster/consul/consul_provider.go +++ b/cluster/consul/consul_provider.go @@ -189,7 +189,6 @@ func (p *ConsulProvider) deregisterService() error { } func (p *ConsulProvider) registerMember() error { - txn := api.KVTxnOps{} // register a unique ID for the current process @@ -227,7 +226,6 @@ func (p *ConsulProvider) blockingStatusChange() { } func (p *ConsulProvider) notifyStatuses() { - statuses, meta, err := p.client.Health().Service(p.clusterName, "", false, &api.QueryOptions{ WaitIndex: p.index, WaitTime: p.blockingWaitTime, @@ -272,14 +270,13 @@ func (p *ConsulProvider) notifyStatuses() { } // the reason why we want this in a batch and not as individual messages is that // if we have an atomic batch, we can calculate what nodes have left the cluster - // passing events one by one, we can't know if someone left or just havent changed status for a long time + // passing events one by one, we can't know if someone left or just haven't changed status for a long time // publish the current cluster topology onto the event stream eventstream.Publish(res) } func (p *ConsulProvider) MonitorMemberStatusChanges() { - go func() { for !p.shutdown { p.notifyStatuses() diff --git a/cluster/member_list.go b/cluster/member_list.go index e054a5b87..1566d0571 100644 --- a/cluster/member_list.go +++ b/cluster/member_list.go @@ -79,7 +79,6 @@ func (ml *memberListValue) getActivatorMember(kind string) string { } func (ml *memberListValue) updateClusterTopology(m interface{}) { - ml.mutex.Lock() defer ml.mutex.Unlock() @@ -108,7 +107,6 @@ func (ml *memberListValue) updateClusterTopology(m interface{}) { } func (ml *memberListValue) updateAndNotify(new *MemberStatus, old *MemberStatus) { - if new == nil && old == nil { // ignore, not possible return diff --git a/cluster/partition.go b/cluster/partition.go index 96c22adfe..81c771372 100644 --- a/cluster/partition.go +++ b/cluster/partition.go @@ -213,7 +213,6 @@ func (state *partitionActor) terminated(msg *actor.Terminated) { } func (state *partitionActor) memberRejoined(msg *MemberRejoinedEvent, context actor.Context) { - memberAddress := msg.Name() plog.Info("Member rejoined", log.String("kind", state.kind), log.String("name", memberAddress)) @@ -236,7 +235,6 @@ func (state *partitionActor) memberRejoined(msg *MemberRejoinedEvent, context ac } func (state *partitionActor) memberLeft(msg *MemberLeftEvent, context actor.Context) { - memberAddress := msg.Name() plog.Info("Member left", log.String("kind", state.kind), log.String("name", memberAddress)) @@ -291,7 +289,7 @@ func (state *partitionActor) transferOwnership(actorID string, address string, c Pid: pid, Name: actorID, }) - // we can safely delete this entry as the consisntent hash no longer points to us + // we can safely delete this entry as the consistent hash no longer points to us delete(state.partition, actorID) delete(state.keyNameMap, pid.String()) context.Unwatch(pid) diff --git a/cluster/rendezvous.go b/cluster/rendezvous.go index a36c78849..39eb5c06a 100644 --- a/cluster/rendezvous.go +++ b/cluster/rendezvous.go @@ -22,7 +22,6 @@ func NewRendezvous(memberStrategy MemberStrategy) *Rendezvous { // Get returns the node with the highest score for the given key. If this Hash // has no nodes, an empty string is returned. func (r *Rendezvous) GetByRdv(key string) string { - members := r.m.GetAllMembers() l := len(members) diff --git a/cluster/weighted/weighted_round_robin.go b/cluster/weighted/weighted_round_robin.go index 7081f0bb1..cf04fe2a5 100644 --- a/cluster/weighted/weighted_round_robin.go +++ b/cluster/weighted/weighted_round_robin.go @@ -20,7 +20,6 @@ func NewWeightedRoundRobin(memberStrategy cluster.MemberStrategy) *WeightedRound } func (r *WeightedRoundRobin) GetByRoundRobin() string { - members := r.m.GetAllMembers() l := len(members) diff --git a/cluster/weighted/weighted_round_robin_test.go b/cluster/weighted/weighted_round_robin_test.go index 01745d807..788b9805d 100644 --- a/cluster/weighted/weighted_round_robin_test.go +++ b/cluster/weighted/weighted_round_robin_test.go @@ -5,7 +5,6 @@ import "testing" var wrr = NewWeightedRoundRobin(nil) func BenchmarkGCD40(b *testing.B) { - val := []int{4, 4, 8, 6, 12, 30, 50, 150, 124, 124, 52, 66, 68, 168, 190, 244, 690, 400, 120, 520, 4, 4, 8, 6, 12, 30, 50, 150, 124, 124, 52, 66, 68, 168, 190, 244, 690, 400, 120, 520} for n := 0; n < b.N; n++ { @@ -14,7 +13,6 @@ func BenchmarkGCD40(b *testing.B) { } func BenchmarkGCD20(b *testing.B) { - val := []int{4, 4, 8, 6, 12, 30, 50, 150, 124, 124, 52, 66, 68, 168, 190, 244, 690, 400, 120, 520} for n := 0; n < b.N; n++ { @@ -23,7 +21,6 @@ func BenchmarkGCD20(b *testing.B) { } func BenchmarkGCD2(b *testing.B) { - val := []int{4, 520} for n := 0; n < b.N; n++ { diff --git a/examples/cluster-metrics/member/main.go b/examples/cluster-metrics/member/main.go index 4371ff008..43fa9164f 100644 --- a/examples/cluster-metrics/member/main.go +++ b/examples/cluster-metrics/member/main.go @@ -14,10 +14,6 @@ import ( "github.com/AsynkronIT/protoactor-go/remote" ) -const ( - timeout = 1 * time.Second -) - // Logger is message middleware which logs messages before continuing to the next middleware func Logger(next actor.ReceiverFunc) actor.ReceiverFunc { fn := func(context actor.ReceiverContext, env *actor.MessageEnvelope) { diff --git a/examples/cluster-metrics/seed/main.go b/examples/cluster-metrics/seed/main.go index e25edb24b..24fc1d799 100644 --- a/examples/cluster-metrics/seed/main.go +++ b/examples/cluster-metrics/seed/main.go @@ -26,7 +26,6 @@ func Logger(next actor.ReceiverFunc) actor.ReceiverFunc { } func main() { - // this node knows about Hello kind remote.Register("Hello", actor.PropsFromProducer(func() actor.Actor { return &shared.HelloActor{} diff --git a/examples/cluster/member/main.go b/examples/cluster/member/main.go index a24097a6f..13f3e40b8 100644 --- a/examples/cluster/member/main.go +++ b/examples/cluster/member/main.go @@ -13,10 +13,6 @@ import ( "github.com/AsynkronIT/protoactor-go/remote" ) -const ( - timeout = 1 * time.Second -) - func main() { // this node knows about Hello kind remote.Register("Hello", actor.PropsFromProducer(func() actor.Actor { diff --git a/examples/cluster/seed/main.go b/examples/cluster/seed/main.go index 03aa8a954..5c9e25a67 100644 --- a/examples/cluster/seed/main.go +++ b/examples/cluster/seed/main.go @@ -12,7 +12,6 @@ import ( ) func main() { - // this node knows about Hello kind remote.Register("Hello", actor.PropsFromProducer(func() actor.Actor { return &shared.HelloActor{} diff --git a/examples/inprocessbenchmark/main.go b/examples/inprocessbenchmark/main.go index bc0604100..f335c9400 100644 --- a/examples/inprocessbenchmark/main.go +++ b/examples/inprocessbenchmark/main.go @@ -23,8 +23,6 @@ type Start struct { Sender *actor.PID } -// type Started struct{} - type pingActor struct { count int wgStop *sync.WaitGroup diff --git a/examples/receivetimeout/main.go b/examples/receivetimeout/main.go index 13783536f..bc851b440 100644 --- a/examples/receivetimeout/main.go +++ b/examples/receivetimeout/main.go @@ -14,8 +14,7 @@ type NoInfluence string func (NoInfluence) NotInfluenceReceiveTimeout() {} func main() { - - log.Println("Reveive timeout test") + log.Println("Receive timeout test") c := 0 diff --git a/examples/remoteheader/node1/main.go b/examples/remoteheader/node1/main.go index 7b9cfdb8f..bf553e0af 100644 --- a/examples/remoteheader/node1/main.go +++ b/examples/remoteheader/node1/main.go @@ -11,7 +11,6 @@ import ( ) func main() { - remote.Start("127.0.0.1:8081") rootContext := actor.EmptyRootContext diff --git a/examples/remoterouting/server/main.go b/examples/remoterouting/server/main.go index 1f8a38420..d69d1bf0b 100644 --- a/examples/remoterouting/server/main.go +++ b/examples/remoterouting/server/main.go @@ -52,7 +52,6 @@ func newRemote(bind, name string) { } func main() { - runtime.GOMAXPROCS(runtime.NumCPU()) runtime.GC() diff --git a/examples/routing/main.go b/examples/routing/main.go index 822f5969f..4707f86d1 100644 --- a/examples/routing/main.go +++ b/examples/routing/main.go @@ -17,7 +17,6 @@ func (m *myMessage) Hash() string { } func main() { - log.Println("Round robin routing:") rootContext := actor.EmptyRootContext diff --git a/internal/queue/goring/queue.go b/internal/queue/goring/queue.go index 9f1ba473f..1343b85c6 100644 --- a/internal/queue/goring/queue.go +++ b/internal/queue/goring/queue.go @@ -69,7 +69,6 @@ func (q *Queue) Empty() bool { // single consumer func (q *Queue) Pop() (interface{}, bool) { - if q.Empty() { return nil, false } @@ -86,7 +85,6 @@ func (q *Queue) Pop() (interface{}, bool) { } func (q *Queue) PopMany(count int64) ([]interface{}, bool) { - if q.Empty() { return nil, false } diff --git a/mailbox/mailbox.go b/mailbox/mailbox.go index f49851366..0797e9b81 100644 --- a/mailbox/mailbox.go +++ b/mailbox/mailbox.go @@ -22,7 +22,7 @@ type MessageInvoker interface { EscalateFailure(reason interface{}, message interface{}) } -// The mailbox interface is used to enqueue messages to the mailbox +// Mailbox interface is used to enqueue messages to the mailbox type Mailbox interface { PostUserMessage(message interface{}) PostSystemMessage(message interface{}) @@ -80,7 +80,6 @@ func (m *defaultMailbox) schedule() { } func (m *defaultMailbox) processMessages() { - process: m.run() diff --git a/mailbox/mailbox_test.go b/mailbox/mailbox_test.go index da41e8891..42739aea9 100644 --- a/mailbox/mailbox_test.go +++ b/mailbox/mailbox_test.go @@ -28,6 +28,7 @@ func (i *invoker) InvokeSystemMessage(interface{}) { log.Println("Unexpected data..") } } + func (i *invoker) InvokeUserMessage(interface{}) { i.count++ if i.count == i.max { @@ -37,6 +38,7 @@ func (i *invoker) InvokeUserMessage(interface{}) { log.Println("Unexpected data..") } } + func (*invoker) EscalateFailure(reason interface{}, message interface{}) {} func TestUnboundedLockfreeMailboxUsermessageConsistency(t *testing.T) { diff --git a/persistence/persistence_provider.go b/persistence/persistence_provider.go index 6d07e70fe..c2346de5c 100644 --- a/persistence/persistence_provider.go +++ b/persistence/persistence_provider.go @@ -1,7 +1,7 @@ package persistence import ( - proto "github.com/golang/protobuf/proto" + "github.com/golang/protobuf/proto" ) // Provider is the abstraction used for persistence diff --git a/persistence/plugin.go b/persistence/plugin.go index bb5d0933b..b71dd9e69 100644 --- a/persistence/plugin.go +++ b/persistence/plugin.go @@ -2,7 +2,7 @@ package persistence import ( "github.com/AsynkronIT/protoactor-go/actor" - proto "github.com/golang/protobuf/proto" + "github.com/golang/protobuf/proto" ) type persistent interface { @@ -32,6 +32,7 @@ func (mixin *Mixin) Recovering() bool { func (mixin *Mixin) Name() string { return mixin.name } + func (mixin *Mixin) PersistReceive(message proto.Message) { mixin.providerState.PersistEvent(mixin.Name(), mixin.eventIndex, message) if mixin.eventIndex%mixin.providerState.GetSnapshotInterval() == 0 { diff --git a/remote/activator_actor.go b/remote/activator_actor.go index f5613df56..8880bd2fd 100644 --- a/remote/activator_actor.go +++ b/remote/activator_actor.go @@ -112,7 +112,7 @@ func (*activator) Receive(context actor.Context) { StatusCode: ResponseStatusCodeERROR.ToInt32(), } context.Respond(response) - panic(fmt.Errorf("No Props found for kind %s", msg.Kind)) + panic(fmt.Errorf("no Props found for kind %s", msg.Kind)) } name := msg.Name diff --git a/remote/doc.go b/remote/doc.go index 96961daf4..191cf15ae 100644 --- a/remote/doc.go +++ b/remote/doc.go @@ -1,6 +1,4 @@ /* Package remote provides access to actors across a network or other I/O connection. - - */ package remote diff --git a/remote/proto_serializer.go b/remote/proto_serializer.go index 223d0208e..31e4a6db1 100644 --- a/remote/proto_serializer.go +++ b/remote/proto_serializer.go @@ -28,7 +28,7 @@ func (protoSerializer) Serialize(msg interface{}) ([]byte, error) { func (protoSerializer) Deserialize(typeName string, bytes []byte) (interface{}, error) { protoType := proto.MessageType(typeName) if protoType == nil { - return nil, fmt.Errorf("Unknown message type %v", typeName) + return nil, fmt.Errorf("unknown message type %v", typeName) } t := protoType.Elem() diff --git a/router/consistent_hash_router.go b/router/consistent_hash_router.go index 09727f3ef..5ec035151 100644 --- a/router/consistent_hash_router.go +++ b/router/consistent_hash_router.go @@ -67,7 +67,7 @@ func (state *consistentHashRouterState) RouteMessage(message interface{}) { if routee, ok := hmc.routeeMap[node]; ok { rootContext.Send(routee, message) } else { - log.Println("[ROUTING] Consisten router failed to resolve node", node) + log.Println("[ROUTING] Consistent router failed to resolve node", node) } default: log.Println("[ROUTING] Message must implement router.Hasher", msg) diff --git a/router/consistent_hash_router_test.go b/router/consistent_hash_router_test.go index 592498945..9ea90ccf5 100644 --- a/router/consistent_hash_router_test.go +++ b/router/consistent_hash_router_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - actor "github.com/AsynkronIT/protoactor-go/actor" + "github.com/AsynkronIT/protoactor-go/actor" "github.com/AsynkronIT/protoactor-go/router" ) @@ -14,6 +14,7 @@ type myMessage struct { i int pid *actor.PID } + type getRoutees struct { pid *actor.PID } @@ -39,6 +40,7 @@ func (state *routerActor) Receive(context actor.Context) { wait.Done() } } + func (state *tellerActor) Receive(context actor.Context) { switch msg := context.Message().(type) { case *myMessage: @@ -56,13 +58,13 @@ func (state *managerActor) Receive(context actor.Context) { state.set = msg.PIDs for i, v := range state.set { if i%2 == 0 { - context.Send(state.rpid, &router.RemoveRoutee{v}) + context.Send(state.rpid, &router.RemoveRoutee{PID: v}) // log.Println(v) } else { props := actor.PropsFromProducer(func() actor.Actor { return &routerActor{} }) pid := context.Spawn(props) - context.Send(state.rpid, &router.AddRoutee{pid}) + context.Send(state.rpid, &router.AddRoutee{PID: pid}) // log.Println(v) } }