paste

package
v0.0.0-...-2f4042c Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package pastes implements business logic.

Index

Constants

View Source
const (
	GCItems    = 5
	GCDays     = 3
	GCSchedule = "@hourly"
)

Predefined consts identify PGC behaviour.

Variables

View Source
var (
	ErrNotFound           = errors.New("Paste not found")
	ErrInvalidID          = errors.New("Paste UUID is invalid")
	ErrNotEnoughDataForGC = errors.New("Not enough data for GC")
	ErrStorageNotReady    = errors.New("Storage not ready")
)

Predefined errors identify expected failure conditions.

Functions

This section is empty.

Types

type Paste

type Paste struct {
	ID      string    `json:"id"`
	Name    string    `json:"name" binding:"required"`
	Created time.Time `json:"created"`
	Body    string    `json:"body" binding:"required"`
}

Paste is an item we store.

type Storage

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

func (*Storage) Add

func (s *Storage) Add(np Paste) (*Paste, error)

Add adds a Paste to the slice of Pastes (pasteList).

func (*Storage) Get

func (s *Storage) Get(id string) (*Paste, error)

Get retrieve a single paste identified by id.

func (*Storage) Kill

func (s *Storage) Kill() ([]Paste, error)

Kill purges list of Pastes.

func (*Storage) List

func (s *Storage) List() ([]Paste, error)

List gets all Pastes from the slice of Pastes.

func (*Storage) PGCRun

func (s *Storage) PGCRun() (int, error)

PGCRun checks if Pastes' creation dates are older than `GCDays` and removes `GCItems` of pastes from the slice of Pastes.

func (*Storage) Ping

func (s *Storage) Ping() (bool, error)

Ping checks if Storage has been created

Jump to

Keyboard shortcuts

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