sosyz opened a new issue, #1208:
URL: https://github.com/apache/incubator-answer/issues/1208

   ## Is your feature request related to a problem? Please describe
   
   During plugin development, we frequently need persistent data storage 
capabilities. The current plugin system only supports reading user 
configurations, which severely limits plugin functionality. For example, when 
developing Passkey login features, plugins need to store client public key 
information, but the existing architecture cannot support this requirement.
   
   ## Describe the solution you'd like
   
   I propose adding a new plugin type called KVStorage to provide key-value 
storage capabilities for plugins. Here is the specific design:
   
   ```go
   // util
   type PluginKVStorage struct {
       Get(ctx context.Context, key string) (string, error)
       Set(ctx context.Context, key, value string) error
       Del(ctx context.Context, key string) error
       Tx(ctx context.Context, call func(ctx context.Context)) error
   }
   
   // entity
   type KVStorage struct{
       ID             string `xorm:"not null pk BIGINT(20) id"`
       PluginSlugName string `xorm:"not null VARCHAR(128) plugin_slug_name"`
       Status         int    `xorm:"not null default 1 INT(11) status"`
       Key            string `xorm:"not null VARCHAR(255) key"`
       Value          string `xorm:"not null MEDIUMTEXT value"`
   }
   
   // plugin
   type KVStorage interface {
       // Inject PluginKVStorage
       InjectKVStorage func(kvs *PluginKVStorage)
   }
   ```
   
   This design ensures data isolation through the PluginSlugName field, where 
each plugin can only access its own data. It also provides transaction support 
to ensure atomic data operations.
   
   ## Describe alternatives you've considered
   
   1. Direct Database Access: We considered allowing plugins to access the 
database directly, but this approach poses serious security risks. Direct 
database access would break system encapsulation and make it difficult to 
manage permissions and ensure data security.
   2. File System Storage: We considered letting plugins use the file system 
for data storage, but this approach would make unified management difficult and 
increase operational complexity and management costs.
   
   Thanks to @LinkinStars for the help. Please provide any feedback - I'm happy 
to make adjustments.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to