store

package
v0.0.0-...-407f28a Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package store contains entities and services to process and contain them.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is an error that is returned when the requested entity is not found.

Functions

This section is empty.

Types

type Article

type Article struct {
	URL          string `json:"url"`
	Title        string `json:"title"`
	Excerpt      string `json:"excerpt"`
	Content      string `json:"content"`
	Author       string `json:"author"`
	ImageURL     string `json:"image_url"`
	BulletPoints string `json:"bullet_points"`
}

Article is a struct that contains the extracted article.

type Bolt

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

Bolt is a storage that uses BoltDB as a backend.

func NewBolt

func NewBolt(dir string) (*Bolt, error)

NewBolt creates new Bolt storage.

func (*Bolt) Close

func (b *Bolt) Close() error

Close closes the storage.

func (*Bolt) Delete

func (b *Bolt) Delete(_ context.Context, id string) error

Delete removes user from storage.

func (*Bolt) Get

func (b *Bolt) Get(_ context.Context, id string) (u User, err error)

Get returns user from storage.

func (*Bolt) List

func (b *Bolt) List(context.Context, ListRequest) ([]User, error)

List returns all users from storage.

func (*Bolt) Put

func (b *Bolt) Put(_ context.Context, u User) error

Put puts user to storage.

type Interface

type Interface interface {
	Put(ctx context.Context, u User) error
	Get(ctx context.Context, chatID string) (User, error)
	List(ctx context.Context, req ListRequest) ([]User, error)
	Delete(ctx context.Context, chatID string) error
}

Interface defines methods for store

type ListRequest

type ListRequest struct{}

ListRequest defines parameters for listing users from store.

type User

type User struct {
	ChatID     string `json:"chat_id"`
	Username   string `json:"username"`
	Authorized bool   `json:"authorized"`
	Subscribed bool   `json:"subscribed"`
}

User is a struct that contains the user's data.

Jump to

Keyboard shortcuts

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