text_store

package
v0.0.0-...-75d57e1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_PASTEBIN_BYTES int = 10 << 20

Variables

View Source
var (
	ErrNotAUtf8String          = errors.New("Not a UTF-8 string")
	ErrMaxPastebinSizeExceeded = errors.New("Pastebin text too long")
	ErrInvalidExpiration       = errors.New("Attempt to create a pastebin that should have already expired")
)

Functions

func DeletePaste

func DeletePaste(db *badger.DB, slug Slug) error

func FindPaste

func FindPaste(db *badger.DB, slug Slug) (*pastebin_record.PastebinRecord, error)

func KeepalivePastebin

func KeepalivePastebin(db *badger.DB, slug Slug, newExpiry time.Time) error

/ KeepalivePastebin issues a new expiration for a pastebin.

func LookupPastebin

func LookupPastebin(db *badger.DB, slug Slug) (string, error)

func OpenDb

func OpenDb() *badger.DB

func RunMaintenance

func RunMaintenance(db *badger.DB) error

/ RunMaintenance maintains integrity of the storage, including removing expired pastes.

Types

type Slug

type Slug string

func GenerateTextSlug

func GenerateTextSlug(pb *pastebin_record.PastebinRecord) Slug

/ GenerateTextSlug uniquely encodes a body of bytes into a short string identifier.

func SavePastebin

func SavePastebin(db *badger.DB, text []byte, exp time.Time) (Slug, error)

func StoreNewPaste

func StoreNewPaste(db *badger.DB, record *pastebin_record.PastebinRecord) (Slug, error)

Jump to

Keyboard shortcuts

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