cron

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

This section is empty.

Functions

This section is empty.

Types

type Cron

type Cron struct {
	ID      uint     `json:"id"`
	UserID  int      `json:"userId"`
	Sources []string `json:"sources"`
	Q       string   `json:"q"`
}

type HTTPServer

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

Server defines the interface to register the http handlers.

type Notifier

type Notifier interface {
	Notify(ctx context.Context, papers []Paper) error
}

type NotifierFactory

type NotifierFactory func(cron Cron) (Notifier, error)

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 {
	GetForUser(ctx context.Context, userID int) ([]Cron, error)
	List(ctx context.Context) ([]Cron, error)
	Insert(ctx context.Context, cron *Cron) error
	Delete(ctx context.Context, id uint) error
}

type ResultRepository

type ResultRepository interface {
	Insert(ctx context.Context, cronID uint, paper Paper) error
	GetLastResult(ctx context.Context, cronID uint, source string) (Paper, error)
}

type SearchResults

type SearchResults struct {
	Papers     []Paper `json:"papers"`
	Pagination struct {
		Limit  uint `json:"limit"`
		Offset uint `json:"offset"`
		Total  uint `json:"total"`
	} `json:"pagination"`
}

type Service

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

func NewService

func NewService(
	repo Repository,
	resultRepo ResultRepository,
	notifierFactory NotifierFactory,
	importsClient *imports.Client,
	logger log.Logger,
) *Service

func (*Service) GetForUser

func (s *Service) GetForUser(ctx context.Context, userID int) ([]Cron, error)

func (*Service) Insert

func (s *Service) Insert(ctx context.Context, cron *Cron) error

func (*Service) RegisterHTTP

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

func (*Service) RunCrons

func (s *Service) RunCrons(ctx context.Context) error

func (*Service) StartCron

func (s *Service) StartCron(ctx context.Context)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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