gcp

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2025 License: Apache-2.0 Imports: 16 Imported by: 2

Documentation

Overview

Package gcp contains a GCP-based antispam implementation for Tessera.

A Spanner database provides a mechanism for maintaining an index of hash --> log position for detecting duplicate submissions.

Index

Constants

View Source
const (
	DefaultMaxBatchSize      = 1500
	DefaultPushbackThreshold = 2048
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AntispamOpts

type AntispamOpts struct {
	// MaxBatchSize is the largest number of mutations permitted in a single BatchWrite operation when
	// updating the antispam index.
	//
	// Larger batches can enable (up to a point) higher throughput, but care should be taken not to
	// overload the Spanner instance.
	//
	// During testing, we've found that 1500 appears to offer maximum throughput when using Spanner instances
	// with 300 or more PU. Smaller deployments (e.g. 100 PU) will likely perform better with smaller batch
	// sizes of around 64.
	MaxBatchSize uint

	// PushbackThreshold allows configuration of when to start responding to Add requests with pushback due to
	// the antispam follower falling too far behind.
	//
	// When the antispam follower is at least this many entries behind the size of the locally integrated tree,
	// the antispam decorator will return a wrapped tessera.ErrPushback for every Add request.
	PushbackThreshold uint
}

AntispamOpts allows configuration of some tunable options.

type AntispamStorage

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

func NewAntispam

func NewAntispam(ctx context.Context, spannerDB string, opts AntispamOpts) (*AntispamStorage, error)

NewAntispam returns an antispam driver which uses Spanner to maintain a mapping of previously seen entries and their assigned indices.

Note that the storage for this mapping is entirely separate and unconnected to the storage used for maintaining the Merkle tree.

This functionality is experimental!

func (*AntispamStorage) Decorator

func (d *AntispamStorage) Decorator() func(f tessera.AddFn) tessera.AddFn

Decorator returns a function which will wrap an underlying Add delegate with code to dedup against the stored data.

func (*AntispamStorage) Follower

func (d *AntispamStorage) Follower(b func([]byte) ([][]byte, error)) stream.Follower

Follower returns a follower which knows how to populate the antispam index.

This implements tessera.Antispam.

Jump to

Keyboard shortcuts

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