db

package
v0.0.0-...-949a5e8 Latest Latest
Warning

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

Go to latest
Published: May 9, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateSearchQuery

func GenerateSearchQuery(depth int) string

Types

type Article

type Article struct {
	UID            string    `json:"uid,omitempty"`
	Title          string    `json:"title,omitempty"`
	Description    string    `json:"description,omitempty"`
	Missing        bool      `json:"missing,omitempty"`
	LinkedArticles []Article `json:"linked_articles,omitempty"`
	LastCrawled    string    `json:"last_crawled,omitempty"`
	DType          []string  `json:"D_type,omitempty"`
	PageID         int       `json:"page_id,omitempty"`
}

Article contains information about a MediaWiki article

type Config

type Config struct {
	Host string `json:"dgraph-host"`
	Port int    `json:"dgraph-port"`
}

type DB

type DB interface {
	// AddVisited writes the visited article and its edges with other articles.
	// It should be called after each article has been visited.
	AddVisited(*Article) error

	// NextsToVisit returns a list of Titles at random from the list of articles that have yet
	// to be visited. If there is nothing to visit, this function blocks
	// indefinitely until there is one.
	NextsToVisit(count int) ([]string, error)
}

DB is the interface to interact with a database

type DGraph

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

DGraph is a connection to a dgraph instance

func NewDGraph

func NewDGraph(config Config) (*DGraph, error)

NewDGraph returns a new *DGraph

func (*DGraph) AddVisited

func (dg *DGraph) AddVisited(article *Article) error

func (*DGraph) NextsToVisit

func (dg *DGraph) NextsToVisit(count int) ([]string, error)

func (*DGraph) SearchArticleByTitle

func (dg *DGraph) SearchArticleByTitle(s string, depth int) ([]Article, error)

func (*DGraph) SearchArticleByUid

func (dg *DGraph) SearchArticleByUid(uid string, depth int) ([]Article, error)

func (*DGraph) ShortestPath

func (dg *DGraph) ShortestPath(from string, to string) ([]Article, error)

Jump to

Keyboard shortcuts

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