Vendor cleanup

Signed-off-by: Madhu Rajanna <mrajanna@redhat.com>
This commit is contained in:
Madhu Rajanna
2019-01-16 18:11:54 +05:30
parent 661818bd79
commit 0f836c62fa
16816 changed files with 20 additions and 4611100 deletions

View File

@ -1,19 +0,0 @@
sudo: false
language: go
go:
- 1.6.x
- 1.7.x
- 1.8.x
- 1.9.x
- master
matrix:
allow_failures:
- go: master
fast_finish: true
install:
- # Do nothing. This is needed to prevent default install action "go get -t -v ./..." from happening here (we want it to happen inside script step).
script:
- go get -t -v ./...
- diff -u <(echo -n) <(gofmt -d .)
- go tool vet .
- go test -v -race ./...

View File

@ -1,25 +0,0 @@
httpcache
=========
[![Build Status](https://travis-ci.org/gregjones/httpcache.svg?branch=master)](https://travis-ci.org/gregjones/httpcache) [![GoDoc](https://godoc.org/github.com/gregjones/httpcache?status.svg)](https://godoc.org/github.com/gregjones/httpcache)
Package httpcache provides a http.RoundTripper implementation that works as a mostly [RFC 7234](https://tools.ietf.org/html/rfc7234) compliant cache for http responses.
It is only suitable for use as a 'private' cache (i.e. for a web-browser or an API-client and not for a shared proxy).
Cache Backends
--------------
- The built-in 'memory' cache stores responses in an in-memory map.
- [`github.com/gregjones/httpcache/diskcache`](https://github.com/gregjones/httpcache/tree/master/diskcache) provides a filesystem-backed cache using the [diskv](https://github.com/peterbourgon/diskv) library.
- [`github.com/gregjones/httpcache/memcache`](https://github.com/gregjones/httpcache/tree/master/memcache) provides memcache implementations, for both App Engine and 'normal' memcache servers.
- [`sourcegraph.com/sourcegraph/s3cache`](https://sourcegraph.com/github.com/sourcegraph/s3cache) uses Amazon S3 for storage.
- [`github.com/gregjones/httpcache/leveldbcache`](https://github.com/gregjones/httpcache/tree/master/leveldbcache) provides a filesystem-backed cache using [leveldb](https://github.com/syndtr/goleveldb/leveldb).
- [`github.com/die-net/lrucache`](https://github.com/die-net/lrucache) provides an in-memory cache that will evict least-recently used entries.
- [`github.com/die-net/lrucache/twotier`](https://github.com/die-net/lrucache/tree/master/twotier) allows caches to be combined, for example to use lrucache above with a persistent disk-cache.
- [`github.com/birkelund/boltdbcache`](https://github.com/birkelund/boltdbcache) provides a BoltDB implementation (based on the [bbolt](https://github.com/coreos/bbolt) fork).
License
-------
- [MIT License](LICENSE.txt)

View File

@ -1,42 +0,0 @@
package diskcache
import (
"bytes"
"io/ioutil"
"os"
"testing"
)
func TestDiskCache(t *testing.T) {
tempDir, err := ioutil.TempDir("", "httpcache")
if err != nil {
t.Fatalf("TempDir: %v", err)
}
defer os.RemoveAll(tempDir)
cache := New(tempDir)
key := "testKey"
_, ok := cache.Get(key)
if ok {
t.Fatal("retrieved key before adding it")
}
val := []byte("some bytes")
cache.Set(key, val)
retVal, ok := cache.Get(key)
if !ok {
t.Fatal("could not retrieve an element we just added")
}
if !bytes.Equal(retVal, val) {
t.Fatal("retrieved a different value than what we put in")
}
cache.Delete(key)
_, ok = cache.Get(key)
if ok {
t.Fatal("deleted key still present")
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,51 +0,0 @@
// Package leveldbcache provides an implementation of httpcache.Cache that
// uses github.com/syndtr/goleveldb/leveldb
package leveldbcache
import (
"github.com/syndtr/goleveldb/leveldb"
)
// Cache is an implementation of httpcache.Cache with leveldb storage
type Cache struct {
db *leveldb.DB
}
// Get returns the response corresponding to key if present
func (c *Cache) Get(key string) (resp []byte, ok bool) {
var err error
resp, err = c.db.Get([]byte(key), nil)
if err != nil {
return []byte{}, false
}
return resp, true
}
// Set saves a response to the cache as key
func (c *Cache) Set(key string, resp []byte) {
c.db.Put([]byte(key), resp, nil)
}
// Delete removes the response with key from the cache
func (c *Cache) Delete(key string) {
c.db.Delete([]byte(key), nil)
}
// New returns a new Cache that will store leveldb in path
func New(path string) (*Cache, error) {
cache := &Cache{}
var err error
cache.db, err = leveldb.OpenFile(path, nil)
if err != nil {
return nil, err
}
return cache, nil
}
// NewWithDB returns a new Cache using the provided leveldb as underlying
// storage.
func NewWithDB(db *leveldb.DB) *Cache {
return &Cache{db}
}

View File

@ -1,46 +0,0 @@
package leveldbcache
import (
"bytes"
"io/ioutil"
"os"
"path/filepath"
"testing"
)
func TestDiskCache(t *testing.T) {
tempDir, err := ioutil.TempDir("", "httpcache")
if err != nil {
t.Fatalf("TempDir: %v", err)
}
defer os.RemoveAll(tempDir)
cache, err := New(filepath.Join(tempDir, "db"))
if err != nil {
t.Fatalf("New leveldb,: %v", err)
}
key := "testKey"
_, ok := cache.Get(key)
if ok {
t.Fatal("retrieved key before adding it")
}
val := []byte("some bytes")
cache.Set(key, val)
retVal, ok := cache.Get(key)
if !ok {
t.Fatal("could not retrieve an element we just added")
}
if !bytes.Equal(retVal, val) {
t.Fatal("retrieved a different value than what we put in")
}
cache.Delete(key)
_, ok = cache.Get(key)
if ok {
t.Fatal("deleted key still present")
}
}

View File

@ -1,61 +0,0 @@
// +build appengine
// Package memcache provides an implementation of httpcache.Cache that uses App
// Engine's memcache package to store cached responses.
//
// When not built for Google App Engine, this package will provide an
// implementation that connects to a specified memcached server. See the
// memcache.go file in this package for details.
package memcache
import (
"appengine"
"appengine/memcache"
)
// Cache is an implementation of httpcache.Cache that caches responses in App
// Engine's memcache.
type Cache struct {
appengine.Context
}
// cacheKey modifies an httpcache key for use in memcache. Specifically, it
// prefixes keys to avoid collision with other data stored in memcache.
func cacheKey(key string) string {
return "httpcache:" + key
}
// Get returns the response corresponding to key if present.
func (c *Cache) Get(key string) (resp []byte, ok bool) {
item, err := memcache.Get(c.Context, cacheKey(key))
if err != nil {
if err != memcache.ErrCacheMiss {
c.Context.Errorf("error getting cached response: %v", err)
}
return nil, false
}
return item.Value, true
}
// Set saves a response to the cache as key.
func (c *Cache) Set(key string, resp []byte) {
item := &memcache.Item{
Key: cacheKey(key),
Value: resp,
}
if err := memcache.Set(c.Context, item); err != nil {
c.Context.Errorf("error caching response: %v", err)
}
}
// Delete removes the response with key from the cache.
func (c *Cache) Delete(key string) {
if err := memcache.Delete(c.Context, cacheKey(key)); err != nil {
c.Context.Errorf("error deleting cached response: %v", err)
}
}
// New returns a new Cache for the given context.
func New(ctx appengine.Context) *Cache {
return &Cache{ctx}
}

View File

@ -1,44 +0,0 @@
// +build appengine
package memcache
import (
"bytes"
"testing"
"appengine/aetest"
)
func TestAppEngine(t *testing.T) {
ctx, err := aetest.NewContext(nil)
if err != nil {
t.Fatal(err)
}
defer ctx.Close()
cache := New(ctx)
key := "testKey"
_, ok := cache.Get(key)
if ok {
t.Fatal("retrieved key before adding it")
}
val := []byte("some bytes")
cache.Set(key, val)
retVal, ok := cache.Get(key)
if !ok {
t.Fatal("could not retrieve an element we just added")
}
if !bytes.Equal(retVal, val) {
t.Fatal("retrieved a different value than what we put in")
}
cache.Delete(key)
_, ok = cache.Get(key)
if ok {
t.Fatal("deleted key still present")
}
}

View File

@ -1,60 +0,0 @@
// +build !appengine
// Package memcache provides an implementation of httpcache.Cache that uses
// gomemcache to store cached responses.
//
// When built for Google App Engine, this package will provide an
// implementation that uses App Engine's memcache service. See the
// appengine.go file in this package for details.
package memcache
import (
"github.com/bradfitz/gomemcache/memcache"
)
// Cache is an implementation of httpcache.Cache that caches responses in a
// memcache server.
type Cache struct {
*memcache.Client
}
// cacheKey modifies an httpcache key for use in memcache. Specifically, it
// prefixes keys to avoid collision with other data stored in memcache.
func cacheKey(key string) string {
return "httpcache:" + key
}
// Get returns the response corresponding to key if present.
func (c *Cache) Get(key string) (resp []byte, ok bool) {
item, err := c.Client.Get(cacheKey(key))
if err != nil {
return nil, false
}
return item.Value, true
}
// Set saves a response to the cache as key.
func (c *Cache) Set(key string, resp []byte) {
item := &memcache.Item{
Key: cacheKey(key),
Value: resp,
}
c.Client.Set(item)
}
// Delete removes the response with key from the cache.
func (c *Cache) Delete(key string) {
c.Client.Delete(cacheKey(key))
}
// New returns a new Cache using the provided memcache server(s) with equal
// weight. If a server is listed multiple times, it gets a proportional amount
// of weight.
func New(server ...string) *Cache {
return NewWithClient(memcache.New(server...))
}
// NewWithClient returns a new Cache with the given memcache client.
func NewWithClient(client *memcache.Client) *Cache {
return &Cache{client}
}

View File

@ -1,47 +0,0 @@
// +build !appengine
package memcache
import (
"bytes"
"net"
"testing"
)
const testServer = "localhost:11211"
func TestMemCache(t *testing.T) {
conn, err := net.Dial("tcp", testServer)
if err != nil {
// TODO: rather than skip the test, fall back to a faked memcached server
t.Skipf("skipping test; no server running at %s", testServer)
}
conn.Write([]byte("flush_all\r\n")) // flush memcache
conn.Close()
cache := New(testServer)
key := "testKey"
_, ok := cache.Get(key)
if ok {
t.Fatal("retrieved key before adding it")
}
val := []byte("some bytes")
cache.Set(key, val)
retVal, ok := cache.Get(key)
if !ok {
t.Fatal("could not retrieve an element we just added")
}
if !bytes.Equal(retVal, val) {
t.Fatal("retrieved a different value than what we put in")
}
cache.Delete(key)
_, ok = cache.Get(key)
if ok {
t.Fatal("deleted key still present")
}
}

View File

@ -1,43 +0,0 @@
// Package redis provides a redis interface for http caching.
package redis
import (
"github.com/gomodule/redigo/redis"
"github.com/gregjones/httpcache"
)
// cache is an implementation of httpcache.Cache that caches responses in a
// redis server.
type cache struct {
redis.Conn
}
// cacheKey modifies an httpcache key for use in redis. Specifically, it
// prefixes keys to avoid collision with other data stored in redis.
func cacheKey(key string) string {
return "rediscache:" + key
}
// Get returns the response corresponding to key if present.
func (c cache) Get(key string) (resp []byte, ok bool) {
item, err := redis.Bytes(c.Do("GET", cacheKey(key)))
if err != nil {
return nil, false
}
return item, true
}
// Set saves a response to the cache as key.
func (c cache) Set(key string, resp []byte) {
c.Do("SET", cacheKey(key), resp)
}
// Delete removes the response with key from the cache.
func (c cache) Delete(key string) {
c.Do("DEL", cacheKey(key))
}
// NewWithClient returns a new Cache with the given redis connection.
func NewWithClient(client redis.Conn) httpcache.Cache {
return cache{client}
}

View File

@ -1,43 +0,0 @@
package redis
import (
"bytes"
"testing"
"github.com/gomodule/redigo/redis"
)
func TestRedisCache(t *testing.T) {
conn, err := redis.Dial("tcp", "localhost:6379")
if err != nil {
// TODO: rather than skip the test, fall back to a faked redis server
t.Skipf("skipping test; no server running at localhost:6379")
}
conn.Do("FLUSHALL")
cache := NewWithClient(conn)
key := "testKey"
_, ok := cache.Get(key)
if ok {
t.Fatal("retrieved key before adding it")
}
val := []byte("some bytes")
cache.Set(key, val)
retVal, ok := cache.Get(key)
if !ok {
t.Fatal("could not retrieve an element we just added")
}
if !bytes.Equal(retVal, val) {
t.Fatal("retrieved a different value than what we put in")
}
cache.Delete(key)
_, ok = cache.Get(key)
if ok {
t.Fatal("deleted key still present")
}
}