rulestat

package
v0.0.0-...-f179113 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package rulestat contains the filtering rule statistics collector and API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Empty

type Empty struct{}

Empty is an Interface implementation that does nothing.

func (Empty) Collect

func (Empty) Collect(_ context.Context, _ filter.ID, _ filter.RuleText)

Collect implements the Interface interface for Empty.

type HTTP

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

HTTP is the filtering rule statistics collector that uploads the statistics to the given URL when it's refreshed.

TODO(a.garipov): Add tests.

func NewHTTP

func NewHTTP(c *HTTPConfig) (s *HTTP)

NewHTTP returns a new statistics collector with HTTP upload.

func (*HTTP) Collect

func (s *HTTP) Collect(_ context.Context, id filter.ID, text filter.RuleText)

Collect implements the Interface interface for *HTTP.

func (*HTTP) Refresh

func (s *HTTP) Refresh(ctx context.Context) (err error)

Refresh implements the agdservice.Refresher interface for *HTTP. It uploads the collected statistics to s.u and starts collecting a new set of statistics.

type HTTPConfig

type HTTPConfig struct {
	// Logger is used for logging the operation of the statistics collector.
	Logger *slog.Logger

	// ErrColl is used to collect errors during refreshes.
	ErrColl errcoll.Interface

	// URL is the URL to which the statistics is uploaded.
	URL *url.URL
}

HTTPConfig is the configuration structure for the filtering rule statistics collector that uploads the statistics to a URL. All fields must not be nil.

type Interface

type Interface interface {
	Collect(ctx context.Context, id filter.ID, r filter.RuleText)
}

Interface is an ephemeral storage of the filtering rule list statistics interface.

All methods must be safe for concurrent use.

Jump to

Keyboard shortcuts

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