Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TT-10277] There is no timeout in the gRPC plugin coprocess #5543

Open
cuongtd1301 opened this issue Sep 8, 2023 · 1 comment
Open

[TT-10277] There is no timeout in the gRPC plugin coprocess #5543

cuongtd1301 opened this issue Sep 8, 2023 · 1 comment

Comments

@cuongtd1301
Copy link

Is your feature request related to a problem? Please describe.
When using gRPC plugins, there's no way to specify a timeout. I set the processing time of the plugin too long (over 2 minutes), there will be no response returned even though the gateway has completed the execution.

Describe the solution you'd like

  • MiddlewareDefinition: add timeout field (second)
{
    "name" : "DemoPre",
    "timeout": 10
}
  • CoProcessMiddleware: add timeout field
type CoProcessMiddleware struct {
 BaseMiddleware
 HookType         coprocess.HookType
 HookName         string
 MiddlewareDriver apidef.MiddlewareDriver
 RawBodyOnly      bool
 Timeout          int

 successHandler *SuccessHandler
}
  • Dispatcher: add context.Context paramter
type Dispatcher interface {
 // Dispatch takes and returns a pointer to a CoProcessMessage struct, see coprocess/api.h for details. This is used by CP bindings.
 Dispatch(context.Context, *Object) (*Object, error)
 ...

GRPCDispatcher (and PythonDispatcher) implement Dispatch, add ctx parameter

// Dispatch takes a CoProcessMessage and sends it to the CP.
func (d *GRPCDispatcher) Dispatch(ctx context.Context, object *coprocess.Object) (*coprocess.Object, error) {
 return grpcClient.Dispatch(ctx, object)
}
@andyo-tyk
Copy link
Contributor

Hi @cuongtd1301,

I'm sorry for the slow acknowledgement here - thank you for your suggestion and PR. It seems like a reasonable capability to add to Tyk, we'll take a look at this and will let you know if and when we can add it to the product.

Thanks again for your contribution!

@andyo-tyk andyo-tyk changed the title There is no timeout in the gRPC plugin coprocess [TT-10277] There is no timeout in the gRPC plugin coprocess Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants