Skip to content

Commit beac023

Browse files
sosyzLinkinStars
authored andcommitted
docs(plugin): Add comments to KVOperator methods to improve code readability
1 parent 56f36ec commit beac023

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

plugin/kv_storage.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19+
1920
package plugin
2021

2122
import (
@@ -233,6 +234,8 @@ func (kv *KVOperator) Del(ctx context.Context, params KVParams) error {
233234
return err
234235
}
235236

237+
// GetByGroup retrieves all key-value pairs for a specific group with pagination support.
238+
// Returns a map of keys to values or an error if the group is empty or not found.
236239
func (kv *KVOperator) GetByGroup(ctx context.Context, params KVParams) (map[string]string, error) {
237240
if params.Group == "" {
238241
return nil, ErrKVGroupEmpty
@@ -265,6 +268,9 @@ func (kv *KVOperator) GetByGroup(ctx context.Context, params KVParams) (map[stri
265268
return result, nil
266269
}
267270

271+
// Tx executes a function within a transaction context. If the KVOperator already has a session,
272+
// it will use that session. Otherwise, it creates a new transaction session.
273+
// The transaction will be committed if the function returns nil, or rolled back if it returns an error.
268274
func (kv *KVOperator) Tx(ctx context.Context, fn func(ctx context.Context, kv *KVOperator) error) error {
269275
var (
270276
txKv = kv
@@ -307,7 +313,7 @@ func (kv *KVOperator) Tx(ctx context.Context, fn func(ctx context.Context, kv *K
307313
return nil
308314
}
309315

310-
// PluginData defines the interface for plugins that need data storage capabilities
316+
// KVStorage defines the interface for plugins that need data storage capabilities
311317
type KVStorage interface {
312318
Info() Info
313319
SetOperator(operator *KVOperator)

0 commit comments

Comments
 (0)