Skip to content

Commit

Permalink
add plugin type
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeuoly committed Jul 26, 2024
1 parent 9e60d83 commit c6d627f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
6 changes: 6 additions & 0 deletions internal/core/plugin_manager/aws_manager/run.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package aws_manager

import "github.com/langgenius/dify-plugin-daemon/internal/types/entities"

func (r *AWSPluginRuntime) StartPlugin() error {

return nil
Expand All @@ -8,3 +10,7 @@ func (r *AWSPluginRuntime) StartPlugin() error {
func (r *AWSPluginRuntime) Wait() (<-chan bool, error) {
return nil, nil
}

func (r *AWSPluginRuntime) Type() entities.PluginRuntimeType {
return entities.PLUGIN_RUNTIME_TYPE_AWS
}
4 changes: 4 additions & 0 deletions internal/core/plugin_manager/local_manager/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ func (r *LocalPluginRuntime) init() {
r.State.Status = entities.PLUGIN_RUNTIME_STATUS_LAUNCHING
}

func (r *LocalPluginRuntime) Type() entities.PluginRuntimeType {
return entities.PLUGIN_RUNTIME_TYPE_LOCAL
}

func (r *LocalPluginRuntime) StartPlugin() error {
defer log.Info("plugin %s stopped", r.Config.Identity())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
* Therefore, we need to a key-value pair to connect a random string to a tenant.
*
* $random_key => $tenant_id, $user_id
* $tenant_id => $random_id
* $tenant_id => $random_key
*
* It's a double mapping for each key, therefore a transaction is needed.
* */
Expand Down
5 changes: 5 additions & 0 deletions internal/core/plugin_manager/remote_manager/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"time"

"github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/plugin_errors"
"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/log"
"github.com/langgenius/dify-plugin-daemon/internal/utils/parser"
Expand All @@ -26,6 +27,10 @@ func (r *RemotePluginRuntime) Stop() {
r.conn.Close()
}

func (r *RemotePluginRuntime) Type() entities.PluginRuntimeType {
return entities.PLUGIN_RUNTIME_TYPE_REMOTE
}

func (r *RemotePluginRuntime) StartPlugin() error {
var exit_error error

Expand Down
10 changes: 10 additions & 0 deletions internal/types/entities/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type (
Configuration() *plugin_entities.PluginDeclaration
RuntimeState() *PluginRuntimeState
Wait() (<-chan bool, error)
Type() PluginRuntimeType
}

PluginRuntimeSessionIOInterface interface {
Expand All @@ -50,13 +51,22 @@ func (r *PluginRuntime) RuntimeState() *PluginRuntimeState {
return &r.State
}

type PluginRuntimeType string

const (
PLUGIN_RUNTIME_TYPE_LOCAL PluginRuntimeType = "local"
PLUGIN_RUNTIME_TYPE_REMOTE PluginRuntimeType = "remote"
PLUGIN_RUNTIME_TYPE_AWS PluginRuntimeType = "aws"
)

type PluginRuntimeState struct {
Restarts int `json:"restarts"`
Status string `json:"status"`
RelativePath string `json:"relative_path"`
ActiveAt *time.Time `json:"active_at"`
StoppedAt *time.Time `json:"stopped_at"`
Verified bool `json:"verified"`
TenantID string `json:"tenant_id"`
}

const (
Expand Down

0 comments on commit c6d627f

Please sign in to comment.