Documentation ¶
Overview ¶
Package segfetcher contains all the logic that is needed to fetch segments, verify and store segments in an efficient manner. It is designed to be pluggable into sciond and PS.
Index ¶
- Variables
- func ErrToMetricsLabel(err error) string
- func NewFetcherMetrics(ns string) metrics.Fetcher
- type DefaultRequester
- type DefaultResolver
- type DstProvider
- type Fetcher
- type LocalInfo
- type MultiSegmentSplitter
- type Pather
- type RPC
- type ReplyHandler
- type ReplyOrErr
- type Request
- type Requester
- type Requests
- type Resolver
- type Segments
- type Splitter
Constants ¶
This section is empty.
Variables ¶
var (
ErrBadDst = errors.New("bad destination AS")
)
Pather errors.
var ErrInvalidRequest = serrors.New("invalid request")
ErrInvalidRequest indicates an invalid request.
var ErrNotReachable = serrors.New("remote not reachable")
ErrNotReachable indicates that the destination is not reachable from this process.
Functions ¶
func ErrToMetricsLabel ¶
ErrToMetricsLabel classifies the error from the segfetcher into metrics labels.
func NewFetcherMetrics ¶ added in v0.6.0
NewFetcherMetrics exposes the metrics constructor.
XXX(roosd): This should be translated to the new metrics approach.
Types ¶
type DefaultRequester ¶
type DefaultRequester struct { RPC RPC DstProvider DstProvider // TimeoutFactor is the percentage of the total timeout available for a segment request // that is allocated to the next try. TimeoutFactor float64 MaxTries int }
DefaultRequester requests all segments that can be requested from a request set.
func (*DefaultRequester) Request ¶
func (r *DefaultRequester) Request(ctx context.Context, reqs Requests) <-chan ReplyOrErr
Request all requests in the request set
type DefaultResolver ¶
DefaultResolver is the default resolver implementation.
func NewResolver ¶
NewResolver creates a new resolver with the given DB.
func (*DefaultResolver) Resolve ¶
func (r *DefaultResolver) Resolve(ctx context.Context, reqs Requests, refresh bool) (Segments, Requests, error)
Resolve resolves requests. It loads the segments that are locally available from the DB and returns the set of requests that have to be requested at a remote server.
type DstProvider ¶
DstProvider provides the destination for a segment lookup including the path.
type Fetcher ¶
type Fetcher struct { Resolver Resolver Requester Requester ReplyHandler ReplyHandler PathDB pathdb.PathDB // QueryInterval specifies after how much time segments should be // refetched at the remote server. QueryInterval time.Duration Metrics metrics.Fetcher }
Fetcher fetches, verifies and stores segments for a path segment request.
type LocalInfo ¶ added in v0.5.0
type LocalInfo interface { // IsSegLocal returns whether the requested segment is always locally stored. IsSegLocal(req Request) bool }
LocalInfo provides information about which segments are always locally stored.
type MultiSegmentSplitter ¶ added in v0.5.0
MultiSegmentSplitter splits requests consisting of one or multiple segments. The AS inspector is used to check whether an IA is core or not.
type Pather ¶ added in v0.5.0
type Pather struct { TopoProvider topology.Provider RevCache revcache.RevCache Fetcher *Fetcher Splitter Splitter }
Pather is used to construct paths from the path database. If necessary, paths are fetched over the network.
func (*Pather) GetPaths ¶ added in v0.5.0
GetPaths returns all non-revoked and non-expired paths to the destination. The paths are sorted from best to worst according to the weighting in path combinator. In case the destination AS is the same as the local AS, a slice containing an empty path is returned.
type RPC ¶ added in v0.6.0
type RPC interface {
Segments(ctx context.Context, req Request, dst net.Addr) ([]*seg.Meta, error)
}
RPC is used to fetch segments from a remote.
type ReplyHandler ¶
type ReplyHandler interface { Handle(ctx context.Context, recs seghandler.Segments, server net.Addr) *seghandler.ProcessedResult }
ReplyHandler handles replies.
type ReplyOrErr ¶
ReplyOrErr is a seg reply or an error for the given request.
type Request ¶
Request represents a path or segment request.
type Requester ¶
type Requester interface {
Request(ctx context.Context, req Requests) <-chan ReplyOrErr
}
Requester requests segments.
type Requests ¶
type Requests []Request
Requests is a list of requests and provides some convenience methods on top of it.
type Resolver ¶
type Resolver interface { // Resolve resolves requests. It loads the segments that are locally available // from the DB and returns the set of requests that have to be requested at a // remote server. Resolve(ctx context.Context, reqs Requests, refresh bool) (Segments, Requests, error) }
Resolver resolves segments that are locally cached.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
Package mock_segfetcher is a generated GoMock package.
|
Package mock_segfetcher is a generated GoMock package. |