package log

import "github.com/google/trillian/log"

Package log holds the code that is specific to Trillian logs core operation, particularly the code for sequencing.

Index

Variables

var (
	// DefaultTimeout is the default timeout on a single log operation run.
	DefaultTimeout = 60 * time.Second
)
var (

	// QuotaIncreaseFactor is the multiplier used for the number of tokens added back to
	// sequencing-based quotas. The resulting PutTokens call is equivalent to
	// "PutTokens(_, numLeaves * QuotaIncreaseFactor, _)".
	// A factor >1 adds resilience to token leakage, on the risk of a system that's overly
	// optimistic in face of true token shortages. The higher the factor, the higher the quota
	// "optimism" is. A factor that's too high (say, >1.5) is likely a sign that the quota
	// configuration should be changed instead.
	// A factor <1 WILL lead to token shortages, therefore it'll be normalized to 1.
	QuotaIncreaseFactor = 1.1
)

Functions

func InitMetrics

func InitMetrics(mf monitoring.MetricFactory)

InitMetrics sets up some metrics for this package. Must be called before calling IntegrateBatch. Can be called more than once, but only the first call has any effect. TODO(pavelkalinnikov): Create all metrics in this package together.

func IntegrateBatch

func IntegrateBatch(ctx context.Context, tree *trillian.Tree, limit int, guardWindow, maxRootDurationInterval time.Duration, ts clock.TimeSource, ls storage.LogStorage, qm quota.Manager) (int, error)

IntegrateBatch wraps up all the operations needed to take a batch of queued or sequenced leaves and integrate them into the tree.

Types

type MockOperation

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

MockOperation is a mock of Operation interface.

func NewMockOperation

func NewMockOperation(ctrl *gomock.Controller) *MockOperation

NewMockOperation creates a new mock instance.

func (*MockOperation) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockOperation) ExecutePass

func (m *MockOperation) ExecutePass(arg0 context.Context, arg1 int64, arg2 *OperationInfo) (int, error)

ExecutePass mocks base method.

type MockOperationMockRecorder

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

MockOperationMockRecorder is the mock recorder for MockOperation.

func (*MockOperationMockRecorder) ExecutePass

func (mr *MockOperationMockRecorder) ExecutePass(arg0, arg1, arg2 interface{}) *gomock.Call

ExecutePass indicates an expected call of ExecutePass.

type Operation

type Operation interface {
	// ExecutePass performs a single pass of processing on a single log.  It returns
	// a count of items processed (for logging) and an error.
	ExecutePass(ctx context.Context, logID int64, info *OperationInfo) (int, error)
}

Operation defines a task that operates on a log. Examples are scheduling, signing, consistency checking or cleanup.

type OperationInfo

type OperationInfo struct {
	// Registry provides access to Trillian storage.
	Registry extension.Registry

	// BatchSize is the batch size to be passed to tasks run by this manager.
	BatchSize int
	// TimeSource should be used by the Operation to allow mocking for tests.
	TimeSource clock.TimeSource

	// Election-related configuration. Copied for each log.
	ElectionConfig election.RunnerConfig

	// RunInterval is the time between starting batches of processing.  If a
	// batch takes longer than this interval to complete, the next batch
	// will start immediately.
	RunInterval time.Duration
	// NumWorkers is the number of worker goroutines to run in parallel.
	NumWorkers int
	// Timeout sets an optional timeout on each operation run.
	// If unset, default to the value of DefaultTimeout.
	Timeout time.Duration
}

OperationInfo bundles up information needed for running a set of Operations.

type OperationManager

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

OperationManager controls scheduling activities for logs.

func NewOperationManager

func NewOperationManager(info OperationInfo, logOperation Operation) *OperationManager

NewOperationManager creates a new OperationManager instance.

func (*OperationManager) OperationLoop

func (o *OperationManager) OperationLoop(ctx context.Context)

OperationLoop starts the manager working. It continues until told to exit. TODO(Martin2112): No mechanism for error reporting etc., this is OK for v1 but needs work

func (*OperationManager) OperationSingle

func (o *OperationManager) OperationSingle(ctx context.Context)

OperationSingle performs a single pass of the manager.

TODO(pavelkalinnikov): Deprecate this because it doesn't clean up any state, and is used only for testing.

type SequencerManager

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

SequencerManager provides sequencing operations for a collection of Logs.

func NewSequencerManager

func NewSequencerManager(registry extension.Registry, gw time.Duration) *SequencerManager

NewSequencerManager creates a new SequencerManager instance based on the provided KeyManager instance and guard window.

func (*SequencerManager) ExecutePass

func (s *SequencerManager) ExecutePass(ctx context.Context, logID int64, info *OperationInfo) (int, error)

ExecutePass performs sequencing for the specified Log.

Source Files

gen.go mock_operation.go operation_manager.go sequencer.go sequencer_manager.go

Version
v1.7.1 (latest)
Published
Jan 9, 2025
Platform
linux/amd64
Imports
25 packages
Last checked
5 days ago

Tools for package owners.