This is an automated email from the ASF dual-hosted git repository. linkinstar pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/answer.git
commit beac023875eeb2007a866695789140b78dfc2f19 Author: Sonui <m...@sonui.cn> AuthorDate: Thu Apr 3 14:01:11 2025 +0800 docs(plugin): Add comments to KVOperator methods to improve code readability --- plugin/kv_storage.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugin/kv_storage.go b/plugin/kv_storage.go index 17617f6c..9b449f8f 100644 --- a/plugin/kv_storage.go +++ b/plugin/kv_storage.go @@ -16,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ + package plugin import ( @@ -233,6 +234,8 @@ func (kv *KVOperator) Del(ctx context.Context, params KVParams) error { return err } +// GetByGroup retrieves all key-value pairs for a specific group with pagination support. +// Returns a map of keys to values or an error if the group is empty or not found. func (kv *KVOperator) GetByGroup(ctx context.Context, params KVParams) (map[string]string, error) { if params.Group == "" { return nil, ErrKVGroupEmpty @@ -265,6 +268,9 @@ func (kv *KVOperator) GetByGroup(ctx context.Context, params KVParams) (map[stri return result, nil } +// Tx executes a function within a transaction context. If the KVOperator already has a session, +// it will use that session. Otherwise, it creates a new transaction session. +// The transaction will be committed if the function returns nil, or rolled back if it returns an error. func (kv *KVOperator) Tx(ctx context.Context, fn func(ctx context.Context, kv *KVOperator) error) error { var ( txKv = kv @@ -307,7 +313,7 @@ func (kv *KVOperator) Tx(ctx context.Context, fn func(ctx context.Context, kv *K return nil } -// PluginData defines the interface for plugins that need data storage capabilities +// KVStorage defines the interface for plugins that need data storage capabilities type KVStorage interface { Info() Info SetOperator(operator *KVOperator)