storage

package
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2018 License: MIT Imports: 3 Imported by: 6 modules, 5 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// GreyListTTL defined the TTL of a repository in seconds: 30 days (~30 days)
	GreyListTTL = 60 * 60 * 24 * 30
)
View Source
const (
	// RedisOK is the standard response of a Redis server if everything went fine ("OK")
	RedisOK = "OK"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection interface {
	io.Closer

	// MarkRepositoryAsTweeted marks a single projects as "already tweeted".
	// This information will be stored in Redis as a simple set with a TTL.
	// The timestamp of the tweet will be used as value.
	MarkRepositoryAsTweeted(projectName, score string) (bool, error)

	// IsRepositoryAlreadyTweeted checks if a project was already tweeted.
	// If it is not available
	//	a) the project was not tweeted yet
	//	b) the project ttl expired and is ready to tweet again
	IsRepositoryAlreadyTweeted(projectName string) (bool, error)
}

Connection represents a single connection out of a pool from a storage type.

type MemoryConnection

type MemoryConnection struct {
	// contains filtered or unexported fields
}

MemoryConnection represents a in memory connection

func (*MemoryConnection) Close

func (mc *MemoryConnection) Close() error

Close shuts down a in memory connection

func (*MemoryConnection) IsRepositoryAlreadyTweeted

func (mc *MemoryConnection) IsRepositoryAlreadyTweeted(projectName string) (bool, error)

IsRepositoryAlreadyTweeted checks if a project was already tweeted. If it is not available

a) the project was not tweeted yet
b) the project ttl expired and is ready to tweet again

func (*MemoryConnection) MarkRepositoryAsTweeted

func (mc *MemoryConnection) MarkRepositoryAsTweeted(projectName, score string) (bool, error)

MarkRepositoryAsTweeted marks a single projects as "already tweeted". This information will be stored as a hashmap with a TTL. The timestamp of the tweet will be used as value.

type MemoryPool

type MemoryPool struct {
	// contains filtered or unexported fields
}

MemoryPool is the pool of connections to your local memory ;)

func (MemoryPool) Close

func (mp MemoryPool) Close() error

Close closes a in memory pool

func (MemoryPool) Get

func (mp MemoryPool) Get() Connection

Get returns you a connection to your in memory storage

type MemoryStorage

type MemoryStorage struct{}

MemoryStorage represents the in memory storage engine. This storage can be useful for debugging / development

func (*MemoryStorage) NewPool

func (ms *MemoryStorage) NewPool(url, auth string) Pool

NewPool returns a pool to communicate with your in memory

type MemoryStorageContainer

type MemoryStorageContainer map[string]time.Time

MemoryStorageContainer is the backend of the "in memory" storage engine. It supports a key (string) and a duration as time. The time duration can act as a TTL.

type Pool

type Pool interface {
	io.Closer
	Get() Connection
}

Pool is the implementation of a specific storage type. It should handle a pool of connections to communicate with the storage type.

func NewBackend added in v0.4.0

func NewBackend(storageURL string, storageAuth string, debug bool) Pool

NewBackend returns a new connection pool based on the requested storage engine.

type RedisConnection

type RedisConnection struct {
	// contains filtered or unexported fields
}

RedisConnection represents a single connection to a redis instance.

func (*RedisConnection) Close

func (rc *RedisConnection) Close() error

Close will close a single redis connection

func (*RedisConnection) IsRepositoryAlreadyTweeted

func (rc *RedisConnection) IsRepositoryAlreadyTweeted(projectName string) (bool, error)

IsRepositoryAlreadyTweeted checks if a project was already tweeted. If it is not available

a) the project was not tweeted yet
b) the project ttl expired and is ready to tweet again

func (*RedisConnection) MarkRepositoryAsTweeted

func (rc *RedisConnection) MarkRepositoryAsTweeted(projectName, score string) (bool, error)

MarkRepositoryAsTweeted marks a single projects as "already tweeted". This information will be stored in Redis as a simple set with a TTL. The timestamp of the tweet will be used as value.

type RedisPool

type RedisPool struct {
	// contains filtered or unexported fields
}

RedisPool is the connection pool to a redis instance

func (RedisPool) Close

func (rp RedisPool) Close() error

Close will close a connection pool

func (RedisPool) Get

func (rp RedisPool) Get() Connection

Get will return a new connection out the pool

type RedisStorage

type RedisStorage struct{}

RedisStorage represents the storage engine based on the Redis project / server

func (*RedisStorage) NewPool

func (rs *RedisStorage) NewPool(url, auth string) Pool

NewPool returns a new redis connection pool

type Storage

type Storage interface {
	NewPool(url, auth string) Pool
}

Storage represents a new storage type. Examples as storages are Redis or in memory.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL