Skip to content

Commit

Permalink
fix: aws timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeuoly committed Aug 23, 2024
1 parent 32d0160 commit bbc84bc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 1 addition & 3 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package main

import (
"time"

"github.com/joho/godotenv"
"github.com/kelseyhightower/envconfig"
"github.com/langgenius/dify-plugin-daemon/internal/server"
Expand Down Expand Up @@ -43,7 +41,7 @@ func setDefault(config *app.Config) {
setDefaultInt(&config.PluginRemoteInstallServerEventLoopNums, 8)
setDefaultInt(&config.PluginRemoteInstallingMaxConn, 128)
setDefaultInt(&config.MaxPluginPackageSize, 52428800)
setDefaultInt(&config.MaxAWSLambdaTransactionTimeout, time.Second*150)
setDefaultInt(&config.MaxAWSLambdaTransactionTimeout, 150)
setDefaultBool(&config.PluginRemoteInstallingEnabled, true)
setDefaultBool(&config.PluginWebhookEnabled, true)
setDefaultString(&config.DBSslMode, "disable")
Expand Down
5 changes: 4 additions & 1 deletion internal/server/http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"net/http"
"time"

"github.com/gin-gonic/gin"
"github.com/langgenius/dify-plugin-daemon/internal/core/plugin_daemon/backwards_invocation/transaction"
Expand Down Expand Up @@ -76,7 +77,9 @@ func (app *App) webhookGroup(group *gin.RouterGroup, config *app.Config) {

func (appRef *App) awsLambdaTransactionGroup(group *gin.RouterGroup, config *app.Config) {
if config.Platform == app.PLATFORM_AWS_LAMBDA {
appRef.aws_transaction_handler = transaction.NewAWSTransactionHandler(config.MaxAWSLambdaTransactionTimeout)
appRef.aws_transaction_handler = transaction.NewAWSTransactionHandler(
time.Duration(config.MaxAWSLambdaTransactionTimeout) * time.Second,
)
group.POST(
"/transaction",
appRef.RedirectAWSLambdaTransaction,
Expand Down
3 changes: 1 addition & 2 deletions internal/types/app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package app

import (
"fmt"
"time"

"github.com/go-playground/validator/v10"
)
Expand Down Expand Up @@ -51,7 +50,7 @@ type Config struct {

MaxPluginPackageSize int64 `envconfig:"MAX_PLUGIN_PACKAGE_SIZE" validate:"required"`

MaxAWSLambdaTransactionTimeout time.Duration `envconfig:"MAX_AWS_LAMBDA_TRANSACTION_TIMEOUT"`
MaxAWSLambdaTransactionTimeout int `envconfig:"MAX_AWS_LAMBDA_TRANSACTION_TIMEOUT"`
}

func (c *Config) Validate() error {
Expand Down

0 comments on commit bbc84bc

Please sign in to comment.