collyzstandard

package module
v0.0.0-...-0f8e3e9 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2018 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

collyzstandard

collyzstandard is a Go package providing an experimental work-in-progress prototype of a cache compressor for Colly.

Installation

$ go get github.com/jimsmart/collyzstandard
import "github.com/jimsmart/collyzstandard"
Dependencies
  • Zstd — Go wrapper for Facebook's fast real-time compression algorithm.
  • Standard library.
  • Ginkgo and Gomega if you wish to run the tests.

Example

import "github.com/jimsmart/collysqlite"
import "github.com/jimsmart/collyzstandard"

cache := collysqlite.NewCache("./cache")
compcache := collyzstandard.NewCompressor(cache)

// TODO SetCache is a proposed method on colly.Collector that is currently unimplemented.
// c := colly.NewCollector()
// c.SetCache(compcache)
// ...

Documentation

GoDocs https://godoc.org/github.com/jimsmart/collyzstandard

Testing

To run the tests execute go test inside the project folder.

For a full coverage report, try:

$ go test -coverprofile=coverage.out && go tool cover -html=coverage.out

License

Package collyzstandard is copyright 2018 by Jim Smart and released under the MIT License

Documentation

Index

Constants

View Source
const DefaultCompressionLevel = zstd.BestCompression

DefaultCompressionLevel used, where fastest = 1, best = 20, default = 5.

Variables

This section is empty.

Functions

This section is empty.

Types

type CollyCache

type CollyCache interface {
	Init() error
	Get(url string) ([]byte, error)
	Put(url string, data []byte) error
	Remove(url string) error
}

CollyCache is the proposed interface for pluggable cache implementations in Colly.

type Compressor

type Compressor struct {
	Level   int
	Cache   CollyCache
	Logging bool
}

Compressor wraps a CollyCache to provide data compression using the Zstandard algorithm.

func NewCompressor

func NewCompressor(cache CollyCache) *Compressor

NewCompressor creates wraps the given CollyCache with a Compressor, configured to use the default (maximum) compression level.

func (*Compressor) Get

func (c *Compressor) Get(url string) ([]byte, error)

func (*Compressor) Init

func (c *Compressor) Init() error

func (*Compressor) Put

func (c *Compressor) Put(url string, data []byte) error

func (*Compressor) Remove

func (c *Compressor) Remove(url string) error

Jump to

Keyboard shortcuts

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