imports

package
v0.0.0-...-8a4eff6 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2017 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type HTTPServer

type HTTPServer interface {
	RegisterHandler(path, method string, f http.Handler)
}

Server defines the interface to register the http handlers.

type Pagination

type Pagination struct {
	Limit  uint `json:"limit"`
	Offset uint `json:"offset"`
	Total  uint `json:"total"`
}

type Paper

type Paper struct {
	ID int `json:"id"`

	Source    string `json:"source"`
	Reference string `json:"reference"`

	Title      string   `json:"title"`
	Summary    string   `json:"summary"`
	Tags       []string `json:"tags"`
	Authors    []string `json:"authors"`
	References []string `json:"references"`

	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

type Repository

type Repository interface {
	Save(userID, paperID int, source, ref string) error
	Get(userID int, source, ref string) (int, error)
}

type SearchResults

type SearchResults struct {
	Papers     []Paper    `json:"papers"`
	Pagination Pagination `json:"pagination"`
}

type Searcher

type Searcher interface {
	Source() string
	Search(ctx context.Context, q string, limit, offset int) (SearchResults, error)
}

type Service

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

func NewService

func NewService(repository Repository, paperClient *paper.Client, searchers ...Searcher) *Service

func (*Service) Import

func (s *Service) Import(ctx context.Context, userID int, p Paper) (Paper, error)

func (*Service) RegisterHTTP

func (s *Service) RegisterHTTP(srv HTTPServer, jwtKey []byte, ac *auth.Client)

func (*Service) Search

func (s *Service) Search(
	ctx context.Context,
	userID int,
	q string,
	limit int,
	offset int,
	sources []string,
) (map[string]SearchResults, error)

func (*Service) Sources

func (s *Service) Sources() []string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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