birdwatcher

package
v0.0.0-...-4a05471 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Overview

Package birdwatcher implements the birdwatcher source for the Alice Looking Glass.

It deals with bird being able to run in single or multi table mode.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Birdwatcher

type Birdwatcher interface {
	sources.Source
}

A Birdwatcher source is a variant of an alice source and implements different strategies for fetching route information from bird.

func NewBirdwatcher

func NewBirdwatcher(config Config) Birdwatcher

NewBirdwatcher creates a new Birdwatcher instance. This might be either a GenericBirdWatcher or a MultiTableBirdwatcher.

type Client

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

A Client uses the http client to talk to the birdwatcher API.

func NewClient

func NewClient(api string) *Client

NewClient creates a new client instance

func (*Client) GetEndpoint

func (c *Client) GetEndpoint(
	ctx context.Context,
	endpoint string,
) (*http.Response, error)

GetEndpoint makes an API request and returns the response. The response body will be parsed further downstream.

func (*Client) GetJSON

func (c *Client) GetJSON(
	ctx context.Context,
	endpoint string,
) (ClientResponse, error)

GetJSON makes an API request. Parse JSON response and return map or error.

type ClientResponse

type ClientResponse map[string]interface{}

ClientResponse is a json key value mapping

type Config

type Config struct {
	ID   string
	Name string

	API             string `ini:"api"`
	Timezone        string `ini:"timezone"`
	ServerTime      string `ini:"servertime"`
	ServerTimeShort string `ini:"servertime_short"`
	ServerTimeExt   string `ini:"servertime_ext"`
	ShowLastReboot  bool   `ini:"show_last_reboot"`

	Type                    string `ini:"type"`
	MainTable               string `ini:"main_table"`
	PeerTablePrefix         string `ini:"peer_table_prefix"`
	PipeProtocolPrefix      string `ini:"pipe_protocol_prefix"`
	AltPipeProtocolPrefix   string `ini:"alt_pipe_protocol_prefix"`
	AltPipeProtocolSuffix   string `ini:"alt_pipe_protocol_suffix"`
	NeighborsRefreshTimeout int    `ini:"neighbors_refresh_timeout"`

	StreamParserThrottle int
}

Config contains all configuration attributes for a birdwatcher based source.

type GenericBirdwatcher

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

GenericBirdwatcher is an Alice data source.

func (*GenericBirdwatcher) ExpireCaches

func (b *GenericBirdwatcher) ExpireCaches() int

ExpireCaches clears all local caches

func (*GenericBirdwatcher) NeighborsStatus

func (b *GenericBirdwatcher) NeighborsStatus(ctx context.Context) (
	*api.NeighborsStatusResponse,
	error,
)

NeighborsStatus retrieves neighbor status infos

func (*GenericBirdwatcher) Status

Status retrievs the current backend status

type LockMap

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

LockMap uses the sync.Map to manage locks, accessed by a key. TODO: Maybe this would be a nice generic helper

func NewLockMap

func NewLockMap() *LockMap

NewLockMap creates a new LockMap

func (*LockMap) Lock

func (m *LockMap) Lock(key string)

Lock locks the lock.

func (*LockMap) Unlock

func (m *LockMap) Unlock(key string)

Unlock unlocks the locked LockMap-lock.

type MultiTableBirdwatcher

type MultiTableBirdwatcher struct {
	GenericBirdwatcher
}

MultiTableBirdwatcher implements a birdwatcher with a multitable bird as a datasource.

func (*MultiTableBirdwatcher) AllRoutes

func (src *MultiTableBirdwatcher) AllRoutes(
	ctx context.Context,
) (*api.RoutesResponse, error)

AllRoutes retrieves a routes dump from the server

func (*MultiTableBirdwatcher) Neighbors

func (src *MultiTableBirdwatcher) Neighbors(
	ctx context.Context,
) (*api.NeighborsResponse, error)

Neighbors get neighbors from protocols. TODO: this. needs. refactoring.

func (*MultiTableBirdwatcher) NeighborsSummary

func (src *MultiTableBirdwatcher) NeighborsSummary(
	ctx context.Context,
) (*api.NeighborsResponse, error)

NeighborsSummary is for now using Neighbors

func (*MultiTableBirdwatcher) Routes

func (src *MultiTableBirdwatcher) Routes(
	ctx context.Context,
	neighborID string,
) (*api.RoutesResponse, error)

Routes gets filtered and exported route from the birdwatcher backend.

func (*MultiTableBirdwatcher) RoutesFiltered

func (src *MultiTableBirdwatcher) RoutesFiltered(
	ctx context.Context,
	neighborID string,
) (*api.RoutesResponse, error)

RoutesFiltered gets all filtered routes from the backend

func (*MultiTableBirdwatcher) RoutesNotExported

func (src *MultiTableBirdwatcher) RoutesNotExported(
	ctx context.Context,
	neighborID string,
) (*api.RoutesResponse, error)

RoutesNotExported gets all not exported routes

func (*MultiTableBirdwatcher) RoutesReceived

func (src *MultiTableBirdwatcher) RoutesReceived(
	ctx context.Context,
	neighborID string,
) (*api.RoutesResponse, error)

RoutesReceived returns all received routes

type SingleTableBirdwatcher

type SingleTableBirdwatcher struct {
	GenericBirdwatcher
}

SingleTableBirdwatcher is an Alice Source

func (*SingleTableBirdwatcher) AllRoutes

func (src *SingleTableBirdwatcher) AllRoutes(
	ctx context.Context,
) (*api.RoutesResponse, error)

AllRoutes retrieves a route dump

func (*SingleTableBirdwatcher) Neighbors

func (src *SingleTableBirdwatcher) Neighbors(
	ctx context.Context,
) (*api.NeighborsResponse, error)

Neighbors get neighbors from protocols

func (*SingleTableBirdwatcher) NeighborsSummary

func (src *SingleTableBirdwatcher) NeighborsSummary(
	ctx context.Context,
) (*api.NeighborsResponse, error)

NeighborsSummary is for now an alias of Neighbors

func (*SingleTableBirdwatcher) Routes

func (src *SingleTableBirdwatcher) Routes(
	ctx context.Context,
	neighborID string,
) (*api.RoutesResponse, error)

Routes gets filtered and exported routes

func (*SingleTableBirdwatcher) RoutesFiltered

func (src *SingleTableBirdwatcher) RoutesFiltered(
	ctx context.Context,
	neighborID string,
) (*api.RoutesResponse, error)

RoutesFiltered gets all filtered routes

func (*SingleTableBirdwatcher) RoutesNotExported

func (src *SingleTableBirdwatcher) RoutesNotExported(
	ctx context.Context,
	neighborID string,
) (*api.RoutesResponse, error)

RoutesNotExported get all not exported routes

func (*SingleTableBirdwatcher) RoutesReceived

func (src *SingleTableBirdwatcher) RoutesReceived(
	ctx context.Context,
	neighborID string,
) (*api.RoutesResponse, error)

RoutesReceived gets all received routes

Jump to

Keyboard shortcuts

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