sitemap

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package sitemap provides a service to generated sitemaps

It requires an implementation of the Store interface to render content.

All sitemap formats limit a single sitemap to 10MB (uncompressed) and 50,000 URLs.

For a single Sitemap index file, the maximum capacity of URLs and storage

  could be calculated as described below:

  in terms of URLs:

	50,000 sitemaps = ( 50,000 * 50,000 ) URLs = 2,500,000,000 URLs

  in terms of size:

	50MB + (50,000 sitemaps * 50MB) = 2,500,050 MB = > 2.3 TB

These limits are enforced by the http.Handlers in this package.

Index

Constants

This section is empty.

Variables

View Source
var ErrConfigNotFound = errors.New("sitemap configuration not found")

Functions

This section is empty.

Types

type Config

type Config struct {
	ID            string   `json:"id"`
	BaseURL       string   `json:"baseURL"`
	Query         string   `json:"query"`
	Filters       []string `json:"filters"` // qf and q URL params
	OrgID         string   `json:"-"`
	ExcludedSpecs []string `json:"excludedSpecs"`
}

func (*Config) IsExcludedSpec

func (c *Config) IsExcludedSpec(spec string) bool

type Location

type Location struct {
	ID          string // relative path to unique identifier
	LastMod     *time.Time
	RecordCount int64
}

type Option

type Option func(*Service) error

func SetStore

func SetStore(store Store) Option

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(options ...Option) (*Service, error)

func (*Service) Routes

func (s *Service) Routes(pattern string, router chi.Router)

func (*Service) ServeHTTP

func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Service) SetServiceBuilder

func (s *Service) SetServiceBuilder(b *domain.ServiceBuilder)

func (*Service) Shutdown

func (s *Service) Shutdown(ctx context.Context) error

type Store

type Store interface {
	Datasets(ctx context.Context, cfg Config) (locations []Location, err error)
	LocationCount(ctx context.Context, cfg Config) (int, error)
	Locations(ctx context.Context, cfg Config, start, end int) []Location
}

Jump to

Keyboard shortcuts

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