Documentation ¶
Index ¶
- type AerospikeBackend
- type AerospikeDB
- type AerospikeDBClient
- type Backend
- type CassandraBackend
- type CassandraDB
- type CassandraDBClient
- type ErrorProneAerospikeClient
- type ErrorProneCassandraClient
- type ErrorProneMemcache
- type ErrorProneMemoryClient
- type FakeRedisClient
- type GoodAerospikeClient
- type GoodCassandraClient
- type GoodMemcache
- type Memcache
- type MemcacheBackend
- type MemcacheDataStore
- type MemoryBackend
- type RedisBackend
- type RedisDB
- type RedisDBClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AerospikeBackend ¶
type AerospikeBackend struct {
// contains filtered or unexported fields
}
AerospikeBackend upon creation will instantiates, and configure the Aerospike client. Implements the Backend interface
func NewAerospikeBackend ¶
func NewAerospikeBackend(cfg config.Aerospike, metrics *metrics.Metrics) *AerospikeBackend
NewAerospikeBackend validates config.Aerospike and returns an AerospikeBackend
func NewMockAerospikeBackend ¶
func NewMockAerospikeBackend(mockClient AerospikeDB) *AerospikeBackend
------------------------------------------ Aerospike client mocks ------------------------------------------
func (*AerospikeBackend) Get ¶
Get creates an aerospike key based on the UUID key parameter, perfomrs the client's Get call and validates results. Can return a KEY_NOT_FOUND error or other Aerospike server errors
type AerospikeDB ¶
type AerospikeDB interface { NewUUIDKey(namespace string, key string) (*as.Key, error) Get(key *as.Key) (*as.Record, error) Put(policy *as.WritePolicy, key *as.Key, binMap as.BinMap) error }
AerospikeDB is a wrapper for the Aerospike client
type AerospikeDBClient ¶
type AerospikeDBClient struct {
// contains filtered or unexported fields
}
AerospikeDBClient implements the AerospikeDB interface
func (*AerospikeDBClient) NewUUIDKey ¶
NewUUIDKey creates an aerospike key so we can store data under it
func (AerospikeDBClient) Put ¶
func (db AerospikeDBClient) Put(policy *as.WritePolicy, key *as.Key, binMap as.BinMap) error
Put performs the as.Client Put operation
type Backend ¶
type Backend interface { Put(ctx context.Context, key string, value string, ttlSeconds int) error Get(ctx context.Context, key string) (string, error) }
Backend interface for storing data
type CassandraBackend ¶
type CassandraBackend struct {
// contains filtered or unexported fields
}
CassandraBackend implements the Backend interface and get called from our Prebid Cache's endpoint handle functions.
func NewCassandraBackend ¶
func NewCassandraBackend(cfg config.Cassandra) *CassandraBackend
NewCassandraBackend expects a valid config.Cassandra object
func NewMockCassandraBackend ¶
func NewMockCassandraBackend(ttl int, mockClient CassandraDB) *CassandraBackend
------------------------------------------ Cassandra client mocks ------------------------------------------
func (*CassandraBackend) Get ¶
Get makes the Cassandra client to retrieve the value that has been previously stored under 'key'. Returns KeyNotFoundError if no such key has ever been stored in the Cassandra database service
func (*CassandraBackend) Put ¶
func (back *CassandraBackend) Put(ctx context.Context, key string, value string, ttlSeconds int) error
Put makes the Cassandra client to store `value` only if `key` doesn't exist in the storage already. If it does, no operation is performed and Put returns RecordExistsError
type CassandraDB ¶
type CassandraDB interface { Init() error Get(ctx context.Context, key string) (string, error) Put(ctx context.Context, key string, value string, ttlSeconds int) (bool, error) }
CassandraDB is an interface that helps us communicate with a cassandra storage service using the cassandra "github.com/gocql/gocql" client
type CassandraDBClient ¶
type CassandraDBClient struct {
// contains filtered or unexported fields
}
CassandraDBClient is a wrapper for the Cassandra client 'gocql' that interacts with the Cassandra server and implements the CassandraDB interface
func (*CassandraDBClient) Init ¶
func (c *CassandraDBClient) Init() error
Init initializes Cassandra cluster and session with the configuration loaded from environment variables or configuration files at startup
func (*CassandraDBClient) Put ¶
func (c *CassandraDBClient) Put(ctx context.Context, key string, value string, ttlSeconds int) (bool, error)
Put writes the `value` under the provided `key` in the Cassandra DB server only if it doesn't already exist. We make sure of this by adding the 'IF NOT EXISTS' clause to the 'INSERT' query
type ErrorProneAerospikeClient ¶
type ErrorProneAerospikeClient struct {
ServerError string
}
func (*ErrorProneAerospikeClient) NewUUIDKey ¶
func (*ErrorProneAerospikeClient) Put ¶
func (c *ErrorProneAerospikeClient) Put(policy *as.WritePolicy, key *as.Key, binMap as.BinMap) error
type ErrorProneCassandraClient ¶
func (*ErrorProneCassandraClient) Init ¶
func (ec *ErrorProneCassandraClient) Init() error
type ErrorProneMemcache ¶
type ErrorProneMemcache struct {
ServerError error
}
type ErrorProneMemoryClient ¶
type ErrorProneMemoryClient struct{}
func NewErrorResponseMemoryBackend ¶
func NewErrorResponseMemoryBackend() *ErrorProneMemoryClient
------------------------------------------ Memory client mocks ------------------------------------------
type FakeRedisClient ¶
type GoodAerospikeClient ¶
Aerospike client that does not throw errors
func (*GoodAerospikeClient) NewUUIDKey ¶
func (*GoodAerospikeClient) Put ¶
func (c *GoodAerospikeClient) Put(policy *as.WritePolicy, aeKey *as.Key, binMap as.BinMap) error
type GoodCassandraClient ¶
Cassandra client client that does not throw errors
func (*GoodCassandraClient) Init ¶
func (gc *GoodCassandraClient) Init() error
type GoodMemcache ¶
Memcache client that does not throw errors
type Memcache ¶
type Memcache struct {
// contains filtered or unexported fields
}
Memcache Object use to implement MemcacheDataStore interface
func (*Memcache) Get ¶
Get uses the github.com/bradfitz/gomemcache/memcache library to retrieve the value stored under 'key', if any
func (*Memcache) Put ¶
Put uses the github.com/bradfitz/gomemcache/memcache library to store 'value' under 'key'. Because Prebid Cache doesn't implement 'upsert', Put calls Add(item *Item), that writes the given item only if no value already exists for its key as opposed to Set(item *Item), or Replace(item *Item)
type MemcacheBackend ¶
type MemcacheBackend struct {
// contains filtered or unexported fields
}
MemcacheBackend implements the Backend interface
func NewMemcacheBackend ¶
func NewMemcacheBackend(cfg config.Memcache) *MemcacheBackend
NewMemcacheBackend creates a new memcache backend and expects a valid 'cfg config.Memcache' argument
func NewMockMemcacheBackend ¶
func NewMockMemcacheBackend(mockClient MemcacheDataStore) *MemcacheBackend
------------------------------------------ Memcache client mocks ------------------------------------------
func (*MemcacheBackend) Get ¶
Get makes the MemcacheDataStore client to retrieve the value that has been previously stored under 'key'. If unseuccessful, returns an empty value and a KeyNotFoundError or other, memcache-related error
type MemcacheDataStore ¶
type MemcacheDataStore interface { Get(key string) (*memcache.Item, error) Put(key string, value string, ttlSeconds int) error }
MemcacheDataStore is an interface that helps us communicate with an instance of the memcached cache server. Its implementation is intended to use the "github.com/bradfitz/gomemcache/memcache" client
type MemoryBackend ¶
type MemoryBackend struct {
// contains filtered or unexported fields
}
MemoryBackend stores information in the local memory heap. Stored data dissapears upon Prebid Cache restart
func NewMemoryBackend ¶
func NewMemoryBackend() *MemoryBackend
NewMemoryBackend instances a MemoryBackend struct
func NewMemoryBackendWithValues ¶
func NewMemoryBackendWithValues(customData map[string]string) (*MemoryBackend, error)
Good memory client does not throw errors
type RedisBackend ¶
type RedisBackend struct {
// contains filtered or unexported fields
}
RedisBackend when initialized will instantiate and configure the Redis client. It implements the Backend interface.
func NewFakeRedisBackend ¶
func NewFakeRedisBackend(mockClient RedisDB) *RedisBackend
------------------------------------------ Redis client mocks ------------------------------------------
func NewRedisBackend ¶
func NewRedisBackend(cfg config.Redis, ctx context.Context) *RedisBackend
NewRedisBackend initializes the redis client and pings to make sure connection was successful
func (*RedisBackend) Get ¶
Get calls the Redis client to return the value associated with the provided `key` parameter and interprets its response. A `Nil` error reply of the Redis client means the `key` does not exist.
func (*RedisBackend) Put ¶
Put writes the `value` under the provided `key` in the Redis storage server. Because the backend implementation of Put calls SetNX(item *Item), a `false` return value is interpreted as the data not being written because the `key` already holds a value, and a RecordExistsError is returned
type RedisDB ¶
type RedisDB interface { Get(ctx context.Context, key string) (string, error) Put(ctx context.Context, key string, value string, ttlSeconds int) (bool, error) }
RedisDB is an interface that helps us communicate with an instance of a Redis database. Its implementation is intended to use the "github.com/go-redis/redis" client
type RedisDBClient ¶
type RedisDBClient struct {
// contains filtered or unexported fields
}
RedisDBClient is a wrapper for the Redis client that implements the RedisDB interface