Documentation ¶
Index ¶
Constants ¶
View Source
const (
MaxRecordLimit = 1000
)
Variables ¶
View Source
var ( // Errors ErrorRecordNotFound = errors.New("record not found") )
View Source
var Routes = []Route{ Route{ GetRecord, http.MethodGet, "/records/:id", []server.ResponseSetting{}, }, Route{ FindRecords, http.MethodGet, "/records", []server.ResponseSetting{}, }, }
Routes is a list of Indexer server routes
View Source
var V1 = func() Controller { controllerOnce.Do(func() { var cfg Config if err := config.Load(&cfg); err != nil { panic(err) } ctx := context.Background() db, err := cdxjdb.New( ctx, cfg.DatabaseAddr, cfg.DropDatabaseOnStart, ) if err != nil { panic(fmt.Errorf( "Controller: failed to connect to database at "+ "address ('%s') with error: %s", cfg.DatabaseAddr, err, )) } control = New(ctx, db) }) return control }
Functions ¶
func FindRecords ¶
func FindRecords(w http.ResponseWriter, r *http.Request, p server.Parameters)
FindRecords handles a request to find CDXJ records matching a given set of values
func GetRecord ¶
func GetRecord(w http.ResponseWriter, r *http.Request, p server.Parameters)
GetRecord handles requests to retrieve a CDXJ record matching a given ID
Types ¶
type Config ¶
type Config struct { DatabaseAddr string `toml:"database_addr"` DropDatabaseOnStart bool `toml:"drop_database_on_start"` }
Config represents the configuration of an Indexer controller
type Controller ¶
type Controller interface { // FindRecords searches for records that match the given values and returns // a list of matching records FindRecords( surt string, types []simplecdxj.RecordType, before, after string, match models.TextMatch, limit int, ) (models.Records, error) // GetRecord returns the record for the given record ID GetRecord(id string) (models.Record, error) }
Controller represents an interface of an WARC-CDXJ record indexer's controller
func New ¶
func New(ctx context.Context, db cdxjdb.CdxjRecords) Controller
New returns a new Controller
Click to show internal directories.
Click to hide internal directories.