links

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const Index = ".index"

Index is used for special handling for the root path; it is stored in the database as the "index" key.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(store Store, ks *token.VerificationKeyset) http.Handler

NewHandler sets up routes based on the given key value store.

Types

type MemStore

type MemStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

MemStore is an in-memory store of links.

func NewMemStore

func NewMemStore() *MemStore

func (*MemStore) Delete

func (s *MemStore) Delete(ctx context.Context, k string) error

func (*MemStore) Get

func (s *MemStore) Get(ctx context.Context, k string) (*pb.LinkEntry, error)

func (*MemStore) Put

func (s *MemStore) Put(ctx context.Context, k string, l *pb.Link) (bool, error)

func (*MemStore) Visit

func (s *MemStore) Visit(ctx context.Context, visit func(string, *pb.LinkEntry)) error

type PostgresStore

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

func NewPostgresStore

func NewPostgresStore(ctx context.Context, source string) (*PostgresStore, error)

func (*PostgresStore) Close

func (s *PostgresStore) Close()

func (*PostgresStore) Delete

func (s *PostgresStore) Delete(ctx context.Context, key string) error

func (*PostgresStore) Get

func (s *PostgresStore) Get(ctx context.Context, key string) (*pb.LinkEntry, error)

func (*PostgresStore) Put

func (s *PostgresStore) Put(ctx context.Context, key string, l *pb.Link) (bool, error)

func (*PostgresStore) Visit

func (s *PostgresStore) Visit(ctx context.Context, visit func(string, *pb.LinkEntry)) error

type Store

type Store interface {
	Get(ctx context.Context, k string) (*pb.LinkEntry, error)
	Put(ctx context.Context, k string, l *pb.Link) (bool, error)
	Delete(ctx context.Context, k string) error
	Visit(ctx context.Context, visit func(string, *pb.LinkEntry)) error
}

Jump to

Keyboard shortcuts

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