diff options
author | Wim <wim@42.be> | 2018-08-06 21:47:05 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2018-08-06 21:47:05 +0200 |
commit | 51062863a5c34d81e296cf15c61140911037cf3b (patch) | |
tree | 9b5e044672486326c7a0ca8fb26430f37bf4d83c /vendor/github.com/xordataexchange/crypt/backend/mock | |
parent | 4fb4b7aa6c02a54db8ad8dd98e4d321396926c0d (diff) | |
download | matterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.tar.gz matterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.tar.bz2 matterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.zip |
Use mod vendor for vendored directory (backwards compatible)
Diffstat (limited to 'vendor/github.com/xordataexchange/crypt/backend/mock')
-rw-r--r-- | vendor/github.com/xordataexchange/crypt/backend/mock/mock.go | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/vendor/github.com/xordataexchange/crypt/backend/mock/mock.go b/vendor/github.com/xordataexchange/crypt/backend/mock/mock.go deleted file mode 100644 index 68a9b1c7..00000000 --- a/vendor/github.com/xordataexchange/crypt/backend/mock/mock.go +++ /dev/null @@ -1,61 +0,0 @@ -package mock - -import ( - "errors" - "path" - "strings" - "time" - - "github.com/xordataexchange/crypt/backend" -) - -var mockedStore map[string][]byte - -type Client struct{} - -func New(machines []string) (*Client, error) { - if mockedStore == nil { - mockedStore = make(map[string][]byte, 2) - } - return &Client{}, nil -} - -func (c *Client) Get(key string) ([]byte, error) { - if v, ok := mockedStore[key]; ok { - return v, nil - } - err := errors.New("Could not find key: " + key) - return nil, err -} - -func (c *Client) List(key string) (backend.KVPairs, error) { - var list backend.KVPairs - dir := path.Clean(key) + "/" - for k, v := range mockedStore { - if strings.HasPrefix(k, dir) { - list = append(list, &backend.KVPair{Key: k, Value: v}) - } - } - return list, nil -} - -func (c *Client) Set(key string, value []byte) error { - mockedStore[key] = value - return nil -} - -func (c *Client) Watch(key string, stop chan bool) <-chan *backend.Response { - respChan := make(chan *backend.Response, 0) - go func() { - for { - b, err := c.Get(key) - if err != nil { - respChan <- &backend.Response{nil, err} - time.Sleep(time.Second * 5) - continue - } - respChan <- &backend.Response{b, nil} - } - }() - return respChan -} |