|
@@ -35,9 +35,17 @@ func (app *App) Endpoint(config *app.Config) func(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
func (app *App) EndpointHandler(ctx *gin.Context, hookId string, maxExecutionTime time.Duration, path string) {
|
|
|
- endpoint, err := db.GetOne[models.Endpoint](
|
|
|
- db.Equal("hook_id", hookId),
|
|
|
- )
|
|
|
+ endpoint, err := db.GetCache[models.Endpoint](&db.GetCachePayload[models.Endpoint]{
|
|
|
+ Getter: func() (*models.Endpoint, error) {
|
|
|
+ v, err := db.GetOne[models.Endpoint](
|
|
|
+ db.Equal("hook_id", hookId),
|
|
|
+ )
|
|
|
+ return &v, err
|
|
|
+ },
|
|
|
+ CacheKey: []db.KeyValuePair{
|
|
|
+ {Key: "hook_id", Val: hookId},
|
|
|
+ },
|
|
|
+ })
|
|
|
if err == db.ErrDatabaseNotFound {
|
|
|
ctx.JSON(404, exception.BadRequestError(errors.New("endpoint not found")).ToResponse())
|
|
|
return
|
|
@@ -50,10 +58,20 @@ func (app *App) EndpointHandler(ctx *gin.Context, hookId string, maxExecutionTim
|
|
|
}
|
|
|
|
|
|
// get plugin installation
|
|
|
- pluginInstallation, err := db.GetOne[models.PluginInstallation](
|
|
|
- db.Equal("plugin_id", endpoint.PluginID),
|
|
|
- db.Equal("tenant_id", endpoint.TenantID),
|
|
|
- )
|
|
|
+ pluginInstallation, err := db.GetCache[models.PluginInstallation](
|
|
|
+ &db.GetCachePayload[models.PluginInstallation]{
|
|
|
+ Getter: func() (*models.PluginInstallation, error) {
|
|
|
+ v, err := db.GetOne[models.PluginInstallation](
|
|
|
+ db.Equal("plugin_id", endpoint.PluginID),
|
|
|
+ db.Equal("tenant_id", endpoint.TenantID),
|
|
|
+ )
|
|
|
+ return &v, err
|
|
|
+ },
|
|
|
+ CacheKey: []db.KeyValuePair{
|
|
|
+ {Key: "plugin_id", Val: endpoint.PluginID},
|
|
|
+ {Key: "tenant_id", Val: endpoint.TenantID},
|
|
|
+ },
|
|
|
+ })
|
|
|
if err != nil {
|
|
|
ctx.JSON(404, exception.BadRequestError(errors.New("plugin installation not found")).ToResponse())
|
|
|
return
|
|
@@ -73,6 +91,6 @@ func (app *App) EndpointHandler(ctx *gin.Context, hookId string, maxExecutionTim
|
|
|
if ok, originalError := app.cluster.IsPluginOnCurrentNode(pluginUniqueIdentifier); !ok {
|
|
|
app.redirectPluginInvokeByPluginIdentifier(ctx, pluginUniqueIdentifier, originalError)
|
|
|
} else {
|
|
|
- service.Endpoint(ctx, &endpoint, &pluginInstallation, maxExecutionTime, path)
|
|
|
+ service.Endpoint(ctx, endpoint, pluginInstallation, maxExecutionTime, path)
|
|
|
}
|
|
|
}
|