asynkron / protoactor-go

Proto Actor - Ultra fast distributed actors for Go, C# and Java/Kotlin
http://proto.actor
Apache License 2.0
5.09k stars 523 forks source link

[cluster] NotInfluenceReceiveTimeout in the Cluster ? #315

Open otherview opened 5 years ago

otherview commented 5 years ago

Hi !

Wondering if there's a way to implement a message that doesn't influence the grain timeout ?

Similar to NotInfluenceReceiveTimeout?

potterdai commented 5 years ago

@otherview Hi, thank you for asking! = ) I think you should just add NotInfluenceReceiveTimeout function to that message type, and should be OK. Since NotInfluenceReceiveTimeout is an interface, as long as your object matched that interface requirement, the message won’t affect timeout.

otherview commented 5 years ago

hmm.. to be honest I thought it wouldn't work and didn't try it !

Let me give it a go tomorrow and I'll post some results!

Thanks @PotterDai !

otherview commented 5 years ago

Was looking more into this.

The magic happens here: https://github.com/AsynkronIT/protoactor-go/blob/f81631684a62bfb0a9f3bf4170f4802d43174501/actor/actor_context.go#L420-L428

And it works fine for actors because we usually define the messages that we're passing around.

However in the cluster, we gRPC the message into a structure https://github.com/AsynkronIT/protoactor-go/blob/3a8d8611c9ecd2ed98b696b18b311185aff079ac/cluster/protos.proto#L14-L17

All the messages we pass along in the cluster will have that type. Maybe if we add something to the cluster.GrainRequest and check it in the _, influenceTimeout = md.(NotInfluenceReceiveTimeout)

That would work ?

potterdai commented 5 years ago

@otherview Hmm, I think you are right! Sorry that I mislead you in previous post! This feature is not supported in Cluster it seems. This is going to be tricky since adding only this parameter to GrainRequest seems to be a bit overwhelming...

potterdai commented 5 years ago

@otherview hmmm this is going to need some change. For now I came to the same path like you

message GrainRequest {
    int32 request_type = 1;
    int32 method_index = 2;
    bytes message_data = 3;
}

And add

func (*GrainRequest) NotInfluenceReceiveTimeout() bool {
    //will return true/false according to `request_type` 
}