Documentation ¶
Index ¶
Constants ¶
const ( Strategy1st = "1st" StrategyConcurrent = "concurrent" )
Default registered strategies
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Article ¶
type Article struct { // Title should represent a short title or a summary of the // content Title string `json:"title"` // Content should contain the body of the article which may // be a snippet, wiki article, answer etc. Content string `json:"content"` // ContentType should contain the type of the content returned // so that radium can use that info to render the content. It // should be one of markdown, json, yaml, html ContentType string `json:"content_type"` // Attribs can contain type of the article, keywords etc. Attribs map[string]string `json:"attribs"` // License can contain name of the license if applicable License string `json:"license"` // Source should contain the name of the registered source // which returned this article. This will be added automatically // by radium. Source string `json:"source"` }
Article represents a radium article which can be a snippet, wiki, answer etc.
type Cache ¶
type Cache interface { Source // Set should store the given pair in a caching // backend for fast access. If an entry with same // query already exists, it should be replaced // with the new results slice Set(q Query, rs []Article) error }
Cache implementation is responsible for caching a given query-results pair for later use
type ClipboardMonitor ¶
type ClipboardMonitor struct { MaxWords int Interval time.Duration Instance *Instance // contains filtered or unexported fields }
ClipboardMonitor monitors the system clipboard and tries to use clipboard content as queries to radium. If the number of words in clipboard content is more than the maxWords, then ClipboardMonitor will not perform a radium query with it.
type Concurrent ¶
type Concurrent struct {
Logger
}
Concurrent is a radium strategy implementation.
func NewConcurrent ¶
func NewConcurrent(logger Logger) *Concurrent
NewConcurrent initializes a concurrent radium strategy
func (Concurrent) Execute ¶
func (con Concurrent) Execute(ctx context.Context, query Query, sources []RegisteredSource) ([]Article, error)
Execute the query against given list of sources concurrently. This strategy ignores the source errors and simply logs them.
type Instance ¶
type Instance struct { Logger // contains filtered or unexported fields }
Instance represents an instance of radium
func (Instance) GetSources ¶
func (ins Instance) GetSources() []RegisteredSource
GetSources returns a list of registered sources
func (*Instance) RegisterSource ¶
RegisterSource adds a new source to the query sources
func (*Instance) RegisterStrategy ¶
RegisterStrategy adds a new source to the query sources
type Logger ¶
type Logger interface { Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Warnf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Fatalf(format string, args ...interface{}) }
Logger implementation should provide logging functionality to the radium instance. Log levels should be managed externally.
type NthResult ¶
type NthResult struct { Logger // contains filtered or unexported fields }
NthResult implements a radium search strategy. This strategy executes search in the given order of sources and stops at nth result or if all the sources are executed.
func NewNthResult ¶
NewNthResult initializes NthResult strategy with given n
type Query ¶
type Query struct { // Text is the primary search criteria. Sources must // use this to find relevant results Text string `json:"text"` // Attribs can be used by sources to further filter down // the results Attribs map[string]string `json:"attribs"` }
Query represents a user query for a post
type RegisteredSource ¶
RegisteredSource embeds given Source along with the registered name.
type Server ¶
type Server struct { Logger // contains filtered or unexported fields }
Server represents an instance of HTTP API server