seghandler

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrVerification = serrors.New("all segments failed to verify")
	ErrDB           = serrors.New("database error")
)

Errors

Functions

This section is empty.

Types

type DefaultStorage

type DefaultStorage struct {
	PathDB   pathdb.DB
	RevCache revcache.RevCache
}

DefaultStorage wraps path DB and revocation cache and offers convenience methods that implement the Storage interface.

func (*DefaultStorage) StoreRevs

func (s *DefaultStorage) StoreRevs(ctx context.Context,
	revs []*path_mgmt.RevInfo) error

StoreRevs stores the given revocations in the revocation cache.

func (*DefaultStorage) StoreSegs

func (s *DefaultStorage) StoreSegs(ctx context.Context, segs []*seg.Meta) (SegStats, error)

StoreSegs stores the given segments in the pathdb in a transaction.

type DefaultVerifier

type DefaultVerifier struct {
	Verifier infra.Verifier
}

DefaultVerifier is a convenience wrapper around segverifier that implements the Verifier interface.

func (*DefaultVerifier) Verify

func (v *DefaultVerifier) Verify(ctx context.Context, recs Segments,
	server net.Addr) (chan segverifier.UnitResult, int)

Verify calls segverifier for the given reply.

type Handler

type Handler struct {
	Verifier Verifier
	Storage  Storage
}

Handler is a handler that verifies and stores seg replies. The handler supports an early trigger, so that a partial result can be stored early to possibly reply to clients earlier.

func (*Handler) Handle

func (h *Handler) Handle(ctx context.Context, recs Segments, server net.Addr) *ProcessedResult

Handle verifies and stores a set of segments.

type ProcessedResult

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

ProcessedResult is the result of handling a segment reply.

func (*ProcessedResult) Err

func (r *ProcessedResult) Err() error

Err indicates the error that happened when storing the segments. This should only be accessed after FullReplyProcessed channel has been closed.

func (*ProcessedResult) Stats

func (r *ProcessedResult) Stats() Stats

Stats provides insights about storage and verification of segments.

func (*ProcessedResult) VerificationErrors

func (r *ProcessedResult) VerificationErrors() serrors.List

VerificationErrors returns the list of verification errors that happened.

type SegStats

type SegStats struct {
	// InsertedSegs are the log IDs of the inserted segments.
	InsertedSegs []string
	// UpdatedSegs are the log IDs of the updated segments.
	UpdatedSegs []string
}

SegStats provides statistics about segment insertion/updates.

func (*SegStats) Log

func (s *SegStats) Log(ctx context.Context)

Log logs the statistics with the given logger.

func (SegStats) Total

func (s SegStats) Total() int

Total returns the total amount of updates and inserts.

type Segments

type Segments struct {
	Segs []*seg.Meta
}

Segments is a list of segments and revocations belonging to them. Optionally a hidden path group ID is attached.

type Stats

type Stats struct {

	// VerifiedSegs contains all segments that were successfully verified.
	VerifiedSegs []*seg.Meta
	// contains filtered or unexported fields
}

Stats provides statistics about handling segments.

func (Stats) SegVerifyErrors

func (s Stats) SegVerifyErrors() int

SegVerifyErrors returns the amount of segment verification errors.

func (Stats) SegsInserted

func (s Stats) SegsInserted() int

SegsInserted returns the amount of inserted segments.

func (Stats) SegsUpdated

func (s Stats) SegsUpdated() int

SegsUpdated returns the amount of updated segments.

type Storage

type Storage interface {
	StoreSegs(context.Context, []*seg.Meta) (SegStats, error)
	StoreRevs(context.Context, []*path_mgmt.RevInfo) error
}

Storage is used to store segments and revocations.

type Verifier

type Verifier interface {
	Verify(context.Context, Segments, net.Addr) (chan segverifier.UnitResult, int)
}

Verifier is used to verify a segment reply.

Directories

Path Synopsis
Package mock_seghandler is a generated GoMock package.
Package mock_seghandler is a generated GoMock package.

Jump to

Keyboard shortcuts

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