MCPcopy Create free account
hub / github.com/DoNewsCode/core / ReadBytes

Method ReadBytes

config/remote/etcd/etcd.go:39–55  ·  view source on GitHub ↗

ReadBytes reads the contents of a key from etcd and returns the bytes.

()

Source from the content-addressed store, hash-verified

37
38// ReadBytes reads the contents of a key from etcd and returns the bytes.
39func (r *ETCD) ReadBytes() ([]byte, error) {
40 client, err := clientv3.New(r.clientConfig)
41 if err != nil {
42 return nil, err
43 }
44 defer client.Close()
45
46 resp, err := client.Get(r.context(), r.key)
47 if err != nil {
48 return nil, err
49 }
50 if resp.Count == 0 {
51 return nil, fmt.Errorf("no such config key: %s", r.key)
52 }
53 r.rev = resp.Header.Revision
54 return resp.Kvs[0].Value, nil
55}
56
57// Read is not supported by the remote provider.
58func (r *ETCD) Read() (map[string]interface{}, error) {

Callers

nothing calls this directly

Calls 3

contextMethod · 0.95
CloseMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected