topfreegames / pitaya

Scalable game server framework with clustering support and client libraries for iOS, Android, Unity and others through the C SDK.
MIT License
2.31k stars 473 forks source link

allow to customize the timeout of rpc #375

Closed bruce1125 closed 4 months ago

bruce1125 commented 9 months ago

To customize the timeout value, the only thing we need to do is just like the code below before RPC call and then use the ctx as the context argument: ctx := pcontext.AddToPropagateCtx(context.Background(), constants.RequestTimeout, (60 * time.Second).String())

rsafonseca commented 6 months ago

Hey @bruce1125 , what are you trying to achieve exactly? The timeout for the RPCs can already be configured via "pitaya.cluster.rpc.client.grpc.requesttimeout" or "pitaya.cluster.rpc.client.nats.requesttimeout" config options :)

bruce1125 commented 6 months ago

Hey @bruce1125 , what are you trying to achieve exactly? The timeout for the RPCs can already be configured via "pitaya.cluster.rpc.client.grpc.requesttimeout" or "pitaya.cluster.rpc.client.nats.requesttimeout" config options :)

Thank you for review. Although we can configure the grpc/nats timeout, that is global. It can cover most of cases excluding some time-consuming operations, such as getting an external API response, collecting a cpu/memory snapshot, etc. And I don't want to set the timeout value only for these issues..

felipejfc commented 4 months ago

@bruce1125 would appreciate if you could update the docs later covering this new capability

bruce1125 commented 4 months ago

@bruce1125 would appreciate if you could update the docs later covering this new capability

@felipejfc It's my pleasure,I've created a new PR. I am not sure is it OK,and I am realy happy to discuss with you guys if there is any problem.