database

package
v0.0.0-...-fe0d423 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Community

type Community struct {
	ID      uint
	ASN     uint16
	Value   uint16
	RouteID uint
}

type Database

type Database struct {
	// contains filtered or unexported fields
}

func Connect

func Connect(dialect string, args ...interface{}) (*Database, error)

Connect connects to the database

func (*Database) Close

func (d *Database) Close() error

Close closes the database connection

func (*Database) Delete

func (d *Database) Delete(ctx context.Context, route *Route) error

Delete removes a route from the database

func (*Database) Routes

func (d *Database) Routes() ([]*Route, error)

Routes returns all routes stored in the database

func (*Database) Save

func (d *Database) Save(ctx context.Context, route *Route) error

Save saves a route to the database

type LargeCommunity

type LargeCommunity struct {
	ID      uint
	Global  uint32
	Data1   uint32
	Data2   uint32
	RouteID uint
}

type Route

type Route struct {
	ID               uint
	Prefix           string
	NextHop          string
	LocalPref        uint
	MED              uint
	Communities      []*Community
	LargeCommunities []*LargeCommunity
}

func NewRoute

func NewRoute(prefix, nextHop string) *Route

func (*Route) AddCommunity

func (r *Route) AddCommunity(asn uint16, value uint16) *Route

func (*Route) AddLargeCommunity

func (r *Route) AddLargeCommunity(global uint32, local1 uint32, local2 uint32) *Route

type RouteStore

type RouteStore interface {
	Save(ctx context.Context, route *Route) error
	Delete(ctx context.Context, route *Route) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL