Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var NoPolicy = PolicyHash{0x44, 0x13, 0x6f, 0xa3, 0x55, 0xb3, 0x67, 0x8a, 0x11, 0x46, 0xad, 0x16,
0xf7, 0xe8, 0x64, 0x9e, 0x94, 0xfb, 0x4f, 0xc2, 0x1f, 0xe7, 0x7e, 0x83, 0x10, 0xc0, 0x60, 0xf6,
0x1c, 0xaa, 0xff, 0x8a}
NoPolicy should be used instead of nil when inserting policy hashes into fields which can't be null in the DB. The value is generated by running the TestNoPolicy, and copying the expected output to this field.
Functions ¶
Types ¶
type InsertStats ¶ added in v0.4.0
type InsertStats struct { // Inserted is the number of inserted entries. Inserted int // Updated is the number of updated entries. Updated int }
InsertStats provides statistics about an insertion.
type NextQueryDeleter ¶ added in v0.4.0
type NextQueryDeleter interface { // DeleteExpiredNQ deletes all expired next query entries, i.e. all entries // which have a next query time that is in the past. DeleteExpiredNQ(ctx context.Context, now time.Time) (int, error) // DeleteNQ deletes all entries that match the given parameters. Note that // only parameters with non-zero value are considered, i.e. calling this // function with all zero values deletes all next query entries. Calling // with only a non-zero src value will delete all next query entries where // the source matches the given src parameter. DeleteNQ(ctx context.Context, src, dst addr.IA, policy PolicyHash) (int, error) }
NextQueryDeleter contains functions to delete NextQuery entries.
type PathDB ¶ added in v0.3.0
type PathDB interface { ReadWrite BeginTransaction(ctx context.Context, opts *sql.TxOptions) (Transaction, error) db.LimitSetter io.Closer }
PathDB defines the interface that all PathDB backends have to implement.
func WithMetrics ¶ added in v0.4.0
WithMetrics wraps the given PathDB into one that also exports metrics. dbName will be added as a label to all metrics, so that multiple path DBs can be differentiated.
type PolicyHash ¶ added in v0.4.0
type PolicyHash []byte
PolicyHash is the hash of a policy.
func HashPolicy ¶ added in v0.4.0
func HashPolicy(policy *pathpol.Policy) (PolicyHash, error)
HashPolicy creates a sha256 hash of the json serialized policy, note that this relies on the fact that JSON serialization for Go is predictable, i.e. marshalling the same struct twice returns the same JSON.
func (PolicyHash) String ¶ added in v0.4.0
func (h PolicyHash) String() string
type Read ¶ added in v0.4.0
type Read interface { // Get returns all path segment(s) matching the parameters specified. Get(context.Context, *query.Params) (query.Results, error) // GetAll returns a channel that will provide all items in the path db. If the path db can't // prepare the query a nil channel and the error are returned. If the querying succeeded the the // channel will be filled with the segments in the database. If an error occurs during reading a // segment the error is pushed in the channel and the operation is aborted, that means that the // result might be incomplete. Note that implementations can spawn a goroutine to fill the // channel, which means the channel must be fully drained to guarantee the destruction of the // goroutine. GetAll(context.Context) (<-chan query.ResultOrErr, error) // GetNextQuery returns the nextQuery timestamp for the given src-dst pair // and policy , or a zero time if it hasn't been queried. GetNextQuery(ctx context.Context, src, dst addr.IA, policy PolicyHash) (time.Time, error) }
Read defines all read operations of the path DB.
type Transaction ¶ added in v0.4.0
type Write ¶ added in v0.4.0
type Write interface { // Insert inserts or updates a path segment. It returns the number of path segments // that have been inserted/updated. Insert(context.Context, *seg.Meta) (InsertStats, error) // InsertWithHPCfgIDs inserts or updates a path segment with a set of HPCfgIDs. It // returns the number of path segments that have been inserted/updated. InsertWithHPCfgIDs(context.Context, *seg.Meta, []*query.HPCfgID) (InsertStats, error) // Delete deletes all path segments that matches the given query, // returning the number of deleted segments Delete(context.Context, *query.Params) (int, error) // DeleteExpired deletes all paths segments that are expired, using now as a reference. // Returns the number of deleted segments. DeleteExpired(ctx context.Context, now time.Time) (int, error) // InsertNextQuery inserts or updates the timestamp nextQuery for the given // src-dst pair and policy. Returns true if an insert/update happened or // false if the stored timestamp is already newer. InsertNextQuery(ctx context.Context, src, dst addr.IA, policy PolicyHash, nextQuery time.Time) (bool, error) NextQueryDeleter }
Write defines all write operations of the path DB.
Directories ¶
Path | Synopsis |
---|---|
Package mock_pathdb is a generated GoMock package.
|
Package mock_pathdb is a generated GoMock package. |