From 8796edad8c064cd2e0945224c0b63c66e8f73bbd Mon Sep 17 00:00:00 2001 From: Yeuoly Date: Mon, 6 Jan 2025 14:16:29 +0800 Subject: [PATCH] refactor: confused code structure --- internal/cluster/plugin_test.go | 4 +- .../core/plugin_manager/aws_manager/init.go | 1 - .../core/plugin_manager/basic_manager/type.go | 13 ------ .../plugin_manager/basic_runtime/checksum.go | 42 +++++++++++++++++++ .../media.go} | 15 ++++++- .../checksum.go | 2 +- .../codec.go | 2 +- .../codec_test.go | 2 +- .../connection_key.go | 2 +- .../connection_key_test.go | 2 +- .../environment.go | 2 +- .../hooks.go | 10 ++--- .../io.go | 4 +- .../register.go | 2 +- .../run.go | 4 +- .../server.go | 8 ++-- .../server_test.go | 6 +-- .../type.go | 6 +-- .../plugin_manager/install_to_serverless.go | 2 +- internal/core/plugin_manager/launcher.go | 15 ++++--- .../plugin_manager/local_manager/tester.go | 1 - .../environment.go | 2 +- .../environment_python.go | 2 +- .../{local_manager => local_runtime}/io.go | 2 +- .../{local_manager => local_runtime}/run.go | 4 +- .../stdio_handle.go | 2 +- .../stdio_store.go | 2 +- .../plugin_manager/local_runtime/tester.go | 1 + .../{local_manager => local_runtime}/type.go | 6 +-- internal/core/plugin_manager/manager.go | 20 ++++----- .../assets.go | 2 +- .../assets_bucket.go | 2 +- .../installed_bucket.go | 2 +- .../package_bucket.go | 2 +- .../positive_manager/environment.go | 30 ------------- .../plugin_manager/positive_manager/types.go | 16 ------- internal/core/plugin_manager/serverless.go | 13 +++--- .../client.go | 0 .../connector.go | 0 .../packager.go | 2 +- .../packager_test.go | 0 .../packager_test_plugin/main.py | 0 .../packager_test_plugin/manifest.yaml | 0 .../packager_test_plugin/provider/jina.yaml | 0 .../packager_test_plugin/requirements.txt | 0 .../upload.go | 0 .../dockerfile/build.go | 0 .../dockerfile/build_test.go | 0 .../dockerfile/python.go | 0 .../dockerfile/python312.dockerfile | 0 .../environment.go | 2 +- .../plugin_manager/serverless_runtime/init.go | 1 + .../{aws_manager => serverless_runtime}/io.go | 4 +- .../run.go | 2 +- .../type.go | 6 +-- internal/core/plugin_manager/tester.go | 4 +- internal/core/plugin_manager/watcher.go | 8 ++-- internal/core/plugin_manager/watcher_test.go | 4 +- internal/service/debugging.go | 4 +- 59 files changed, 141 insertions(+), 149 deletions(-) delete mode 100644 internal/core/plugin_manager/aws_manager/init.go delete mode 100644 internal/core/plugin_manager/basic_manager/type.go create mode 100644 internal/core/plugin_manager/basic_runtime/checksum.go rename internal/core/plugin_manager/{basic_manager/remap_assets.go => basic_runtime/media.go} (50%) rename internal/core/plugin_manager/{remote_manager => debugging_runtime}/checksum.go (95%) rename internal/core/plugin_manager/{remote_manager => debugging_runtime}/codec.go (97%) rename internal/core/plugin_manager/{remote_manager => debugging_runtime}/codec_test.go (97%) rename internal/core/plugin_manager/{remote_manager => debugging_runtime}/connection_key.go (99%) rename internal/core/plugin_manager/{remote_manager => debugging_runtime}/connection_key_test.go (97%) rename internal/core/plugin_manager/{remote_manager => debugging_runtime}/environment.go (97%) rename internal/core/plugin_manager/{remote_manager => debugging_runtime}/hooks.go (98%) rename internal/core/plugin_manager/{remote_manager => debugging_runtime}/io.go (96%) rename internal/core/plugin_manager/{remote_manager => debugging_runtime}/register.go (95%) rename internal/core/plugin_manager/{remote_manager => debugging_runtime}/run.go (97%) rename internal/core/plugin_manager/{remote_manager => debugging_runtime}/server.go (93%) rename internal/core/plugin_manager/{remote_manager => debugging_runtime}/server_test.go (98%) rename internal/core/plugin_manager/{remote_manager => debugging_runtime}/type.go (98%) delete mode 100644 internal/core/plugin_manager/local_manager/tester.go rename internal/core/plugin_manager/{local_manager => local_runtime}/environment.go (97%) rename internal/core/plugin_manager/{local_manager => local_runtime}/environment_python.go (99%) rename internal/core/plugin_manager/{local_manager => local_runtime}/io.go (97%) rename internal/core/plugin_manager/{local_manager => local_runtime}/run.go (98%) rename internal/core/plugin_manager/{local_manager => local_runtime}/stdio_handle.go (99%) rename internal/core/plugin_manager/{local_manager => local_runtime}/stdio_store.go (98%) create mode 100644 internal/core/plugin_manager/local_runtime/tester.go rename internal/core/plugin_manager/{local_manager => local_runtime}/type.go (90%) rename internal/core/plugin_manager/{media_manager => media_transport}/assets.go (99%) rename internal/core/plugin_manager/{media_manager => media_transport}/assets_bucket.go (98%) rename internal/core/plugin_manager/{media_manager => media_transport}/installed_bucket.go (98%) rename internal/core/plugin_manager/{media_manager => media_transport}/package_bucket.go (96%) delete mode 100644 internal/core/plugin_manager/positive_manager/environment.go delete mode 100644 internal/core/plugin_manager/positive_manager/types.go rename internal/core/plugin_manager/{serverless => serverless_connector}/client.go (100%) rename internal/core/plugin_manager/{serverless => serverless_connector}/connector.go (100%) rename internal/core/plugin_manager/{serverless => serverless_connector}/packager.go (98%) rename internal/core/plugin_manager/{serverless => serverless_connector}/packager_test.go (100%) rename internal/core/plugin_manager/{serverless => serverless_connector}/packager_test_plugin/main.py (100%) rename internal/core/plugin_manager/{serverless => serverless_connector}/packager_test_plugin/manifest.yaml (100%) rename internal/core/plugin_manager/{serverless => serverless_connector}/packager_test_plugin/provider/jina.yaml (100%) rename internal/core/plugin_manager/{serverless => serverless_connector}/packager_test_plugin/requirements.txt (100%) rename internal/core/plugin_manager/{serverless => serverless_connector}/upload.go (100%) rename internal/core/plugin_manager/{aws_manager => serverless_runtime}/dockerfile/build.go (100%) rename internal/core/plugin_manager/{aws_manager => serverless_runtime}/dockerfile/build_test.go (100%) rename internal/core/plugin_manager/{aws_manager => serverless_runtime}/dockerfile/python.go (100%) rename internal/core/plugin_manager/{aws_manager => serverless_runtime}/dockerfile/python312.dockerfile (100%) rename internal/core/plugin_manager/{aws_manager => serverless_runtime}/environment.go (96%) create mode 100644 internal/core/plugin_manager/serverless_runtime/init.go rename internal/core/plugin_manager/{aws_manager => serverless_runtime}/io.go (98%) rename internal/core/plugin_manager/{aws_manager => serverless_runtime}/run.go (92%) rename internal/core/plugin_manager/{aws_manager => serverless_runtime}/type.go (87%) diff --git a/internal/cluster/plugin_test.go b/internal/cluster/plugin_test.go index 4888faa..7ab0d1e 100644 --- a/internal/cluster/plugin_test.go +++ b/internal/cluster/plugin_test.go @@ -5,7 +5,7 @@ import ( "time" "github.com/google/uuid" - "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/positive_manager" + "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/basic_runtime" "github.com/langgenius/dify-plugin-daemon/internal/types/entities" "github.com/langgenius/dify-plugin-daemon/internal/types/entities/manifest_entities" "github.com/langgenius/dify-plugin-daemon/internal/types/entities/plugin_entities" @@ -13,7 +13,7 @@ import ( type fakePlugin struct { plugin_entities.PluginRuntime - positive_manager.PositivePluginRuntime + basic_runtime.BasicChecksum } func (r *fakePlugin) InitEnvironment() error { diff --git a/internal/core/plugin_manager/aws_manager/init.go b/internal/core/plugin_manager/aws_manager/init.go deleted file mode 100644 index 777dcd4..0000000 --- a/internal/core/plugin_manager/aws_manager/init.go +++ /dev/null @@ -1 +0,0 @@ -package aws_manager diff --git a/internal/core/plugin_manager/basic_manager/type.go b/internal/core/plugin_manager/basic_manager/type.go deleted file mode 100644 index 2915ef2..0000000 --- a/internal/core/plugin_manager/basic_manager/type.go +++ /dev/null @@ -1,13 +0,0 @@ -package basic_manager - -import "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/media_manager" - -type BasicPluginRuntime struct { - mediaManager *media_manager.MediaBucket - - assetsIds []string -} - -func NewBasicPluginRuntime(mediaManager *media_manager.MediaBucket) BasicPluginRuntime { - return BasicPluginRuntime{mediaManager: mediaManager} -} diff --git a/internal/core/plugin_manager/basic_runtime/checksum.go b/internal/core/plugin_manager/basic_runtime/checksum.go new file mode 100644 index 0000000..c27dea0 --- /dev/null +++ b/internal/core/plugin_manager/basic_runtime/checksum.go @@ -0,0 +1,42 @@ +package basic_runtime + +import ( + "os" + + "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_packager/decoder" +) + +type BasicChecksum struct { + MediaTransport + + WorkingPath string + // plugin decoder used to manage the plugin + Decoder decoder.PluginDecoder + + InnerChecksum string +} + +func (r *BasicChecksum) calculateChecksum() (string, error) { + checksum, err := r.Decoder.Checksum() + if err != nil { + return "", err + } + + return checksum, nil +} + +func (r *BasicChecksum) Checksum() (string, error) { + if r.InnerChecksum == "" { + checksum, err := r.calculateChecksum() + if err != nil { + return "", err + } + r.InnerChecksum = checksum + } + + return r.InnerChecksum, nil +} + +func (r *BasicChecksum) Cleanup() { + os.RemoveAll(r.WorkingPath) +} diff --git a/internal/core/plugin_manager/basic_manager/remap_assets.go b/internal/core/plugin_manager/basic_runtime/media.go similarity index 50% rename from internal/core/plugin_manager/basic_manager/remap_assets.go rename to internal/core/plugin_manager/basic_runtime/media.go index 06d5038..a718867 100644 --- a/internal/core/plugin_manager/basic_manager/remap_assets.go +++ b/internal/core/plugin_manager/basic_runtime/media.go @@ -1,11 +1,18 @@ -package basic_manager +package basic_runtime import ( + "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/media_transport" "github.com/langgenius/dify-plugin-daemon/internal/types/entities/plugin_entities" ) +type MediaTransport struct { + mediaManager *media_transport.MediaBucket + + assetsIds []string +} + // RemapAssets will take the assets and remap them to a media id -func (r *BasicPluginRuntime) RemapAssets( +func (r *MediaTransport) RemapAssets( declaration *plugin_entities.PluginDeclaration, assets map[string][]byte, ) error { @@ -17,3 +24,7 @@ func (r *BasicPluginRuntime) RemapAssets( r.assetsIds = assetsIds return nil } + +func NewMediaTransport(mediaManager *media_transport.MediaBucket) MediaTransport { + return MediaTransport{mediaManager: mediaManager} +} diff --git a/internal/core/plugin_manager/remote_manager/checksum.go b/internal/core/plugin_manager/debugging_runtime/checksum.go similarity index 95% rename from internal/core/plugin_manager/remote_manager/checksum.go rename to internal/core/plugin_manager/debugging_runtime/checksum.go index 67c009a..835a9d6 100644 --- a/internal/core/plugin_manager/remote_manager/checksum.go +++ b/internal/core/plugin_manager/debugging_runtime/checksum.go @@ -1,4 +1,4 @@ -package remote_manager +package debugging_runtime import ( "bytes" diff --git a/internal/core/plugin_manager/remote_manager/codec.go b/internal/core/plugin_manager/debugging_runtime/codec.go similarity index 97% rename from internal/core/plugin_manager/remote_manager/codec.go rename to internal/core/plugin_manager/debugging_runtime/codec.go index 92dc106..d499662 100644 --- a/internal/core/plugin_manager/remote_manager/codec.go +++ b/internal/core/plugin_manager/debugging_runtime/codec.go @@ -1,4 +1,4 @@ -package remote_manager +package debugging_runtime import ( "bytes" diff --git a/internal/core/plugin_manager/remote_manager/codec_test.go b/internal/core/plugin_manager/debugging_runtime/codec_test.go similarity index 97% rename from internal/core/plugin_manager/remote_manager/codec_test.go rename to internal/core/plugin_manager/debugging_runtime/codec_test.go index 63f9f53..ecde12f 100644 --- a/internal/core/plugin_manager/remote_manager/codec_test.go +++ b/internal/core/plugin_manager/debugging_runtime/codec_test.go @@ -1,4 +1,4 @@ -package remote_manager +package debugging_runtime import ( "testing" diff --git a/internal/core/plugin_manager/remote_manager/connection_key.go b/internal/core/plugin_manager/debugging_runtime/connection_key.go similarity index 99% rename from internal/core/plugin_manager/remote_manager/connection_key.go rename to internal/core/plugin_manager/debugging_runtime/connection_key.go index c3379f2..3d11278 100644 --- a/internal/core/plugin_manager/remote_manager/connection_key.go +++ b/internal/core/plugin_manager/debugging_runtime/connection_key.go @@ -1,4 +1,4 @@ -package remote_manager +package debugging_runtime import ( "strings" diff --git a/internal/core/plugin_manager/remote_manager/connection_key_test.go b/internal/core/plugin_manager/debugging_runtime/connection_key_test.go similarity index 97% rename from internal/core/plugin_manager/remote_manager/connection_key_test.go rename to internal/core/plugin_manager/debugging_runtime/connection_key_test.go index 6aa6ff3..08cb0bf 100644 --- a/internal/core/plugin_manager/remote_manager/connection_key_test.go +++ b/internal/core/plugin_manager/debugging_runtime/connection_key_test.go @@ -1,4 +1,4 @@ -package remote_manager +package debugging_runtime import ( "testing" diff --git a/internal/core/plugin_manager/remote_manager/environment.go b/internal/core/plugin_manager/debugging_runtime/environment.go similarity index 97% rename from internal/core/plugin_manager/remote_manager/environment.go rename to internal/core/plugin_manager/debugging_runtime/environment.go index 046ca1f..7941be9 100644 --- a/internal/core/plugin_manager/remote_manager/environment.go +++ b/internal/core/plugin_manager/debugging_runtime/environment.go @@ -1,4 +1,4 @@ -package remote_manager +package debugging_runtime import ( "fmt" diff --git a/internal/core/plugin_manager/remote_manager/hooks.go b/internal/core/plugin_manager/debugging_runtime/hooks.go similarity index 98% rename from internal/core/plugin_manager/remote_manager/hooks.go rename to internal/core/plugin_manager/debugging_runtime/hooks.go index 06e21f4..196cff5 100644 --- a/internal/core/plugin_manager/remote_manager/hooks.go +++ b/internal/core/plugin_manager/debugging_runtime/hooks.go @@ -1,4 +1,4 @@ -package remote_manager +package debugging_runtime import ( "bytes" @@ -8,8 +8,8 @@ import ( "sync/atomic" "time" - "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/basic_manager" - "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/media_manager" + "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/basic_runtime" + "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/media_transport" "github.com/langgenius/dify-plugin-daemon/internal/types/entities/plugin_entities" "github.com/langgenius/dify-plugin-daemon/internal/utils/cache" "github.com/langgenius/dify-plugin-daemon/internal/utils/log" @@ -29,7 +29,7 @@ type DifyServer struct { engine gnet.Engine - mediaManager *media_manager.MediaBucket + mediaManager *media_transport.MediaBucket // listening address addr string @@ -62,7 +62,7 @@ func (s *DifyServer) OnOpen(c gnet.Conn) (out []byte, action gnet.Action) { // new plugin connected c.SetContext(&codec{}) runtime := &RemotePluginRuntime{ - BasicPluginRuntime: basic_manager.NewBasicPluginRuntime( + MediaTransport: basic_runtime.NewMediaTransport( s.mediaManager, ), diff --git a/internal/core/plugin_manager/remote_manager/io.go b/internal/core/plugin_manager/debugging_runtime/io.go similarity index 96% rename from internal/core/plugin_manager/remote_manager/io.go rename to internal/core/plugin_manager/debugging_runtime/io.go index bcc4a3d..8337ab0 100644 --- a/internal/core/plugin_manager/remote_manager/io.go +++ b/internal/core/plugin_manager/debugging_runtime/io.go @@ -1,4 +1,4 @@ -package remote_manager +package debugging_runtime import ( "encoding/json" @@ -17,7 +17,7 @@ func (r *RemotePluginRuntime) Listen(session_id string) *entities.Broadcast[plug listener.OnClose(func() { // execute in new goroutine to avoid deadlock routine.Submit(map[string]string{ - "module": "remote_manager", + "module": "debugging_runtime", "method": "removeMessageCallbackHandler", }, func() { r.removeMessageCallbackHandler(session_id) diff --git a/internal/core/plugin_manager/remote_manager/register.go b/internal/core/plugin_manager/debugging_runtime/register.go similarity index 95% rename from internal/core/plugin_manager/remote_manager/register.go rename to internal/core/plugin_manager/debugging_runtime/register.go index b879db3..21a824a 100644 --- a/internal/core/plugin_manager/remote_manager/register.go +++ b/internal/core/plugin_manager/debugging_runtime/register.go @@ -1,4 +1,4 @@ -package remote_manager +package debugging_runtime import "github.com/langgenius/dify-plugin-daemon/internal/service/install_service" diff --git a/internal/core/plugin_manager/remote_manager/run.go b/internal/core/plugin_manager/debugging_runtime/run.go similarity index 97% rename from internal/core/plugin_manager/remote_manager/run.go rename to internal/core/plugin_manager/debugging_runtime/run.go index d226259..5fe9335 100644 --- a/internal/core/plugin_manager/remote_manager/run.go +++ b/internal/core/plugin_manager/debugging_runtime/run.go @@ -1,4 +1,4 @@ -package remote_manager +package debugging_runtime import ( "time" @@ -39,7 +39,7 @@ func (r *RemotePluginRuntime) StartPlugin() error { // handle heartbeat routine.Submit(map[string]string{ - "module": "remote_manager", + "module": "debugging_runtime", "function": "StartPlugin", "plugin_id": identity.String(), }, func() { diff --git a/internal/core/plugin_manager/remote_manager/server.go b/internal/core/plugin_manager/debugging_runtime/server.go similarity index 93% rename from internal/core/plugin_manager/remote_manager/server.go rename to internal/core/plugin_manager/debugging_runtime/server.go index e62a7f5..e23245c 100644 --- a/internal/core/plugin_manager/remote_manager/server.go +++ b/internal/core/plugin_manager/debugging_runtime/server.go @@ -1,4 +1,4 @@ -package remote_manager +package debugging_runtime import ( "context" @@ -11,7 +11,7 @@ import ( "syscall" "time" - "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/media_manager" + "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/media_transport" "github.com/langgenius/dify-plugin-daemon/internal/types/app" "github.com/langgenius/dify-plugin-daemon/internal/types/entities/plugin_entities" "github.com/langgenius/dify-plugin-daemon/internal/utils/stream" @@ -102,7 +102,7 @@ func (s *RemotePluginServer) collectShutdownSignal() { } // NewRemotePluginServer creates a new RemotePluginServer -func NewRemotePluginServer(config *app.Config, media_manager *media_manager.MediaBucket) *RemotePluginServer { +func NewRemotePluginServer(config *app.Config, media_transport *media_transport.MediaBucket) *RemotePluginServer { addr := fmt.Sprintf( "tcp://%s:%d", config.PluginRemoteInstallingHost, @@ -115,7 +115,7 @@ func NewRemotePluginServer(config *app.Config, media_manager *media_manager.Medi multicore := true s := &DifyServer{ - mediaManager: media_manager, + mediaManager: media_transport, addr: addr, port: config.PluginRemoteInstallingPort, multicore: multicore, diff --git a/internal/core/plugin_manager/remote_manager/server_test.go b/internal/core/plugin_manager/debugging_runtime/server_test.go similarity index 98% rename from internal/core/plugin_manager/remote_manager/server_test.go rename to internal/core/plugin_manager/debugging_runtime/server_test.go index 4a45c22..3a62508 100644 --- a/internal/core/plugin_manager/remote_manager/server_test.go +++ b/internal/core/plugin_manager/debugging_runtime/server_test.go @@ -1,4 +1,4 @@ -package remote_manager +package debugging_runtime import ( "errors" @@ -9,7 +9,7 @@ import ( "time" "github.com/google/uuid" - "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/media_manager" + "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/media_transport" "github.com/langgenius/dify-plugin-daemon/internal/db" "github.com/langgenius/dify-plugin-daemon/internal/oss/local" "github.com/langgenius/dify-plugin-daemon/internal/types/app" @@ -49,7 +49,7 @@ func preparePluginServer(t *testing.T) (*RemotePluginServer, uint16) { PluginRemoteInstallingPort: port, PluginRemoteInstallingMaxConn: 1, PluginRemoteInstallServerEventLoopNums: 8, - }, media_manager.NewAssetsBucket(oss, "assets", 10)), port + }, media_transport.NewAssetsBucket(oss, "assets", 10)), port } // TestLaunchAndClosePluginServer tests the launch and close of the plugin server diff --git a/internal/core/plugin_manager/remote_manager/type.go b/internal/core/plugin_manager/debugging_runtime/type.go similarity index 98% rename from internal/core/plugin_manager/remote_manager/type.go rename to internal/core/plugin_manager/debugging_runtime/type.go index 684065e..f6d379d 100644 --- a/internal/core/plugin_manager/remote_manager/type.go +++ b/internal/core/plugin_manager/debugging_runtime/type.go @@ -1,4 +1,4 @@ -package remote_manager +package debugging_runtime import ( "bytes" @@ -6,7 +6,7 @@ import ( "sync/atomic" "time" - "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/basic_manager" + "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/basic_runtime" "github.com/langgenius/dify-plugin-daemon/internal/types/entities/plugin_entities" "github.com/langgenius/dify-plugin-daemon/internal/utils/stream" "github.com/panjf2000/gnet/v2" @@ -17,7 +17,7 @@ type pluginRuntimeMode string const _PLUGIN_RUNTIME_MODE_CI pluginRuntimeMode = "ci" type RemotePluginRuntime struct { - basic_manager.BasicPluginRuntime + basic_runtime.MediaTransport plugin_entities.PluginRuntime // connection diff --git a/internal/core/plugin_manager/install_to_serverless.go b/internal/core/plugin_manager/install_to_serverless.go index dd0554e..faf7c29 100644 --- a/internal/core/plugin_manager/install_to_serverless.go +++ b/internal/core/plugin_manager/install_to_serverless.go @@ -3,7 +3,7 @@ package plugin_manager import ( "fmt" - "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/serverless" + serverless "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/serverless_connector" "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_packager/decoder" "github.com/langgenius/dify-plugin-daemon/internal/db" "github.com/langgenius/dify-plugin-daemon/internal/types/models" diff --git a/internal/core/plugin_manager/launcher.go b/internal/core/plugin_manager/launcher.go index d52eb44..7a0774f 100644 --- a/internal/core/plugin_manager/launcher.go +++ b/internal/core/plugin_manager/launcher.go @@ -7,9 +7,8 @@ import ( "path" "strings" - "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/basic_manager" - "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/local_manager" - "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/positive_manager" + "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/basic_runtime" + "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/local_runtime" "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_packager/decoder" "github.com/langgenius/dify-plugin-daemon/internal/types/entities/plugin_entities" "github.com/langgenius/dify-plugin-daemon/internal/utils/log" @@ -130,12 +129,12 @@ func (p *PluginManager) launchLocal(pluginUniqueIdentifier plugin_entities.Plugi return nil, nil, nil, failed(err.Error()) } - localPluginRuntime := local_manager.NewLocalPluginRuntime(p.pythonInterpreterPath) + localPluginRuntime := local_runtime.NewLocalPluginRuntime(p.pythonInterpreterPath) localPluginRuntime.PluginRuntime = plugin.runtime - localPluginRuntime.PositivePluginRuntime = positive_manager.PositivePluginRuntime{ - BasicPluginRuntime: basic_manager.NewBasicPluginRuntime(p.mediaBucket), - WorkingPath: plugin.runtime.State.WorkingPath, - Decoder: plugin.decoder, + localPluginRuntime.BasicChecksum = basic_runtime.BasicChecksum{ + MediaTransport: basic_runtime.NewMediaTransport(p.mediaBucket), + WorkingPath: plugin.runtime.State.WorkingPath, + Decoder: plugin.decoder, } if err := localPluginRuntime.RemapAssets( diff --git a/internal/core/plugin_manager/local_manager/tester.go b/internal/core/plugin_manager/local_manager/tester.go deleted file mode 100644 index 950b623..0000000 --- a/internal/core/plugin_manager/local_manager/tester.go +++ /dev/null @@ -1 +0,0 @@ -package local_manager diff --git a/internal/core/plugin_manager/local_manager/environment.go b/internal/core/plugin_manager/local_runtime/environment.go similarity index 97% rename from internal/core/plugin_manager/local_manager/environment.go rename to internal/core/plugin_manager/local_runtime/environment.go index 2e80288..65f34d7 100644 --- a/internal/core/plugin_manager/local_manager/environment.go +++ b/internal/core/plugin_manager/local_runtime/environment.go @@ -1,4 +1,4 @@ -package local_manager +package local_runtime import ( "fmt" diff --git a/internal/core/plugin_manager/local_manager/environment_python.go b/internal/core/plugin_manager/local_runtime/environment_python.go similarity index 99% rename from internal/core/plugin_manager/local_manager/environment_python.go rename to internal/core/plugin_manager/local_runtime/environment_python.go index 72a086d..6719d74 100644 --- a/internal/core/plugin_manager/local_manager/environment_python.go +++ b/internal/core/plugin_manager/local_runtime/environment_python.go @@ -1,4 +1,4 @@ -package local_manager +package local_runtime import ( "bytes" diff --git a/internal/core/plugin_manager/local_manager/io.go b/internal/core/plugin_manager/local_runtime/io.go similarity index 97% rename from internal/core/plugin_manager/local_manager/io.go rename to internal/core/plugin_manager/local_runtime/io.go index 6ee321f..4dd0a1e 100644 --- a/internal/core/plugin_manager/local_manager/io.go +++ b/internal/core/plugin_manager/local_runtime/io.go @@ -1,4 +1,4 @@ -package local_manager +package local_runtime import ( "github.com/langgenius/dify-plugin-daemon/internal/types/entities" diff --git a/internal/core/plugin_manager/local_manager/run.go b/internal/core/plugin_manager/local_runtime/run.go similarity index 98% rename from internal/core/plugin_manager/local_manager/run.go rename to internal/core/plugin_manager/local_runtime/run.go index caceffe..e76157f 100644 --- a/internal/core/plugin_manager/local_manager/run.go +++ b/internal/core/plugin_manager/local_runtime/run.go @@ -1,5 +1,5 @@ -// Package local_manager handles the local plugin runtime management -package local_manager +// Package local_runtime handles the local plugin runtime management +package local_runtime import ( "errors" diff --git a/internal/core/plugin_manager/local_manager/stdio_handle.go b/internal/core/plugin_manager/local_runtime/stdio_handle.go similarity index 99% rename from internal/core/plugin_manager/local_manager/stdio_handle.go rename to internal/core/plugin_manager/local_runtime/stdio_handle.go index 7780b81..e22fa78 100644 --- a/internal/core/plugin_manager/local_manager/stdio_handle.go +++ b/internal/core/plugin_manager/local_runtime/stdio_handle.go @@ -1,4 +1,4 @@ -package local_manager +package local_runtime import ( "bufio" diff --git a/internal/core/plugin_manager/local_manager/stdio_store.go b/internal/core/plugin_manager/local_runtime/stdio_store.go similarity index 98% rename from internal/core/plugin_manager/local_manager/stdio_store.go rename to internal/core/plugin_manager/local_runtime/stdio_store.go index 4c7fb78..8b8af2d 100644 --- a/internal/core/plugin_manager/local_manager/stdio_store.go +++ b/internal/core/plugin_manager/local_runtime/stdio_store.go @@ -1,4 +1,4 @@ -package local_manager +package local_runtime import ( "io" diff --git a/internal/core/plugin_manager/local_runtime/tester.go b/internal/core/plugin_manager/local_runtime/tester.go new file mode 100644 index 0000000..f5e7662 --- /dev/null +++ b/internal/core/plugin_manager/local_runtime/tester.go @@ -0,0 +1 @@ +package local_runtime diff --git a/internal/core/plugin_manager/local_manager/type.go b/internal/core/plugin_manager/local_runtime/type.go similarity index 90% rename from internal/core/plugin_manager/local_manager/type.go rename to internal/core/plugin_manager/local_runtime/type.go index 80d4acb..7cfb241 100644 --- a/internal/core/plugin_manager/local_manager/type.go +++ b/internal/core/plugin_manager/local_runtime/type.go @@ -1,14 +1,14 @@ -package local_manager +package local_runtime import ( "sync" - "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/positive_manager" + "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/basic_runtime" "github.com/langgenius/dify-plugin-daemon/internal/types/entities/plugin_entities" ) type LocalPluginRuntime struct { - positive_manager.PositivePluginRuntime + basic_runtime.BasicChecksum plugin_entities.PluginRuntime waitChan chan bool diff --git a/internal/core/plugin_manager/manager.go b/internal/core/plugin_manager/manager.go index 17cf806..7dd1633 100644 --- a/internal/core/plugin_manager/manager.go +++ b/internal/core/plugin_manager/manager.go @@ -7,9 +7,9 @@ import ( "github.com/langgenius/dify-plugin-daemon/internal/core/dify_invocation" "github.com/langgenius/dify-plugin-daemon/internal/core/dify_invocation/real" - "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/media_manager" - "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/remote_manager" - "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/serverless" + "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/debugging_runtime" + "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/media_transport" + serverless "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/serverless_connector" "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_packager/decoder" "github.com/langgenius/dify-plugin-daemon/internal/db" "github.com/langgenius/dify-plugin-daemon/internal/oss" @@ -36,13 +36,13 @@ type PluginManager struct { pluginStoragePath string // mediaBucket is used to manage media files like plugin icons, images, etc. - mediaBucket *media_manager.MediaBucket + mediaBucket *media_transport.MediaBucket // packageBucket is used to manage plugin packages, all the packages uploaded by users will be saved here - packageBucket *media_manager.PackageBucket + packageBucket *media_transport.PackageBucket // installedBucket is used to manage installed plugins, all the installed plugins will be saved here - installedBucket *media_manager.InstalledBucket + installedBucket *media_transport.InstalledBucket // register plugin pluginRegisters []func(lifetime plugin_entities.PluginLifetime) error @@ -57,7 +57,7 @@ type PluginManager struct { pythonInterpreterPath string // remote plugin server - remotePluginServer remote_manager.RemotePluginServerInterface + remotePluginServer debugging_runtime.RemotePluginServerInterface // max launching lock to prevent too many plugins launching at the same time maxLaunchingLock chan bool @@ -75,16 +75,16 @@ func InitGlobalManager(oss oss.OSS, configuration *app.Config) *PluginManager { maxPluginPackageSize: configuration.MaxPluginPackageSize, pluginStoragePath: configuration.PluginInstalledPath, workingDirectory: configuration.PluginWorkingPath, - mediaBucket: media_manager.NewAssetsBucket( + mediaBucket: media_transport.NewAssetsBucket( oss, configuration.PluginMediaCachePath, configuration.PluginMediaCacheSize, ), - packageBucket: media_manager.NewPackageBucket( + packageBucket: media_transport.NewPackageBucket( oss, configuration.PluginPackageCachePath, ), - installedBucket: media_manager.NewInstalledBucket( + installedBucket: media_transport.NewInstalledBucket( oss, configuration.PluginInstalledPath, ), diff --git a/internal/core/plugin_manager/media_manager/assets.go b/internal/core/plugin_manager/media_transport/assets.go similarity index 99% rename from internal/core/plugin_manager/media_manager/assets.go rename to internal/core/plugin_manager/media_transport/assets.go index ac087f9..436f57b 100644 --- a/internal/core/plugin_manager/media_manager/assets.go +++ b/internal/core/plugin_manager/media_transport/assets.go @@ -1,4 +1,4 @@ -package media_manager +package media_transport import ( "errors" diff --git a/internal/core/plugin_manager/media_manager/assets_bucket.go b/internal/core/plugin_manager/media_transport/assets_bucket.go similarity index 98% rename from internal/core/plugin_manager/media_manager/assets_bucket.go rename to internal/core/plugin_manager/media_transport/assets_bucket.go index ad872ba..36c35bb 100644 --- a/internal/core/plugin_manager/media_manager/assets_bucket.go +++ b/internal/core/plugin_manager/media_transport/assets_bucket.go @@ -1,4 +1,4 @@ -package media_manager +package media_transport import ( "crypto/sha256" diff --git a/internal/core/plugin_manager/media_manager/installed_bucket.go b/internal/core/plugin_manager/media_transport/installed_bucket.go similarity index 98% rename from internal/core/plugin_manager/media_manager/installed_bucket.go rename to internal/core/plugin_manager/media_transport/installed_bucket.go index c8c34f2..42270a0 100644 --- a/internal/core/plugin_manager/media_manager/installed_bucket.go +++ b/internal/core/plugin_manager/media_transport/installed_bucket.go @@ -1,4 +1,4 @@ -package media_manager +package media_transport import ( "path/filepath" diff --git a/internal/core/plugin_manager/media_manager/package_bucket.go b/internal/core/plugin_manager/media_transport/package_bucket.go similarity index 96% rename from internal/core/plugin_manager/media_manager/package_bucket.go rename to internal/core/plugin_manager/media_transport/package_bucket.go index 96ae9fd..b596091 100644 --- a/internal/core/plugin_manager/media_manager/package_bucket.go +++ b/internal/core/plugin_manager/media_transport/package_bucket.go @@ -1,4 +1,4 @@ -package media_manager +package media_transport import ( "path" diff --git a/internal/core/plugin_manager/positive_manager/environment.go b/internal/core/plugin_manager/positive_manager/environment.go deleted file mode 100644 index d168c25..0000000 --- a/internal/core/plugin_manager/positive_manager/environment.go +++ /dev/null @@ -1,30 +0,0 @@ -package positive_manager - -import ( - "os" -) - -func (r *PositivePluginRuntime) calculateChecksum() (string, error) { - checksum, err := r.Decoder.Checksum() - if err != nil { - return "", err - } - - return checksum, nil -} - -func (r *PositivePluginRuntime) Checksum() (string, error) { - if r.InnerChecksum == "" { - checksum, err := r.calculateChecksum() - if err != nil { - return "", err - } - r.InnerChecksum = checksum - } - - return r.InnerChecksum, nil -} - -func (r *PositivePluginRuntime) Cleanup() { - os.RemoveAll(r.WorkingPath) -} diff --git a/internal/core/plugin_manager/positive_manager/types.go b/internal/core/plugin_manager/positive_manager/types.go deleted file mode 100644 index cd9c906..0000000 --- a/internal/core/plugin_manager/positive_manager/types.go +++ /dev/null @@ -1,16 +0,0 @@ -package positive_manager - -import ( - "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/basic_manager" - "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_packager/decoder" -) - -type PositivePluginRuntime struct { - basic_manager.BasicPluginRuntime - - WorkingPath string - // plugin decoder used to manage the plugin - Decoder decoder.PluginDecoder - - InnerChecksum string -} diff --git a/internal/core/plugin_manager/serverless.go b/internal/core/plugin_manager/serverless.go index 7cec1bf..6fad99c 100644 --- a/internal/core/plugin_manager/serverless.go +++ b/internal/core/plugin_manager/serverless.go @@ -4,9 +4,8 @@ import ( "fmt" "time" - "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/aws_manager" - "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/basic_manager" - "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/positive_manager" + "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/basic_runtime" + "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/serverless_runtime" "github.com/langgenius/dify-plugin-daemon/internal/db" "github.com/langgenius/dify-plugin-daemon/internal/types/entities/plugin_entities" "github.com/langgenius/dify-plugin-daemon/internal/types/models" @@ -40,10 +39,10 @@ func (p *PluginManager) getServerlessPluginRuntime( runtimeEntity.InitState() // convert to plugin runtime - pluginRuntime := aws_manager.AWSPluginRuntime{ - PositivePluginRuntime: positive_manager.PositivePluginRuntime{ - BasicPluginRuntime: basic_manager.NewBasicPluginRuntime(p.mediaBucket), - InnerChecksum: model.Checksum, + pluginRuntime := serverless_runtime.AWSPluginRuntime{ + BasicChecksum: basic_runtime.BasicChecksum{ + MediaTransport: basic_runtime.NewMediaTransport(p.mediaBucket), + InnerChecksum: model.Checksum, }, PluginRuntime: runtimeEntity, LambdaURL: model.FunctionURL, diff --git a/internal/core/plugin_manager/serverless/client.go b/internal/core/plugin_manager/serverless_connector/client.go similarity index 100% rename from internal/core/plugin_manager/serverless/client.go rename to internal/core/plugin_manager/serverless_connector/client.go diff --git a/internal/core/plugin_manager/serverless/connector.go b/internal/core/plugin_manager/serverless_connector/connector.go similarity index 100% rename from internal/core/plugin_manager/serverless/connector.go rename to internal/core/plugin_manager/serverless_connector/connector.go diff --git a/internal/core/plugin_manager/serverless/packager.go b/internal/core/plugin_manager/serverless_connector/packager.go similarity index 98% rename from internal/core/plugin_manager/serverless/packager.go rename to internal/core/plugin_manager/serverless_connector/packager.go index 65a9633..a8715df 100644 --- a/internal/core/plugin_manager/serverless/packager.go +++ b/internal/core/plugin_manager/serverless_connector/packager.go @@ -11,7 +11,7 @@ import ( "strings" "time" - "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/aws_manager/dockerfile" + "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/serverless_runtime/dockerfile" "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_packager/decoder" "github.com/langgenius/dify-plugin-daemon/internal/utils/tmpfile" ) diff --git a/internal/core/plugin_manager/serverless/packager_test.go b/internal/core/plugin_manager/serverless_connector/packager_test.go similarity index 100% rename from internal/core/plugin_manager/serverless/packager_test.go rename to internal/core/plugin_manager/serverless_connector/packager_test.go diff --git a/internal/core/plugin_manager/serverless/packager_test_plugin/main.py b/internal/core/plugin_manager/serverless_connector/packager_test_plugin/main.py similarity index 100% rename from internal/core/plugin_manager/serverless/packager_test_plugin/main.py rename to internal/core/plugin_manager/serverless_connector/packager_test_plugin/main.py diff --git a/internal/core/plugin_manager/serverless/packager_test_plugin/manifest.yaml b/internal/core/plugin_manager/serverless_connector/packager_test_plugin/manifest.yaml similarity index 100% rename from internal/core/plugin_manager/serverless/packager_test_plugin/manifest.yaml rename to internal/core/plugin_manager/serverless_connector/packager_test_plugin/manifest.yaml diff --git a/internal/core/plugin_manager/serverless/packager_test_plugin/provider/jina.yaml b/internal/core/plugin_manager/serverless_connector/packager_test_plugin/provider/jina.yaml similarity index 100% rename from internal/core/plugin_manager/serverless/packager_test_plugin/provider/jina.yaml rename to internal/core/plugin_manager/serverless_connector/packager_test_plugin/provider/jina.yaml diff --git a/internal/core/plugin_manager/serverless/packager_test_plugin/requirements.txt b/internal/core/plugin_manager/serverless_connector/packager_test_plugin/requirements.txt similarity index 100% rename from internal/core/plugin_manager/serverless/packager_test_plugin/requirements.txt rename to internal/core/plugin_manager/serverless_connector/packager_test_plugin/requirements.txt diff --git a/internal/core/plugin_manager/serverless/upload.go b/internal/core/plugin_manager/serverless_connector/upload.go similarity index 100% rename from internal/core/plugin_manager/serverless/upload.go rename to internal/core/plugin_manager/serverless_connector/upload.go diff --git a/internal/core/plugin_manager/aws_manager/dockerfile/build.go b/internal/core/plugin_manager/serverless_runtime/dockerfile/build.go similarity index 100% rename from internal/core/plugin_manager/aws_manager/dockerfile/build.go rename to internal/core/plugin_manager/serverless_runtime/dockerfile/build.go diff --git a/internal/core/plugin_manager/aws_manager/dockerfile/build_test.go b/internal/core/plugin_manager/serverless_runtime/dockerfile/build_test.go similarity index 100% rename from internal/core/plugin_manager/aws_manager/dockerfile/build_test.go rename to internal/core/plugin_manager/serverless_runtime/dockerfile/build_test.go diff --git a/internal/core/plugin_manager/aws_manager/dockerfile/python.go b/internal/core/plugin_manager/serverless_runtime/dockerfile/python.go similarity index 100% rename from internal/core/plugin_manager/aws_manager/dockerfile/python.go rename to internal/core/plugin_manager/serverless_runtime/dockerfile/python.go diff --git a/internal/core/plugin_manager/aws_manager/dockerfile/python312.dockerfile b/internal/core/plugin_manager/serverless_runtime/dockerfile/python312.dockerfile similarity index 100% rename from internal/core/plugin_manager/aws_manager/dockerfile/python312.dockerfile rename to internal/core/plugin_manager/serverless_runtime/dockerfile/python312.dockerfile diff --git a/internal/core/plugin_manager/aws_manager/environment.go b/internal/core/plugin_manager/serverless_runtime/environment.go similarity index 96% rename from internal/core/plugin_manager/aws_manager/environment.go rename to internal/core/plugin_manager/serverless_runtime/environment.go index 2b78c44..cbd2d8c 100644 --- a/internal/core/plugin_manager/aws_manager/environment.go +++ b/internal/core/plugin_manager/serverless_runtime/environment.go @@ -1,4 +1,4 @@ -package aws_manager +package serverless_runtime import ( "fmt" diff --git a/internal/core/plugin_manager/serverless_runtime/init.go b/internal/core/plugin_manager/serverless_runtime/init.go new file mode 100644 index 0000000..8814cb9 --- /dev/null +++ b/internal/core/plugin_manager/serverless_runtime/init.go @@ -0,0 +1 @@ +package serverless_runtime diff --git a/internal/core/plugin_manager/aws_manager/io.go b/internal/core/plugin_manager/serverless_runtime/io.go similarity index 98% rename from internal/core/plugin_manager/aws_manager/io.go rename to internal/core/plugin_manager/serverless_runtime/io.go index 7f33bda..2a85283 100644 --- a/internal/core/plugin_manager/aws_manager/io.go +++ b/internal/core/plugin_manager/serverless_runtime/io.go @@ -1,4 +1,4 @@ -package aws_manager +package serverless_runtime import ( "bufio" @@ -60,7 +60,7 @@ func (r *AWSPluginRuntime) Write(session_id string, data []byte) { req.Header.Set("Dify-Plugin-Session-ID", session_id) routine.Submit(map[string]string{ - "module": "aws_manager", + "module": "serverless_runtime", "function": "Write", "session_id": session_id, "lambda_url": r.LambdaURL, diff --git a/internal/core/plugin_manager/aws_manager/run.go b/internal/core/plugin_manager/serverless_runtime/run.go similarity index 92% rename from internal/core/plugin_manager/aws_manager/run.go rename to internal/core/plugin_manager/serverless_runtime/run.go index be8cfb8..aa20557 100644 --- a/internal/core/plugin_manager/aws_manager/run.go +++ b/internal/core/plugin_manager/serverless_runtime/run.go @@ -1,4 +1,4 @@ -package aws_manager +package serverless_runtime import "github.com/langgenius/dify-plugin-daemon/internal/types/entities/plugin_entities" diff --git a/internal/core/plugin_manager/aws_manager/type.go b/internal/core/plugin_manager/serverless_runtime/type.go similarity index 87% rename from internal/core/plugin_manager/aws_manager/type.go rename to internal/core/plugin_manager/serverless_runtime/type.go index d94ff4a..90f2fdc 100644 --- a/internal/core/plugin_manager/aws_manager/type.go +++ b/internal/core/plugin_manager/serverless_runtime/type.go @@ -1,16 +1,16 @@ -package aws_manager +package serverless_runtime import ( "net/http" - "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/positive_manager" + "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/basic_runtime" "github.com/langgenius/dify-plugin-daemon/internal/types/entities" "github.com/langgenius/dify-plugin-daemon/internal/types/entities/plugin_entities" "github.com/langgenius/dify-plugin-daemon/internal/utils/mapping" ) type AWSPluginRuntime struct { - positive_manager.PositivePluginRuntime + basic_runtime.BasicChecksum plugin_entities.PluginRuntime // access url for the lambda function diff --git a/internal/core/plugin_manager/tester.go b/internal/core/plugin_manager/tester.go index 54cbb24..3b2ce4a 100644 --- a/internal/core/plugin_manager/tester.go +++ b/internal/core/plugin_manager/tester.go @@ -24,10 +24,10 @@ NOTE: tester is deprecated, maybe, in several months, we will support this again // return nil, errors.Join(err, errors.New("failed to get assets")) // } -// local_plugin_runtime := local_manager.NewLocalPluginRuntime(p.pythonInterpreterPath) +// local_plugin_runtime := local_runtime.NewLocalPluginRuntime(p.pythonInterpreterPath) // local_plugin_runtime.PluginRuntime = plugin.runtime // local_plugin_runtime.PositivePluginRuntime = positive_manager.PositivePluginRuntime{ -// BasicPluginRuntime: basic_manager.NewBasicPluginRuntime(p.mediaBucket), +// BasicPluginRuntime: basic_runtime.NewBasicPluginRuntime(p.mediaBucket), // WorkingPath: plugin.runtime.State.WorkingPath, // Decoder: plugin.decoder, // } diff --git a/internal/core/plugin_manager/watcher.go b/internal/core/plugin_manager/watcher.go index 4b50091..e4d31ff 100644 --- a/internal/core/plugin_manager/watcher.go +++ b/internal/core/plugin_manager/watcher.go @@ -3,8 +3,8 @@ package plugin_manager import ( "time" - "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/local_manager" - "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/remote_manager" + "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/debugging_runtime" + "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/local_runtime" "github.com/langgenius/dify-plugin-daemon/internal/types/app" "github.com/langgenius/dify-plugin-daemon/internal/types/entities/plugin_entities" "github.com/langgenius/dify-plugin-daemon/internal/utils/log" @@ -26,7 +26,7 @@ func (p *PluginManager) initRemotePluginServer(config *app.Config) { if p.remotePluginServer != nil { return } - p.remotePluginServer = remote_manager.NewRemotePluginServer(config, p.mediaBucket) + p.remotePluginServer = debugging_runtime.NewRemotePluginServer(config, p.mediaBucket) } func (p *PluginManager) startRemoteWatcher(config *app.Config) { @@ -95,7 +95,7 @@ func (p *PluginManager) removeUninstalledLocalPlugins() { // read all local plugin runtimes p.m.Range(func(key string, value plugin_entities.PluginLifetime) bool { // try to convert to local runtime - runtime, ok := value.(*local_manager.LocalPluginRuntime) + runtime, ok := value.(*local_runtime.LocalPluginRuntime) if !ok { return true } diff --git a/internal/core/plugin_manager/watcher_test.go b/internal/core/plugin_manager/watcher_test.go index 4ea1e31..9b37b6b 100644 --- a/internal/core/plugin_manager/watcher_test.go +++ b/internal/core/plugin_manager/watcher_test.go @@ -5,7 +5,7 @@ import ( "time" "github.com/google/uuid" - "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/positive_manager" + "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/basic_runtime" "github.com/langgenius/dify-plugin-daemon/internal/oss/local" "github.com/langgenius/dify-plugin-daemon/internal/types/app" "github.com/langgenius/dify-plugin-daemon/internal/types/entities" @@ -16,7 +16,7 @@ import ( type fakePlugin struct { plugin_entities.PluginRuntime - positive_manager.PositivePluginRuntime + basic_runtime.BasicChecksum } func (r *fakePlugin) InitEnvironment() error { diff --git a/internal/service/debugging.go b/internal/service/debugging.go index 321b84f..cdd2d81 100644 --- a/internal/service/debugging.go +++ b/internal/service/debugging.go @@ -1,7 +1,7 @@ package service import ( - "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/remote_manager" + "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/debugging_runtime" "github.com/langgenius/dify-plugin-daemon/internal/types/entities" "github.com/langgenius/dify-plugin-daemon/internal/types/exception" ) @@ -11,7 +11,7 @@ func GetRemoteDebuggingKey(tenant_id string) *entities.Response { Key string `json:"key"` } - key, err := remote_manager.GetConnectionKey(remote_manager.ConnectionInfo{ + key, err := debugging_runtime.GetConnectionKey(debugging_runtime.ConnectionInfo{ TenantId: tenant_id, })