@@ -54,7 +54,7 @@ func (c *EtcdClient) WatchPrefix(ctx context.Context, startRevision int64) clien
5454 opts = append (opts , clientv3 .WithRev (startRevision + 1 ))
5555 }
5656
57- watchChan := c .Client . Watch (ctx , c .prefix , opts ... )
57+ watchChan := c .Watch (ctx , c .prefix , opts ... )
5858 logrus .WithFields (logrus.Fields {
5959 "prefix" : c .prefix ,
6060 "revision" : startRevision ,
@@ -65,7 +65,7 @@ func (c *EtcdClient) WatchPrefix(ctx context.Context, startRevision int64) clien
6565
6666// GetAllKeys retrieves all key-value pairs with the given prefix for initial sync
6767func (c * EtcdClient ) GetAllKeys (ctx context.Context , prefix string ) ([]KeyValueRecord , error ) {
68- resp , err := c .Client . Get (ctx , prefix , clientv3 .WithPrefix (), clientv3 .WithSort (clientv3 .SortByKey , clientv3 .SortAscend ))
68+ resp , err := c .Get (ctx , prefix , clientv3 .WithPrefix (), clientv3 .WithSort (clientv3 .SortByKey , clientv3 .SortAscend ))
6969 if err != nil {
7070 return nil , fmt .Errorf ("failed to get all keys: %w" , err )
7171 }
@@ -90,59 +90,6 @@ func (c *EtcdClient) GetAllKeys(ctx context.Context, prefix string) ([]KeyValueR
9090 return pairs , nil
9191}
9292
93- // Put stores a key-value pair in etcd
94- func (c * EtcdClient ) Put (ctx context.Context , key , value string ) (* clientv3.PutResponse , error ) {
95- resp , err := c .Client .Put (ctx , key , value )
96- if err != nil {
97- return nil , fmt .Errorf ("failed to put key %s: %w" , key , err )
98- }
99-
100- logrus .WithFields (logrus.Fields {
101- "key" : key ,
102- "revision" : resp .Header .Revision ,
103- }).Debug ("Put key to etcd" )
104-
105- return resp , nil
106- }
107-
108- // Delete removes a key from etcd
109- func (c * EtcdClient ) Delete (ctx context.Context , key string ) (* clientv3.DeleteResponse , error ) {
110- resp , err := c .Client .Delete (ctx , key )
111- if err != nil {
112- return nil , fmt .Errorf ("failed to delete key %s: %w" , key , err )
113- }
114-
115- logrus .WithFields (logrus.Fields {
116- "key" : key ,
117- "revision" : resp .Header .Revision ,
118- "deleted" : resp .Deleted ,
119- }).Debug ("Deleted key from etcd" )
120-
121- return resp , nil
122- }
123-
124- // Get retrieves a single key from etcd
125- func (c * EtcdClient ) Get (ctx context.Context , key string ) (* KeyValueRecord , error ) {
126- resp , err := c .Client .Get (ctx , key )
127- if err != nil {
128- return nil , fmt .Errorf ("failed to get key %s: %w" , key , err )
129- }
130-
131- if len (resp .Kvs ) == 0 {
132- return nil , nil // Key not found
133- }
134-
135- kv := resp .Kvs [0 ]
136- value := string (kv .Value )
137-
138- return & KeyValueRecord {
139- Key : string (kv .Key ),
140- Value : value ,
141- Revision : kv .ModRevision ,
142- Tombstone : false ,
143- }, nil
144- }
145-
14693// NewEtcdClientWithRetry creates a new etcd client with retry logic
14794func NewEtcdClientWithRetry (ctx context.Context , dsn string ) (* EtcdClient , error ) {
14895 config := DefaultRetryConfig ()
@@ -158,7 +105,7 @@ func NewEtcdClientWithRetry(ctx context.Context, dsn string) (*EtcdClient, error
158105 // Test the connection
159106 if _ , testErr := client .Get (ctx , "healthcheck" ); testErr != nil {
160107 if client != nil {
161- client .Close ()
108+ _ = client .Close ()
162109 }
163110 return testErr
164111 }
@@ -243,7 +190,7 @@ func (c *EtcdClient) WatchWithRecovery(ctx context.Context, startRevision int64)
243190}
244191
245192// RetryEtcdOperation retries an etcd operation with exponential backoff
246- func RetryEtcdOperation (ctx context.Context , operation func () error , operationName string ) error {
193+ func RetryEtcdOperation (ctx context.Context , operation func () error ) error {
247194 config := DefaultRetryConfig ()
248195 return RetryWithBackoff (ctx , config , operation )
249196}
0 commit comments