1
0
mirror of https://github.com/alice-lg/alice-lg.git synced 2024-05-11 05:55:03 +00:00

initial openbgpd source

This commit is contained in:
Annika Hannig
2021-03-24 14:26:46 +01:00
parent 93501c6712
commit 7533d1e198
3 changed files with 42 additions and 5 deletions

View File

@ -5,13 +5,13 @@ import (
"time"
)
// General api response
// Response is a general API response
type Response interface{}
// Details, usually the original backend response
// Details are usually the original backend response
type Details map[string]interface{}
// Error Handling
// ErrorResponse encodes an error message and code
type ErrorResponse struct {
Message string `json:"message"`
Code int `json:"code"`
@ -19,12 +19,12 @@ type ErrorResponse struct {
RouteserverId string `json:"routeserver_id"`
}
// Cache aware api response
// CacheableResponse is a cache aware API response
type CacheableResponse interface {
CacheTTL() time.Duration
}
// Config
// ConfigResponse is a response with client runtime configuration
type ConfigResponse struct {
Asn int `json:"asn"`
@ -51,6 +51,7 @@ type ConfigResponse struct {
PrefixLookupEnabled bool `json:"prefix_lookup_enabled"`
}
// Noexport options
type Noexport struct {
LoadOnDemand bool `json:"load_on_demand"`
}

View File

@ -0,0 +1,9 @@
package openbgpd
// Config is a OpenBGPD source config
type Config struct {
ID string
Name string
API string `ini:"api"`
}

View File

@ -0,0 +1,27 @@
package openbgpd
import (
"net/http"
"github.com/alice-lg/alice-lg/pkg/api"
)
// Source implements the OpenBGPD source for Alice.
// It is intendet to consume structured bgpctl output
// queried over HTTP using a `openbgpd-state-server`.
type Source struct {
// API is the http host and api prefix. For
// example http://rs1.mgmt.ixp.example.net:29111/api/v1
API string
}
// ExpireCaches expires all cached data
func (s *Source) ExpireCaches() int {
return 0 // Nothing to expire yet
}
// Status returns an API status response. In our case
// this is pretty much only that the service is available.
func (s *Source) Status() (*api.StatusResponse, error) {
return nil, nil
}