meAmidos / gopactor

Testing tools for ProtoActor in Go
MIT License
14 stars 3 forks source link

Installation challenges #1

Closed Tochemey closed 7 years ago

Tochemey commented 7 years ago

Hello, When I tried to install it using the following command:

go get github.com/meAmidos/gopactor

I got the following message:

# github.com/meamidos/gopactor/catcher
Work/Go/src/github.com/meamidos/gopactor/catcher/middleware.go:44: cannot use func literal (type func(actor.Context, *actor.PID, actor.MessageEnvelope)) as type actor.SenderFunc in return argument
Work/Go/src/github.com/meamidos/gopactor/catcher/middleware.go:46: cannot use env (type actor.MessageEnvelope) as type *actor.MessageEnvelope in argument to next

I maybe doing something wrong.

meAmidos commented 7 years ago

Thank you for reporting it.

I suspect it can be related to some changes in the Protoactor itself. I will be able to look into it after August 10, when I return from vacations. However, feel free to investigate what is the real cause of the problem and let me know if you find something.

Tochemey commented 7 years ago

Thanks to the protoactor guys I am able to fix the issue:

func (catcher *Catcher) outboundMiddleware(next actor.SenderFunc) actor.SenderFunc {
    return func(ctx actor.Context, target *actor.PID, env *actor.MessageEnvelope) {
        catcher.processOutboundMessage(ctx, target, env)
        next(ctx, target, env)
    }
    /*  return func(ctx actor.Context, target *actor.PID, env actor.MessageEnvelope) {
        catcher.processOutboundMessage(ctx, target, &env)
        next(ctx, target, &env)
    }*/
}

func (catcher *Catcher) processOutboundMessage(ctx actor.Context, target *actor.PID, env *actor.MessageEnvelope) {
    // TODO: Is there a difference between using ctx.Message() and env.Message?
    message := env.Message

    if !isSystemMessage(message) {
        catcher.ChUserOutbound <- &Envelope{
            Sender:  ctx.Self(),
            Target:  target,
            Message: message,
        }
    }
}
Tochemey commented 7 years ago

So far I worked as expected. However I am facing some timeout issue while sending and receiving messages. When I run it I could see that the message has been handled as expected and response has been sent but there is a timeout issue.