Documentation
¶
Overview ¶
Package crawler implements a STAC resource crawler.
Index ¶
- Variables
- func Crawl(resource string, visitor Visitor, options ...*Options) error
- func Join(resource string, visitor Visitor, options ...*Options) error
- func LinkTypeAnyJSON(link Link) bool
- func LinkTypeApplicationJSON(link Link) bool
- func LinkTypeGeoJSON(link Link) bool
- func LinkTypeNone(link Link) bool
- type Asset
- type ErrorHandler
- type Link
- type LinkMatcher
- type Links
- type Options
- type RecursionType
- type Resource
- type ResourceType
- type Task
- type Visitor
Constants ¶
This section is empty.
Variables ¶
var DefaultOptions = &Options{ Context: context.Background(), Recursion: Children, Concurrency: runtime.GOMAXPROCS(0), ErrorHandler: func(err error) error { return err }, }
DefaultOptions used when creating a new crawler.
Functions ¶
func Crawl ¶ added in v0.11.0
Crawl calls the visitor for each resolved resource.
The resource can be a file path or a URL. Any error returned by visitor will stop crawling and be returned by this function. Context cancellation will also stop crawling and the context error will be returned.
func Join ¶ added in v0.11.0
Join adds a crawler to an existing crawl instead of initiating a new one.
This is useful when two crawlers share the same queue and the first crawler has been taken down or the queue is getting too large. Join will return immediately if the queue of tasks is empty.
func LinkTypeAnyJSON ¶ added in v0.10.0
func LinkTypeApplicationJSON ¶ added in v0.10.0
func LinkTypeGeoJSON ¶ added in v0.10.0
func LinkTypeNone ¶ added in v0.10.0
Types ¶
type Asset ¶ added in v0.12.0
type Asset map[string]interface{}
Asset provides metadata about data for an item.
func (Asset) Description ¶ added in v0.12.0
Description returns the asset's description.
type ErrorHandler ¶ added in v0.11.0
ErrorHandler is called with any errors during a crawl. If the function returns nil, the crawl will continue. If the function returns an error, the crawl will stop.
type LinkMatcher ¶ added in v0.10.0
type Options ¶
type Options struct { // Optional context. If provided, the crawler will stop when the context is done. Context context.Context // Limit to the number of resources to fetch and visit concurrently. Concurrency int // Strategy to use when crawling linked resources. Use None to visit // a single resource. Use Children to only visit linked item/child resources. Recursion RecursionType // Optional function to limit which resources to crawl. If provided, the function // will be called with the URL or absolute path to a resource before it is crawled. // If the function returns false, the resource will not be read and the visitor will // not be called. Filter func(string) bool // Optional function to handle any errors during the crawl. By default, any error // will stop the crawl. To continue crawling on error, provide a function that // returns nil. ErrorHandler ErrorHandler // Optional queue to use for crawling tasks. If not provided, an in-memory queue // will be used. When running a crawl across multiple processes, it can be useful // to provide a queue that is shared across processes. Queue workgroup.Queue[*Task] }
Options for creating a crawler.
type RecursionType ¶
type RecursionType string
RecursionType informs the crawler how to treat linked resources. None will only call the visitor for the first resource. Children will call the visitor for all child catalogs, collections, and items. All will call the visitor for parent resources as well as child resources.
const ( None RecursionType = "none" Children RecursionType = "children" )
type Resource ¶
type Resource map[string]interface{}
Resource represents a STAC catalog, collection, or item.
func (Resource) ConformsTo ¶ added in v0.6.0
Returns the STAC / OGC Features API conformance classes (if any).
func (Resource) Extensions ¶
Extensions returns the resource extension URLs.
func (Resource) Type ¶
func (r Resource) Type() ResourceType
Type returns the specific resource type.
type ResourceType ¶
type ResourceType string
ResourceType indicates the STAC resource type.
const ( Item ResourceType = "item" Catalog ResourceType = "catalog" Collection ResourceType = "collection" )