package server
import "github.com/google/trillian/server"
Package server holds code for running Trillian servers.
Index ¶
- Constants
- Variables
- func AnnounceSelf(ctx context.Context, client *clientv3.Client, etcdService, endpoint string) func()
- func NewQuotaManager(name string) (quota.Manager, error)
- func NewQuotaManagerFromFlags() (quota.Manager, error)
- func RegisterQuotaManager(name string, qp NewQuotaManagerFunc) error
- type Main
- type NewQuotaManagerFunc
- type NewStorageProviderFunc
- type StorageProvider
- type TrillianLogRPCServer
- func NewTrillianLogRPCServer(registry extension.Registry, timeSource clock.TimeSource) *TrillianLogRPCServer
- func (t *TrillianLogRPCServer) AddSequencedLeaf(ctx context.Context, req *trillian.AddSequencedLeafRequest) (*trillian.AddSequencedLeafResponse, error)
- func (t *TrillianLogRPCServer) AddSequencedLeaves(ctx context.Context, req *trillian.AddSequencedLeavesRequest) (*trillian.AddSequencedLeavesResponse, error)
- 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) GetLeavesByRange(ctx context.Context, req *trillian.GetLeavesByRangeRequest) (*trillian.GetLeavesByRangeResponse, error)
- func (t *TrillianLogRPCServer) GetSequencedLeafCount(ctx context.Context, req *trillian.GetSequencedLeafCountRequest) (*trillian.GetSequencedLeafCountResponse, error)
- func (t *TrillianLogRPCServer) InitLog(ctx context.Context, req *trillian.InitLogRequest) (*trillian.InitLogResponse, 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 NewTrillianMapServer(registry extension.Registry, opts TrillianMapServerOptions) *TrillianMapServer
- func (t *TrillianMapServer) GetLeaf(ctx context.Context, req *trillian.GetMapLeafRequest) (*trillian.GetMapLeafResponse, error)
- func (t *TrillianMapServer) GetLeafByRevision(ctx context.Context, req *trillian.GetMapLeafByRevisionRequest) (*trillian.GetMapLeafResponse, error)
- func (t *TrillianMapServer) GetLeaves(ctx context.Context, req *trillian.GetMapLeavesRequest) (*trillian.GetMapLeavesResponse, error)
- func (t *TrillianMapServer) GetLeavesByRevision(ctx context.Context, req *trillian.GetMapLeavesByRevisionRequest) (*trillian.GetMapLeavesResponse, error)
- func (t *TrillianMapServer) GetLeavesByRevisionNoProof(ctx context.Context, req *trillian.GetMapLeavesByRevisionRequest) (*trillian.MapLeaves, 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) InitMap(ctx context.Context, req *trillian.InitMapRequest) (*trillian.InitMapResponse, error)
- func (t *TrillianMapServer) IsHealthy() error
- func (t *TrillianMapServer) SetLeaves(ctx context.Context, req *trillian.SetMapLeavesRequest) (*trillian.SetMapLeavesResponse, error)
- type TrillianMapServerOptions
- type TrillianMapWriteServer
- func NewTrillianMapWriteServer(registry extension.Registry, mapServer *TrillianMapServer) *TrillianMapWriteServer
- func (t *TrillianMapWriteServer) GetLeavesByRevision(ctx context.Context, req *trillian.GetMapLeavesByRevisionRequest) (*trillian.MapLeaves, error)
- func (t *TrillianMapWriteServer) IsHealthy() error
- func (t *TrillianMapWriteServer) WriteLeaves(ctx context.Context, req *trillian.WriteMapLeavesRequest) (*trillian.WriteMapLeavesResponse, 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 QuotaEtcd = "etcd"
QuotaEtcd represents the etcd quota implementation.
const QuotaMySQL = "mysql"
QuotaMySQL represents the MySQL quota implementation.
const ( // QuotaNoop represents the noop quota implementation. QuotaNoop = "noop" )
Variables ¶
var ( // EtcdServers is a flag containing the address(es) of etcd servers EtcdServers = flag.String("etcd_servers", "", "A comma-separated list of etcd servers; no etcd registration if empty") )
var NewStorageProvider = storage.NewProvider
NewStorageProvider returns a new StorageProvider instance of the type specified by name.
Deprecated: storage.NewProvider should be used directly.
var NewStorageProviderFromFlags = storage.NewProviderFromFlags
NewStorageProviderFromFlags returns a new StorageProvider instance of the type specified by flag.
Deprecated: storage.NewProviderFromFlags should be used directly.
var ( // QuotaSystem is a flag specifying which quota system is in use. QuotaSystem = flag.String("quota_system", "mysql", fmt.Sprintf("Quota system to use. One of: %v", quotaSystems())) )
var RegisterStorageProvider = storage.RegisterProvider
RegisterStorageProvider registers the provided StorageProvider.
Deprecated: storage.RegisterProvider should be used directly.
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 ¶
NewQuotaManager returns a quota.Manager implementation.
func NewQuotaManagerFromFlags ¶
NewQuotaManagerFromFlags returns a quota.Manager implementation as speficied by flag.
func RegisterQuotaManager ¶
func RegisterQuotaManager(name string, qp NewQuotaManagerFunc) error
RegisterQuotaManager registers the provided QuotaManager.
Types ¶
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 // TLS Certificate and Key files for the server. TLSCertFile, TLSKeyFile string DBClose func() error Registry extension.Registry StatsPrefix string QuotaDryRun bool // 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 // IsHealthy will be called whenever "/healthz" is called on the mux. // A nil return value from this function will result in a 200-OK response // on the /healthz endpoint. IsHealthy func(context.Context) error // HealthyDeadline is the maximum duration to wait wait for a successful // IsHealthy() call. HealthyDeadline time.Duration // 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 // These will be added to the GRPC server options. ExtraOptions []grpc.ServerOption }
Main encapsulates the data and logic to start a Trillian server (Log or Map).
func (*Main) Run ¶
Run starts the configured server. Blocks until the server exits.
type NewQuotaManagerFunc ¶
NewQuotaManagerFunc is the signature of a function which can be registered to provide instances of a quota manager.
type NewStorageProviderFunc ¶
type NewStorageProviderFunc = storage.NewProviderFunc
NewStorageProviderFunc is the signature of a function which can be registered to provide instances of storage providers.
Deprecated: storage.NewProviderFunc should be used directly.
type StorageProvider ¶
StorageProvider is an interface which allows Trillian binaries to use different storage implementations.
Deprecated: storage.Provider should be used directly.
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 clock.TimeSource) *TrillianLogRPCServer
NewTrillianLogRPCServer creates a new RPC server backed by a LogStorageProvider.
func (*TrillianLogRPCServer) AddSequencedLeaf ¶
func (t *TrillianLogRPCServer) AddSequencedLeaf(ctx context.Context, req *trillian.AddSequencedLeafRequest) (*trillian.AddSequencedLeafResponse, error)
AddSequencedLeaf submits one sequenced leaf to the storage.
func (*TrillianLogRPCServer) AddSequencedLeaves ¶
func (t *TrillianLogRPCServer) AddSequencedLeaves(ctx context.Context, req *trillian.AddSequencedLeavesRequest) (*trillian.AddSequencedLeavesResponse, error)
AddSequencedLeaves submits a batch of sequenced leaves to a pre-ordered log for later integration into its underlying tree.
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) GetLeavesByRange ¶
func (t *TrillianLogRPCServer) GetLeavesByRange(ctx context.Context, req *trillian.GetLeavesByRangeRequest) (*trillian.GetLeavesByRangeResponse, error)
GetLeavesByRange obtains leaves based on a range of sequence numbers within the tree. This only fetches sequenced leaves; leaves that have been queued but not yet integrated are not visible.
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) InitLog ¶
func (t *TrillianLogRPCServer) InitLog(ctx context.Context, req *trillian.InitLogRequest) (*trillian.InitLogResponse, error)
InitLog initialises a freshly created Log by creating the first STH with size 0.
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 { trillian.UnimplementedTrillianMapServer // contains filtered or unexported fields }
TrillianMapServer implements the RPC API defined in the proto
func NewTrillianMapServer ¶
func NewTrillianMapServer(registry extension.Registry, opts TrillianMapServerOptions) *TrillianMapServer
NewTrillianMapServer creates a new RPC server backed by registry
func (*TrillianMapServer) GetLeaf ¶
func (t *TrillianMapServer) GetLeaf(ctx context.Context, req *trillian.GetMapLeafRequest) (*trillian.GetMapLeafResponse, error)
GetLeaf returns an inclusion proof to the leaf, or nil if the leaf does not exist.
func (*TrillianMapServer) GetLeafByRevision ¶
func (t *TrillianMapServer) GetLeafByRevision(ctx context.Context, req *trillian.GetMapLeafByRevisionRequest) (*trillian.GetMapLeafResponse, error)
GetLeafByRevision returns an inclusion proof to the leaf, or nil if the leaf does not exist.
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 the leaf, or nil if the leaf does not exist.
func (*TrillianMapServer) GetLeavesByRevision ¶
func (t *TrillianMapServer) GetLeavesByRevision(ctx context.Context, req *trillian.GetMapLeavesByRevisionRequest) (*trillian.GetMapLeavesResponse, error)
GetLeavesByRevision implements the GetLeavesByRevision RPC method.
func (*TrillianMapServer) GetLeavesByRevisionNoProof ¶
func (t *TrillianMapServer) GetLeavesByRevisionNoProof(ctx context.Context, req *trillian.GetMapLeavesByRevisionRequest) (*trillian.MapLeaves, error)
GetLeavesByRevisionNoProof implements the GetLeavesByRevision RPC method.
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) InitMap ¶
func (t *TrillianMapServer) InitMap(ctx context.Context, req *trillian.InitMapRequest) (*trillian.InitMapResponse, error)
InitMap implements the RPC Method of the same name.
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.
type TrillianMapServerOptions ¶
type TrillianMapServerOptions struct { // UseSingleTransaction specifies whether updates to a map should be // attempted within a single transaction. UseSingleTransaction bool // UseLargePreload enables the performance workaround applied when // UseSingleTransaction is set. UseLargePreload bool }
TrillianMapServerOptions allows various options to be provided when creating a new TrillianMapServer.
type TrillianMapWriteServer ¶
type TrillianMapWriteServer struct {
// contains filtered or unexported fields
}
TrillianMapWriteServer implements the Write RPC API
func NewTrillianMapWriteServer ¶
func NewTrillianMapWriteServer(registry extension.Registry, mapServer *TrillianMapServer) *TrillianMapWriteServer
NewTrillianMapWriteServer creates a new RPC server for map writes
func (*TrillianMapWriteServer) GetLeavesByRevision ¶
func (t *TrillianMapWriteServer) GetLeavesByRevision(ctx context.Context, req *trillian.GetMapLeavesByRevisionRequest) (*trillian.MapLeaves, error)
GetLeavesByRevision implements the GetLeavesByRevision write RPC method.
func (*TrillianMapWriteServer) IsHealthy ¶
func (t *TrillianMapWriteServer) IsHealthy() error
IsHealthy returns nil if the server is healthy, error otherwise.
func (*TrillianMapWriteServer) WriteLeaves ¶
func (t *TrillianMapWriteServer) WriteLeaves(ctx context.Context, req *trillian.WriteMapLeavesRequest) (*trillian.WriteMapLeavesResponse, error)
WriteLeaves implements the WriteLeaves write RPC method.
Source Files ¶
etcd_quota_provider.go log_rpc_server.go main.go map_rpc_server.go map_tree_updater.go map_write_rpc_server.go mysql_quota_provider.go proof_fetcher.go quota.go storage_provider.go validate.go
Directories ¶
Path | Synopsis |
---|---|
server/admin | Package admin contains the TrillianAdminServer implementation. |
server/errors | Package errors contains utilities to translate TrillianErrors to gRPC errors. |
server/interceptor | Package interceptor defines gRPC interceptors for Trillian. |
server/trillian_log_server | The trillian_log_server binary runs the Trillian log server, and also provides an admin server. |
server/trillian_log_signer | The trillian_log_signer binary runs the log signing code. |
server/trillian_map_server |
- Version
- v1.3.5
- Published
- Nov 23, 2019
- Platform
- js/wasm
- Imports
- 42 packages
- Last checked
- 6 hours ago –
Tools for package owners.