index

package module
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2019 License: BSD-3-Clause Imports: 10 Imported by: 0

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/acaloiaro/go-whosonfirst-index"
       _ "github.com/acaloiaro/go-whosonfirst-index/fs"              
       "io"
       "log"
)

func main() {

	var dsn = flag.String("dsn", "repo://", "A valid go-whosonfirst-index DSN")
	
     	flag.Parse()
	
	cb := func(fh io.Reader, ctx context.Context, 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

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

func ContextForPath

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

func Drivers

func Drivers() []string

func Modes

func Modes() []string

func PathForContext

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

func Register

func Register(name string, driver Driver)

Types

type Driver

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 (*Indexer) Index

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

Directories

Path Synopsis
cmd
wof-index-count command

Jump to

Keyboard shortcuts

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