Documentation ¶
Index ¶
- Constants
- Variables
- type MemoryURL
- func (m *MemoryURL) Count(ctx context.Context, key string) (int, error)
- func (m *MemoryURL) Get(ctx context.Context, key string) (string, error)
- func (m *MemoryURL) Inc(ctx context.Context, key string) error
- func (m *MemoryURL) Set(ctx context.Context, key string, url string, expire *time.Time, count int) (string, error)
- type MongoURL
- func (s *MongoURL) Count(ctx context.Context, key string) (int, error)
- func (s *MongoURL) Get(ctx context.Context, key string) (string, error)
- func (s *MongoURL) Inc(ctx context.Context, key string) error
- func (s *MongoURL) Set(ctx context.Context, key, url string, expire *time.Time, count int) (string, error)
- type URL
- type Usage
Constants ¶
View Source
const (
Collection = "urls"
)
Collection is a name of the MongoDB collection for URLs.
Variables ¶
View Source
var ( // ErrKeyNotFound indicates that given key does not exist on database. ErrKeyNotFound = errors.New("given key does not exist or expired") // ErrDuplicateKey indicates that given key is exists on database. ErrDuplicateKey = errors.New("given key is exist") )
Functions ¶
This section is empty.
Types ¶
type MemoryURL ¶
type MemoryURL struct {
// contains filtered or unexported fields
}
func NewMemoryURL ¶
func NewMemoryURL() *MemoryURL
type MongoURL ¶
MongoURL communicate with url collections in MongoDB.
func NewMongoURL ¶
NewMongoURL creates new URL store.
func (*MongoURL) Count ¶
Count retrieves number of access for the url of the given key if it exists.
type URL ¶
type URL interface { Inc(ctx context.Context, key string) error Set(ctx context.Context, key, url string, expire *time.Time, count int) (string, error) Get(ctx context.Context, key string) (string, error) Count(ctx context.Context, key string) (int, error) }
URL stores and retrieves urls.
type Usage ¶
type Usage struct { InsertedCounter prometheus.Counter FetchedCounter prometheus.Counter }
Usage contains metrics to meter database insert/retrieve.
Click to show internal directories.
Click to hide internal directories.