index

package module
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2021 License: BSD-3-Clause Imports: 13 Imported by: 24

README

go-whosonfirst-index

Go package for indexing Who's On First documents

Install

You will need to have both Go (specifically a version 1.12 or higher) and the make programs installed on your computer. Assuming you do just type:

make tools

All of this package's dependencies are bundled with the code in the vendor directory.

Example

package main

import (
       "context"
       "flag"
       "github.com/whosonfirst/go-whosonfirst-index"
       _ "github.com/whosonfirst/go-whosonfirst-index/fs"              
       "io"
       "log"
)

func main() {

	var dsn = flag.String("dsn", "repo://", "A valid go-whosonfirst-index DSN")
	
     	flag.Parse()
	
	cb := func(ctx context.Context, fh io.Reader, args ...interface{}) error {

		path, _ := index.PathForContext(ctx)

		log.Println("PATH", path)
		return nil
	}

	i, _ := index.NewIndexer(*dsn, cb)

	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()

	paths := flag.Args()

	i.Index(ctx, paths...)
}	

Error handling removed for the sake of brevity.

Documentation

Index

Constants

View Source
const (
	STDIN = "STDIN"
)

Variables

This section is empty.

Functions

func AssignPathContext added in v0.2.0

func AssignPathContext(ctx context.Context, path string) context.Context

func ContextForPath

func ContextForPath(path string) (context.Context, error)

func Drivers added in v0.2.0

func Drivers() []string

func Modes

func Modes() []string

func PathForContext

func PathForContext(ctx context.Context) (string, error)

func Register added in v0.2.0

func Register(name string, driver Driver)

Types

type Driver added in v0.2.0

type Driver interface {
	Open(string) error
	IndexURI(context.Context, IndexerFunc, string) error
}

type Indexer

type Indexer struct {
	Driver  Driver
	Func    IndexerFunc
	Logger  *log.WOFLogger
	Indexed int64
	// contains filtered or unexported fields
}

func NewIndexer

func NewIndexer(dsn string, f IndexerFunc) (*Indexer, error)

func NewIndexerWithQuerySet added in v0.3.3

func NewIndexerWithQuerySet(ctx context.Context, indexer_uri string, indexer_cb IndexerFunc, qs *query.QuerySet) (*Indexer, error)

func (*Indexer) Index added in v0.2.0

func (i *Indexer) Index(ctx context.Context, paths ...string) error

func (*Indexer) IndexPath

func (i *Indexer) IndexPath(path string, args ...interface{}) error

func (*Indexer) IndexPaths

func (i *Indexer) IndexPaths(paths []string, args ...interface{}) error

func (*Indexer) IsIndexing

func (i *Indexer) IsIndexing() bool

type IndexerContextKey

type IndexerContextKey string

type IndexerFunc

type IndexerFunc func(ctx context.Context, fh io.Reader, args ...interface{}) error

func NewCallbackWithQuerySet added in v0.3.4

func NewCallbackWithQuerySet(ctx context.Context, indexer_cb IndexerFunc, qs *query.QuerySet) (IndexerFunc, error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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