Documentation ¶
Overview ¶
Package pathmgr implements an asynchronous Path Resolver for SCION Paths.
A new resolver can be instantiated by calling `New`. There are two types of supported path queries, simple or periodic.
Simple path queries are issued via 'Query'; they return an spathmeta.AppPathSet of valid paths.
Periodic path queries are added via 'Watch', which returns a pointer to a thread-safe SyncPaths object; calling Load on the object returns the data associated with the watch, which includes the set of paths. When updating paths, the resolver will atomically change the value within the SyncPaths object. The data can be accessed by calling Load again.
An example of how this package can be used can be found in the associated infra test file.
Index ¶
- Constants
- func StartPeriodic(params PollingParameters, ch chan sciond.PathReqFlags) *periodic.Runner
- type DefaultPollingPolicy
- type Policy
- type PollingParameters
- type PollingPolicy
- type Querier
- type Resolver
- type SyncPaths
- type SyncPathsData
- type Timers
- type WatchFactory
- type WatchReference
- type WatchRunner
Constants ¶
const ( // DefaultNormalRefire is the wait time after a successful path lookup (for periodic lookups) DefaultNormalRefire = time.Minute // DefaultErorrRefire is the wait time after a failed path lookup (for periodic lookups) DefaultErrorRefire = time.Second // DefaultQueryTimeout is the time allocated for a query to SCIOND DefaultQueryTimeout = 5 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func StartPeriodic ¶ added in v0.4.0
func StartPeriodic(params PollingParameters, ch chan sciond.PathReqFlags) *periodic.Runner
Types ¶
type DefaultPollingPolicy ¶ added in v0.4.0
type DefaultPollingPolicy struct {
// contains filtered or unexported fields
}
func (*DefaultPollingPolicy) Destroy ¶ added in v0.4.0
func (pp *DefaultPollingPolicy) Destroy()
func (*DefaultPollingPolicy) PollC ¶ added in v0.4.0
func (pp *DefaultPollingPolicy) PollC() <-chan sciond.PathReqFlags
func (*DefaultPollingPolicy) PollNow ¶ added in v0.4.0
func (pp *DefaultPollingPolicy) PollNow()
func (*DefaultPollingPolicy) UpdateState ¶ added in v0.4.0
func (pp *DefaultPollingPolicy) UpdateState(availablePaths spathmeta.AppPathSet)
type PollingParameters ¶ added in v0.4.0
type PollingParameters struct {
// contains filtered or unexported fields
}
type PollingPolicy ¶ added in v0.4.0
type PollingPolicy interface { // UpdateState reconfigures the polling policy based on availablePaths. UpdateState(availablePaths spathmeta.AppPathSet) // PollNow triggers a new query now, irrespective of other timers. PollNow() // PollC returns the channel that is written to whenever the policy // dictates a new poll. Ticks are dropped if the channel is full. PollC() <-chan sciond.PathReqFlags // Destroy shuts down any running goroutines. Destroy() }
PollingPolicy describes how SCIOND should be polled, taking into account various aspects such as number of paths and the existence of a filtering policy. The PollingPolicy decides when SCIOND should be queried next, and which flags to be set.
func NewPollingPolicy ¶ added in v0.4.0
func NewPollingPolicy(haveFilter bool, timers Timers) PollingPolicy
type Querier ¶ added in v0.4.0
type Querier interface { // Query returns a set of paths between src and dst. Query(ctx context.Context, src, dst addr.IA, flags sciond.PathReqFlags) spathmeta.AppPathSet }
type Resolver ¶ added in v0.4.0
type Resolver interface { Querier // QueryFilter returns a set of paths between src and dst that satisfy // policy. A nil policy will not delete any paths. QueryFilter(ctx context.Context, src, dst addr.IA, policy Policy) spathmeta.AppPathSet // Watch returns an object that periodically polls for paths between src // and dst. // // The function blocks until the first answer from SCIOND is received. The // amount of time is dictated by ctx. Note that the resolver might // asynchronously change the paths at any time. Calling Load on the // returned object returns a reference to a structure containing the // currently available paths. // // The asynchronous worker is not subject to ctx; thus, it has infinite // lifetime or until Destroy is called on the SyncPaths object. Watch(ctx context.Context, src, dst addr.IA) (*SyncPaths, error) // WatchFilter returns a pointer to a SyncPaths object that contains paths from // src to dst that adhere to the specified filter. On path changes the list is // refreshed automatically. // // A nil filter will not delete any paths. WatchFilter(ctx context.Context, src, dst addr.IA, filter Policy) (*SyncPaths, error) // WatchCount returns the number of active watchers. WatchCount() int // RevokeRaw informs SCIOND of a revocation. RevokeRaw(ctx context.Context, rawSRevInfo common.RawBytes) // Revoke informs SCIOND of a revocation. Revoke(ctx context.Context, sRevInfo *path_mgmt.SignedRevInfo) // Sciond returns a reference to the SCIOND connection. Sciond() sciond.Connector }
func New ¶
New creates a new path management context.
Parameter timers can be used to customize path manager behavior; if any timer is left uninitialized, it is assigned the corresponding default value (see package constants). When a query for a path older than maxAge reaches the resolver, SCIOND is used to refresh the path. New returns with an error if a connection to SCIOND could not be established.
type SyncPaths ¶
type SyncPaths struct {
// contains filtered or unexported fields
}
SyncPaths contains a concurrency-safe reference to an spathmeta.AppPathSet that is continuously kept up to date by the path manager. Callers can safely `Load` the reference and use the paths within. At any moment, the path resolver can change the value of the reference within a SyncPaths to a different slice containing new paths. Calling code should reload the reference often to make sure the paths are fresh. Timestamp() can be called to get the time of the last write.
A SyncPaths must never be copied.
func NewSyncPaths ¶
func NewSyncPaths() *SyncPaths
NewSyncPaths creates a new SyncPaths object and sets the timestamp to current time. A newly created SyncPaths contains a nil spathmeta.AppPathSet.
func (*SyncPaths) Load ¶
func (sp *SyncPaths) Load() *SyncPathsData
Load returns a SyncPathsData snapshot of the data within sp.
func (*SyncPaths) Update ¶ added in v0.4.0
func (sp *SyncPaths) Update(newAPS spathmeta.AppPathSet)
Update adds and removes paths in sp to match newAPS. If a path was added or removed, the modified timestamp is updated. The refresh timestamp is always updated. FIXME(scrye): Add SCIOND support s.t. the refresh timestamp is changed only when paths (including path metadata) change.
type SyncPathsData ¶
SyncPathsData is the atomic value inside a SyncPaths object. It provides a snapshot of a SyncPaths object. Callers must not change APS.
type Timers ¶
type Timers struct { // Wait time after a successful path lookup (for periodic lookups) NormalRefire time.Duration // Wait time after a failed (error or empty) path lookup (for periodic lookups) ErrorRefire time.Duration }
Timers is used to customize the timers for a new Path Manager.
type WatchFactory ¶ added in v0.4.0
type WatchFactory struct {
// contains filtered or unexported fields
}
WatchFactory creates and tracks path watches, i.e., path polling goroutines.
func NewWatchFactory ¶ added in v0.4.0
func NewWatchFactory(timers Timers) *WatchFactory
func (*WatchFactory) New ¶ added in v0.4.0
func (factory *WatchFactory) New(sp *SyncPaths, bq *queryConfig, pp PollingPolicy) *WatchReference
type WatchReference ¶ added in v0.4.0
type WatchReference struct {
// contains filtered or unexported fields
}
WatchReference is a reference to an internal Watch managed by the PathManager. Call Run to start the goroutine associated with the watch, and call Destroy to stop it.
Calling Run after a reference has been destroyed will result in a no-op.
func (*WatchReference) Destroy ¶ added in v0.4.0
func (ref *WatchReference) Destroy()
func (*WatchReference) Run ¶ added in v0.4.0
func (ref *WatchReference) Run()
type WatchRunner ¶ added in v0.4.0
type WatchRunner struct {
// contains filtered or unexported fields
}
WatchRunner polls SCIOND in accordance to a polling policy, updating a concurrency-safe store of paths after every poll.
Call Stop to shut down the running goroutine. It is safe to call Stop multiple times from different goroutines.
func (*WatchRunner) Run ¶ added in v0.4.0
func (w *WatchRunner) Run()
func (*WatchRunner) Stop ¶ added in v0.4.0
func (w *WatchRunner) Stop()
Directories ¶
Path | Synopsis |
---|---|
Package mock_pathmgr is a generated GoMock package.
|
Package mock_pathmgr is a generated GoMock package. |