Documentation ¶
Overview ¶
Package server holds code for core Trillian servers.
Package server is a generated GoMock package.
Index ¶
- Constants
- func AnnounceSelf(ctx context.Context, client *clientv3.Client, etcdService, endpoint string) func()
- func NewQuotaManager(params *QuotaParams) (quota.Manager, error)
- type LogOperation
- type LogOperationInfo
- type LogOperationManager
- type Main
- type MockLogOperation
- type MockLogOperationMockRecorder
- type QuotaParams
- type SequencerManager
- type TrillianLogRPCServer
- func (t *TrillianLogRPCServer) GetConsistencyProof(ctx context.Context, req *trillian.GetConsistencyProofRequest) (*trillian.GetConsistencyProofResponse, error)
- func (t *TrillianLogRPCServer) GetEntryAndProof(ctx context.Context, req *trillian.GetEntryAndProofRequest) (*trillian.GetEntryAndProofResponse, error)
- func (t *TrillianLogRPCServer) GetInclusionProof(ctx context.Context, req *trillian.GetInclusionProofRequest) (*trillian.GetInclusionProofResponse, error)
- func (t *TrillianLogRPCServer) GetInclusionProofByHash(ctx context.Context, req *trillian.GetInclusionProofByHashRequest) (*trillian.GetInclusionProofByHashResponse, error)
- func (t *TrillianLogRPCServer) GetLatestSignedLogRoot(ctx context.Context, req *trillian.GetLatestSignedLogRootRequest) (*trillian.GetLatestSignedLogRootResponse, error)
- func (t *TrillianLogRPCServer) GetLeavesByHash(ctx context.Context, req *trillian.GetLeavesByHashRequest) (*trillian.GetLeavesByHashResponse, error)
- func (t *TrillianLogRPCServer) GetLeavesByIndex(ctx context.Context, req *trillian.GetLeavesByIndexRequest) (*trillian.GetLeavesByIndexResponse, error)
- func (t *TrillianLogRPCServer) GetSequencedLeafCount(ctx context.Context, req *trillian.GetSequencedLeafCountRequest) (*trillian.GetSequencedLeafCountResponse, error)
- func (t *TrillianLogRPCServer) IsHealthy() error
- func (t *TrillianLogRPCServer) QueueLeaf(ctx context.Context, req *trillian.QueueLeafRequest) (*trillian.QueueLeafResponse, error)
- func (t *TrillianLogRPCServer) QueueLeaves(ctx context.Context, req *trillian.QueueLeavesRequest) (*trillian.QueueLeavesResponse, error)
- type TrillianMapServer
- func (t *TrillianMapServer) GetLeaves(ctx context.Context, req *trillian.GetMapLeavesRequest) (*trillian.GetMapLeavesResponse, error)
- func (t *TrillianMapServer) GetSignedMapRoot(ctx context.Context, req *trillian.GetSignedMapRootRequest) (*trillian.GetSignedMapRootResponse, error)
- func (t *TrillianMapServer) GetSignedMapRootByRevision(ctx context.Context, req *trillian.GetSignedMapRootByRevisionRequest) (*trillian.GetSignedMapRootResponse, error)
- func (t *TrillianMapServer) Init(ctx context.Context, mapID int64) error
- func (t *TrillianMapServer) IsHealthy() error
- func (t *TrillianMapServer) SetLeaves(ctx context.Context, req *trillian.SetMapLeavesRequest) (*trillian.SetMapLeavesResponse, error)
Constants ¶
const ( // DefaultTreeDeleteThreshold is the suggested threshold for tree deletion. // It represents the minimum time a tree has to remain Deleted before being hard-deleted. DefaultTreeDeleteThreshold = 7 * 24 * time.Hour // DefaultTreeDeleteMinInterval is the suggested min interval between tree GC sweeps. // A tree GC sweep consists of listing deleted trees older than the deletion threshold and // hard-deleting them. // Actual runs happen randomly between [minInterval,2*minInterval). DefaultTreeDeleteMinInterval = 4 * time.Hour )
const ( // QuotaNoop represents the noop quota implementation. QuotaNoop = "noop" // QuotaMySQL represents the MySQL quota implementation. QuotaMySQL = "mysql" // QuotaEtcd represents the etcd quota implementation. QuotaEtcd = "etcd" )
Variables ¶
This section is empty.
Functions ¶
func AnnounceSelf ¶
func AnnounceSelf(ctx context.Context, client *clientv3.Client, etcdService, endpoint string) func()
AnnounceSelf announces this binary's presence to etcd. Returns a function that should be called on process exit. AnnounceSelf does nothing if client is nil.
func NewQuotaManager ¶
func NewQuotaManager(params *QuotaParams) (quota.Manager, error)
NewQuotaManager returns a quota.Manager implementation according to params. See QuotaParams for details.
Types ¶
type LogOperation ¶
type LogOperation interface { // Name returns the name of the task. Name() string // 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 *LogOperationInfo) (int, error) }
LogOperation defines a task that operates on a log. Examples are scheduling, signing, consistency checking or cleanup.
type LogOperationInfo ¶
type LogOperationInfo struct { // Registry provides access to Trillian storage. Registry extension.Registry // BatchSize is the processing batch size to be passed to tasks run by this manager BatchSize int // TimeSource should be used by the LogOperation to allow mocking for tests. TimeSource util.TimeSource // 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 // PreElectionPause is the maximum interval to wait before starting a // mastership election for a particular log. PreElectionPause time.Duration // MasterCheckInterval is the interval between checks that we still // hold mastership for a log. MasterCheckInterval time.Duration // MasterHoldInterval is the minimum interval to hold mastership for. MasterHoldInterval time.Duration // ResignOdds gives the chance of resigning mastership after each // check interval, as the N for 1-in-N. ResignOdds int // NumWorkers is the number of worker goroutines to run in parallel. NumWorkers int }
LogOperationInfo bundles up information needed for running a set of LogOperations.
type LogOperationManager ¶
type LogOperationManager struct {
// contains filtered or unexported fields
}
LogOperationManager controls scheduling activities for logs.
func NewLogOperationManager ¶
func NewLogOperationManager(info LogOperationInfo, logOperation LogOperation) *LogOperationManager
NewLogOperationManager creates a new LogOperationManager instance.
func (*LogOperationManager) OperationLoop ¶
func (l *LogOperationManager) 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 (*LogOperationManager) OperationSingle ¶
func (l *LogOperationManager) OperationSingle(ctx context.Context)
OperationSingle performs a single pass of the manager.
type Main ¶
type Main struct { // Endpoints for RPC and HTTP/REST servers. // HTTP/REST is optional, if empty it'll not be bound. RPCEndpoint, HTTPEndpoint string DB *sql.DB Registry extension.Registry Server *grpc.Server // RegisterHandlerFn is called to register REST-proxy handlers. RegisterHandlerFn func(context.Context, *runtime.ServeMux, string, []grpc.DialOption) error // RegisterServerFn is called to register RPC servers. RegisterServerFn func(*grpc.Server, extension.Registry) error // AllowedTreeTypes determines which types of trees may be created through the Admin Server // bound by Main. nil means unrestricted. AllowedTreeTypes []trillian.TreeType TreeGCEnabled bool TreeDeleteThreshold time.Duration TreeDeleteMinInterval time.Duration }
Main encapsulates the data and logic to start a Trillian server (Log or Map).
type MockLogOperation ¶
type MockLogOperation struct {
// contains filtered or unexported fields
}
MockLogOperation is a mock of LogOperation interface
func NewMockLogOperation ¶
func NewMockLogOperation(ctrl *gomock.Controller) *MockLogOperation
NewMockLogOperation creates a new mock instance
func (*MockLogOperation) EXPECT ¶
func (m *MockLogOperation) EXPECT() *MockLogOperationMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockLogOperation) ExecutePass ¶
func (m *MockLogOperation) ExecutePass(arg0 context.Context, arg1 int64, arg2 *LogOperationInfo) (int, error)
ExecutePass mocks base method
type MockLogOperationMockRecorder ¶
type MockLogOperationMockRecorder struct {
// contains filtered or unexported fields
}
MockLogOperationMockRecorder is the mock recorder for MockLogOperation
func (*MockLogOperationMockRecorder) ExecutePass ¶
func (mr *MockLogOperationMockRecorder) ExecutePass(arg0, arg1, arg2 interface{}) *gomock.Call
ExecutePass indicates an expected call of ExecutePass
func (*MockLogOperationMockRecorder) Name ¶
func (mr *MockLogOperationMockRecorder) Name() *gomock.Call
Name indicates an expected call of Name
type QuotaParams ¶
type QuotaParams struct { // QuotaSystem represents the underlying quota implementation used. // Valid values are "noop", "mysql" and "etcd". QuotaSystem string // DB is the database used by MySQL quotas. DB *sql.DB // MaxUnsequencedRows is the max number of rows that may be in Unsequenced before new write // requests are blocked. // Used by MySQL quotas. MaxUnsequencedRows int // Client is used by etcd quotas. Client *clientv3.Client // MinBatchSize and MaxCacheEntries are used for token caching. // Applicable to etcd quotas. MinBatchSize, MaxCacheEntries int }
QuotaParams represents all parameters required to initialize a quota.Manager.
Depending on the supplied QuotaSystem, the actual quota.Manager implementation, as returned by NewQuotaManager, may differ.
See fields for details.
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 *LogOperationInfo) (int, error)
ExecutePass performs sequencing for the specified Log.
func (*SequencerManager) Name ¶
func (s *SequencerManager) Name() string
Name returns the name of the object.
type TrillianLogRPCServer ¶
type TrillianLogRPCServer struct {
// contains filtered or unexported fields
}
TrillianLogRPCServer implements the RPC API defined in the proto
func NewTrillianLogRPCServer ¶
func NewTrillianLogRPCServer(registry extension.Registry, timeSource util.TimeSource) *TrillianLogRPCServer
NewTrillianLogRPCServer creates a new RPC server backed by a LogStorageProvider.
func (*TrillianLogRPCServer) GetConsistencyProof ¶
func (t *TrillianLogRPCServer) GetConsistencyProof(ctx context.Context, req *trillian.GetConsistencyProofRequest) (*trillian.GetConsistencyProofResponse, error)
GetConsistencyProof obtains a proof that two versions of the tree are consistent with each other and that the later tree includes all the entries of the prior one. For more details see the example trees in RFC 6962.
func (*TrillianLogRPCServer) GetEntryAndProof ¶
func (t *TrillianLogRPCServer) GetEntryAndProof(ctx context.Context, req *trillian.GetEntryAndProofRequest) (*trillian.GetEntryAndProofResponse, error)
GetEntryAndProof returns both a Merkle Leaf entry and an inclusion proof for a given index and tree size.
func (*TrillianLogRPCServer) GetInclusionProof ¶
func (t *TrillianLogRPCServer) GetInclusionProof(ctx context.Context, req *trillian.GetInclusionProofRequest) (*trillian.GetInclusionProofResponse, error)
GetInclusionProof obtains the proof of inclusion in the tree for a leaf that has been sequenced. Similar to the get proof by hash handler but one less step as we don't need to look up the index
func (*TrillianLogRPCServer) GetInclusionProofByHash ¶
func (t *TrillianLogRPCServer) GetInclusionProofByHash(ctx context.Context, req *trillian.GetInclusionProofByHashRequest) (*trillian.GetInclusionProofByHashResponse, error)
GetInclusionProofByHash obtains proofs of inclusion by leaf hash. Because some logs can contain duplicate hashes it is possible for multiple proofs to be returned.
func (*TrillianLogRPCServer) GetLatestSignedLogRoot ¶
func (t *TrillianLogRPCServer) GetLatestSignedLogRoot(ctx context.Context, req *trillian.GetLatestSignedLogRootRequest) (*trillian.GetLatestSignedLogRootResponse, error)
GetLatestSignedLogRoot obtains the latest published tree root for the Merkle Tree that underlies the log.
func (*TrillianLogRPCServer) GetLeavesByHash ¶
func (t *TrillianLogRPCServer) GetLeavesByHash(ctx context.Context, req *trillian.GetLeavesByHashRequest) (*trillian.GetLeavesByHashResponse, error)
GetLeavesByHash obtains one or more leaves based on their tree hash. It is not possible to fetch leaves that have been queued but not yet integrated. Logs may accept duplicate entries so this may return more results than the number of hashes in the request.
func (*TrillianLogRPCServer) GetLeavesByIndex ¶
func (t *TrillianLogRPCServer) GetLeavesByIndex(ctx context.Context, req *trillian.GetLeavesByIndexRequest) (*trillian.GetLeavesByIndexResponse, error)
GetLeavesByIndex obtains one or more leaves based on their sequence number within the tree. It is not possible to fetch leaves that have been queued but not yet integrated. TODO: Validate indices against published tree size in case we implement write sharding that can get ahead of this point. Not currently clear what component should own this state.
func (*TrillianLogRPCServer) GetSequencedLeafCount ¶
func (t *TrillianLogRPCServer) GetSequencedLeafCount(ctx context.Context, req *trillian.GetSequencedLeafCountRequest) (*trillian.GetSequencedLeafCountResponse, error)
GetSequencedLeafCount returns the number of leaves that have been integrated into the Merkle Tree. This can be zero for a log containing no entries.
func (*TrillianLogRPCServer) IsHealthy ¶
func (t *TrillianLogRPCServer) IsHealthy() error
IsHealthy returns nil if the server is healthy, error otherwise.
func (*TrillianLogRPCServer) QueueLeaf ¶
func (t *TrillianLogRPCServer) QueueLeaf(ctx context.Context, req *trillian.QueueLeafRequest) (*trillian.QueueLeafResponse, error)
QueueLeaf submits one leaf to the queue.
func (*TrillianLogRPCServer) QueueLeaves ¶
func (t *TrillianLogRPCServer) QueueLeaves(ctx context.Context, req *trillian.QueueLeavesRequest) (*trillian.QueueLeavesResponse, error)
QueueLeaves submits a batch of leaves to the log for later integration into the underlying tree.
type TrillianMapServer ¶
type TrillianMapServer struct {
// contains filtered or unexported fields
}
TrillianMapServer implements the RPC API defined in the proto
func NewTrillianMapServer ¶
func NewTrillianMapServer(registry extension.Registry) *TrillianMapServer
NewTrillianMapServer creates a new RPC server backed by registry
func (*TrillianMapServer) GetLeaves ¶
func (t *TrillianMapServer) GetLeaves(ctx context.Context, req *trillian.GetMapLeavesRequest) (*trillian.GetMapLeavesResponse, error)
GetLeaves implements the GetLeaves RPC method. Each requested index will return an inclusion proof to either the leaf, or nil if the leaf does not exist.
func (*TrillianMapServer) GetSignedMapRoot ¶
func (t *TrillianMapServer) GetSignedMapRoot(ctx context.Context, req *trillian.GetSignedMapRootRequest) (*trillian.GetSignedMapRootResponse, error)
GetSignedMapRoot implements the GetSignedMapRoot RPC method.
func (*TrillianMapServer) GetSignedMapRootByRevision ¶
func (t *TrillianMapServer) GetSignedMapRootByRevision(ctx context.Context, req *trillian.GetSignedMapRootByRevisionRequest) (*trillian.GetSignedMapRootResponse, error)
GetSignedMapRootByRevision implements the GetSignedMapRootByRevision RPC method.
func (*TrillianMapServer) Init ¶ added in v1.0.3
func (t *TrillianMapServer) Init(ctx context.Context, mapID int64) error
Init creates the initial revision 0 SignedMapHead, if one doesn't already exist.
func (*TrillianMapServer) IsHealthy ¶
func (t *TrillianMapServer) IsHealthy() error
IsHealthy returns nil if the server is healthy, error otherwise.
func (*TrillianMapServer) SetLeaves ¶
func (t *TrillianMapServer) SetLeaves(ctx context.Context, req *trillian.SetMapLeavesRequest) (*trillian.SetMapLeavesResponse, error)
SetLeaves implements the SetLeaves RPC method.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package admin contains the TrillianAdminServer implementation.
|
Package admin contains the TrillianAdminServer implementation. |
Package errors contains utilities to translate TrillianErrors to gRPC errors.
|
Package errors contains utilities to translate TrillianErrors to gRPC errors. |
Package interceptor defines gRPC interceptors for Trillian.
|
Package interceptor defines gRPC interceptors for Trillian. |
The trillian_log_server binary runs the Trillian log server, and also provides an admin server.
|
The trillian_log_server binary runs the Trillian log server, and also provides an admin server. |
The trillian_log_signer binary runs the log signing code.
|
The trillian_log_signer binary runs the log signing code. |